• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Knockback Problem

Status
Not open for further replies.
Level 13
Joined
Mar 29, 2012
Messages
542
Hey guys i have a problem in my spell 'Knockback'...:ogre_frown::ogre_rage:

Spell Description :

Knock the target backwards, dealing bonus damage when hit tree.
Level 1 - 50 knock damage, 10 tree damage.
Level 2 - 75 knock damage, 15 tree damage.
Level 3 - 100 knock damage, 20 tree damage.

Problem that i found using debug message :
The caster cast the spell on some unit, but when cast sometimes the distance change to correct value and sometimes change to wrong value.
Example :
The first cast the distance set to 400, the second cast the distance set to -10, -20, or -30. The third cast the distance set to 400.

Here is the triggers
[trigger=]K Configuration
Events
Map initialization
Conditions
Actions
-------- CONFIGURABLE --------
-------- set the distance to knock the target --------
Set K_Max_Distance[1] = 400.00
Set K_Max_Distance[2] = 500.00
Set K_Max_Distance[3] = 600.00
-------- set the speed when target is knocked --------
Set K_Knock_Speed[1] = 30.00
Set K_Knock_Speed[2] = 30.00
Set K_Knock_Speed[3] = 30.00
-------- set the damage to target --------
Set K_Damage[1] = 50.00
Set K_Damage[2] = 75.00
Set K_Damage[3] = 100.00
-------- set the damage to target when target hit tree --------
Set K_Bonus_Damage[1] = 10.00
Set K_Bonus_Damage[2] = 15.00
Set K_Bonus_Damage[3] = 20.00
-------- set the range to detect nearby tree of target --------
Set K_Target_AoE = 150.00
-------- set the effect when the target start knocked --------
Set K_Effect[1] = Abilities\Spells\Orc\WarStomp\WarStompCaster.mdl
-------- set the effect when the target is knocking back --------
Set K_Effect[2] = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
-------- set the effect when the target is knocked --------
Set K_Effect[3] = Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
-------- set the attack type --------
Set K_Attack_Type = Normal
-------- set the damage type --------
Set K_Damage_Type = Defensive
[/trigger]
[trigger=]K Cast
Events
Unit - A unit Starts the effect of an ability
Conditions
(Ability being cast) Equal to Knockback
Actions
-------- START --------
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K_Index_Size Equal to 0
Then - Actions
Trigger - Turn on K Loop <gen>
Else - Actions
Set K_Index_Size = (K_Index_Size + 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K_Index_Size Greater than K_Max_Index
Then - Actions
Set K_Index[K_Index_Size] = K_Index_Size
Set K_Max_Index = K_Index_Size
Else - Actions
Set K_Current_Index = K_Index[K_Index_Size]
Set K_Caster[K_Current_Index] = (Triggering unit)
Set K_Target[K_Current_Index] = (Target unit of ability being cast)
Set K_Level = (Level of (Ability being cast) for K_Caster[K_Current_Index])
Set K_Max_Distance[K_Current_Index] = K_Max_Distance[K_Level]
Set K_Knock_Speed[K_Current_Index] = K_Knock_Speed[K_Level]
Set K_Damage[K_Current_Index] = K_Damage[K_Level]
Set K_Bonus_Damage[K_Current_Index] = K_Bonus_Damage[K_Level]
Set Temp_Point = (Position of K_Caster[K_Current_Index])
Set Temp_Point2 = (Position of K_Target[K_Current_Index])
Set K_Angle[K_Current_Index] = (Angle from Temp_Point to Temp_Point2)
Custom script: call RemoveLocation(udg_Temp_Point)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(K_Target[K_Current_Index] is A flying unit) Equal to True
Then - Actions
Special Effect - Create a special effect attached to the origin of K_Target[K_Current_Index] using K_Effect[1]
Special Effect - Destroy (Last created special effect)
Else - Actions
Special Effect - Create a special effect at Temp_Point2 using K_Effect[1]
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation(udg_Temp_Point2)
[/trigger]
[trigger=]K Loop
Events
Time - Every 0.03 seconds of game time
Conditions
Actions
For each (Integer K_Loop) from 1 to K_Index_Size, do (Actions)
Loop - Actions
Set K_Current_Index = K_Index[K_Loop]
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
And - All (Conditions) are true
Conditions
(K_Target[K_Current_Index] is alive) Equal to True
K_Max_Distance[K_Current_Index] Greater than 0.00
Then - Actions
Set Temp_Point = (Position of K_Target[K_Current_Index])
Set Temp_Point2 = (Temp_Point offset by K_Knock_Speed[K_Current_Index] towards K_Angle[K_Current_Index] degrees)
Set K_Point_X = (X of Temp_Point2)
Set K_Point_Y = (Y of Temp_Point2)
Custom script: call RemoveLocation(udg_Temp_Point)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(K_Target[K_Current_Index] is A flying unit) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Terrain pathing at Temp_Point2 of type Flyability is off) Equal to True
Then - Actions
Set K_Max_Distance[K_Current_Index] = 0.00
Else - Actions
Custom script: call SetUnitX(udg_K_Target[udg_K_Current_Index], udg_K_Point_X)
Custom script: call SetUnitY(udg_K_Target[udg_K_Current_Index], udg_K_Point_Y)
Special Effect - Create a special effect attached to the origin of K_Target[K_Current_Index] using K_Effect[2]
Special Effect - Destroy (Last created special effect)
Else - Actions
Set Temp_Point = (Position of K_Target[K_Current_Index])
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Terrain pathing at Temp_Point2 of type Walkability is off) Equal to True
Then - Actions
Set K_Max_Distance[K_Current_Index] = 0.00
Else - Actions
Custom script: call SetUnitX(udg_K_Target[udg_K_Current_Index], udg_K_Point_X)
Custom script: call SetUnitY(udg_K_Target[udg_K_Current_Index], udg_K_Point_Y)
Special Effect - Create a special effect at Temp_Point using K_Effect[2]
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation(udg_Temp_Point)
Destructible - Pick every destructible within K_Target_AoE of Temp_Point2 and do (Actions)
Loop - Actions
Unit - Order Harvester to Harvest (Picked destructible)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Current order of Harvester) Equal to (Order(harvest))
Then - Actions
Destructible - Kill (Picked destructible)
Unit - Cause K_Caster[K_Current_Index] to damage K_Target[K_Current_Index], dealing K_Bonus_Damage[K_Current_Index] damage of attack type K_Attack_Type and damage type K_Damage_Type
Else - Actions
Unit - Order Harvester to Stop
Custom script: call RemoveLocation(udg_Temp_Point2)
Set K_Max_Distance[K_Current_Index] = (K_Max_Distance[K_Current_Index] - K_Knock_Speed[K_Current_Index])
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(K_Target[K_Current_Index] is alive) Equal to True
Then - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(K_Target[K_Current_Index] is A flying unit) Equal to True
Then - Actions
Special Effect - Create a special effect attached to the origin of K_Target[K_Current_Index] using K_Effect[3]
Special Effect - Destroy (Last created special effect)
Else - Actions
Set Temp_Point = (Position of K_Target[K_Current_Index])
Special Effect - Create a special effect at Temp_Point using K_Effect[3]
Special Effect - Destroy (Last created special effect)
Custom script: call RemoveLocation(udg_Temp_Point)
Unit - Cause K_Caster[K_Current_Index] to damage K_Target[K_Current_Index], dealing K_Damage[K_Current_Index] damage of attack type K_Attack_Type and damage type K_Damage_Type
Else - Actions
-------- END --------
Set K_Index[K_Loop] = K_Index[K_Index_Size]
Set K_Index[K_Index_Size] = K_Current_Index
Set K_Index_Size = (K_Index_Size - 1)
Set K_Loop = (K_Loop - 1)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
K_Index_Size Equal to 0
Then - Actions
Trigger - Turn off (This trigger)
Skip remaining actions
Else - Actions
[/trigger]
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
What a crazy thing :$...

I don't know why so many people is crazy about using loops instead of unit groups.

Use a unit group for bashed people, and store the level of the ability they were bashed with in a Hashtable based on the unit ID (or in an integer variable if you're using Unit Indexer). Then Pick every unit in that group, retrieve the number from the picked unit ID (or custom value), and do all the actions using the global arrays you use to configure the ability using that number.

Since you're already making a lot of custom scripts and X/Y thing, you should turn this completely to jass (wich would make this a peace of cake)
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I don't know why so many people is crazy about using loops instead of unit groups.
Because Indexing > Hashtable, in speed, that's all.
Apparently, Unit Indexer (Bribe's system) has treated Indexing = Hashtable, so it's like Hashtable has no place left in THW :/

Only that, Hashtable still has the advantage, it can save data to an object that does not exist in the map yet (saving data to an Item-type, Unit-type in map init, Indexing can't do this (or can they ?))
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I don't know. It's faster by independent functions, but requires a whole script run everytime a unit enters the map.

Anyway, having 1 UnitGroup will be more than enough for this trigger, besides having just 1 Hashtable (wich works for any infinite amount of abilities, items, units, etc.) is, by far, more than enough, and still better than having all those Global arrays wich takes far more space than a hashtable does (and work just for one ability).

I think that 1UnitGroup, 1Hash, and 2 triggers (1 to set, and another to loop) would be more than enough for this. At the point where Picking this unit becomes impossible, you can destroy the unit group, and both triggers to clear up a bit of space.

In fact, I think he could use the default bj_lastCreatedGroup and GroupEnumUnits and GroupClear to handle anything...
 
Status
Not open for further replies.
Top