- Joined
- Jun 18, 2011
- Messages
- 168
I can get the knockback to work on a single unit, but I am not experienced enough to think of a way to knockback a unit group or loop the trigger to knockback each unit (in range of the point I create when casting a spell) one at a time.
-
Actions to apply
- Events
- Conditions
-
Actions
- -------- This is the caster of the knockback. --------
- -------- If you use spells, it´s mostly the 'triggering unit' or the 'casting unit'. --------
- Set KBA_Caster = (Triggering unit)
- -------- --------
- -------- This is the unit knocked back. Set this variable to the unit which should receive the knockback. --------
- -------- Use for example 'Target unit of ability being cast' or 'picked unit', 'attacking unit', 'casting unit', 'triggering unit' or whatever. --------
- Set KBA_TargetUnit = (Target unit of ability being cast)
- -------- --------
- -------- This is the location from where the unit should be knocked back. --------
- -------- Don´t set this location to the position of the unit which should be knocked back. --------
- Set KBA_StartingPosition = (Target point of ability being cast)
- -------- --------
- -------- This saves the level of the spell. --------
- -------- If the level shouldn´t influence the knockback, set the variable to 1. --------
- Set KBA_Level = (Level of (Ability being cast) for (Triggering unit))
- -------- --------
- -------- This determines the speed of the knockback. --------
- -------- If you set the speed to 0, the unit won´t move. --------
- Set KBA_Speed = 7.00
- -------- --------
- -------- This determines the distance knockbacked per level of the spell. --------
- -------- If the level shouldn´t influence the knockback, simply set this variable to the distance you wish. --------
- Set KBA_DistancePerLevel = 200.00
- -------- --------
- -------- The following both variables store the path of the effects used. --------
- -------- Effect[1] is more often used than Effect[2]. --------
- Set KBA_SpecialEffects[1] = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
- Set KBA_SpecialEffects[2] = Abilities\Weapons\AncientProtectorMissile\AncientProtectorMissile.mdl
- -------- --------
- -------- Set the following variable to 'false' to allow trees to survive a collision with a knocked unit. --------
- -------- Set the following variable to 'true' to kill trees upon collision with a knocked unit. --------
- Set KBA_DestroyTrees = True
- -------- --------
- -------- After setting the needed variables we start the knockback. --------
- Trigger - Run Cast A Knockback <gen> (checking conditions)
- -------- Done. The unit knockbacked if the trigger triggers. --------
-
Cast A Knockback
- Events
- Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (KBA_TargetUnit is in KB_KnockbackedUnits) Equal to True
-
Then - Actions
- Unit Group - Remove KBA_TargetUnit from KB_KnockbackedUnits
- Set KB_CountBuffs = (KB_CountBuffs - 1)
-
For each (Integer KB_GeneralIntegers[2]) from 1 to KB_TotalKnockUnits, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_Units[KB_GeneralIntegers[1]] Equal to KBA_TargetUnit
-
Then - Actions
- Set KB_GeneralIntegers[1] = KB_GeneralIntegers[2]
- Set KB_GeneralIntegers[2] = KB_TotalKnockUnits
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_TotalKnockUnits Greater than KB_GeneralIntegers[1]
-
Then - Actions
- Set KB_Levels[KB_GeneralIntegers[1]] = KB_Levels[KB_TotalKnockUnits]
- Set KB_Units[KB_GeneralIntegers[1]] = KB_Units[KB_TotalKnockUnits]
- Set KB_Angle[KB_GeneralIntegers[1]] = KB_Angle[KB_TotalKnockUnits]
- Set KB_MaxDistance[KB_GeneralIntegers[1]] = KB_MaxDistance[KB_TotalKnockUnits]
- Set KB_ReachedDistance[KB_GeneralIntegers[1]] = KB_ReachedDistance[KB_TotalKnockUnits]
- Set KB_ReduceSpeedReal[KB_GeneralIntegers[1]] = KB_ReduceSpeedReal[KB_TotalKnockUnits]
- Set KB_SpecificSpeed[KB_GeneralIntegers[1]] = KB_SpecificSpeed[KB_TotalKnockUnits]
- Set KB_Effects_1[KB_GeneralIntegers[1]] = KB_Effects_1[KB_TotalKnockUnits]
- Set KB_Effects_2[KB_EffectCounter2[1]] = KB_Effects_2[KB_TotalKnockUnits]
- Set KB_DestroyTrees[KB_GeneralIntegers[1]] = KB_DestroyTrees[KB_TotalKnockUnits]
- Set KB_EffectCounter[KB_GeneralIntegers[1]] = KB_EffectCounter[KB_TotalKnockUnits]
- Set KB_EffectCounter2[KB_GeneralIntegers[1]] = KB_EffectCounter2[KB_TotalKnockUnits]
- Set KB_GeneralIntegers[1] = (KB_GeneralIntegers[1] - 1)
- Else - Actions
-
If - Conditions
- Set KB_Units[KB_TotalKnockUnits] = No unit
- Set KB_TotalKnockUnits = (KB_TotalKnockUnits - 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_CountBuffs Equal to 0
-
Then - Actions
- Set KB_TotalKnockUnits = 0
- Trigger - Turn off Get Knockback <gen>
- Else - Actions
-
If - Conditions
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_CountBuffs Equal to 0
-
Then - Actions
- Trigger - Turn on Get Knockback <gen>
- Else - Actions
-
If - Conditions
- Set KB_CountBuffs = (KB_CountBuffs + 1)
- Set KB_TotalKnockUnits = (KB_TotalKnockUnits + 1)
- Set KB_Casters[KB_TotalKnockUnits] = KBA_Caster
- Set KB_Levels[KB_TotalKnockUnits] = KBA_Level
- Set KB_Units[KB_TotalKnockUnits] = KBA_TargetUnit
- Set KB_StartPositions[KB_TotalKnockUnits] = KBA_StartingPosition
- Set KB_TempPoint[KB_TotalKnockUnits] = (Position of KBA_TargetUnit)
- Set KB_Angle[KB_TotalKnockUnits] = (Angle from KB_StartPositions[KB_TotalKnockUnits] to KB_TempPoint[KB_TotalKnockUnits])
- Set KB_MaxDistance[KB_TotalKnockUnits] = (KBA_DistancePerLevel x (Real(KBA_Level)))
- Set KB_ReachedDistance[KB_TotalKnockUnits] = 0.00
- Set KB_ReduceSpeedReal[KB_GeneralIntegers[1]] = 0.00
- Set KB_SpecificSpeed[KB_TotalKnockUnits] = KBA_Speed
- Set KB_Effects_1[KB_TotalKnockUnits] = KBA_SpecialEffects[1]
- Set KB_Effects_2[KB_TotalKnockUnits] = KBA_SpecialEffects[2]
- Set KB_DestroyTrees[KB_TotalKnockUnits] = KBA_DestroyTrees
- Set KB_EffectCounter[KB_GeneralIntegers[1]] = 0
- Set KB_EffectCounter2[KB_GeneralIntegers[1]] = 0
- Unit Group - Add KBA_TargetUnit to KB_KnockbackedUnits
- Custom script: call RemoveLocation (udg_KBA_StartingPosition)
- Custom script: call RemoveLocation (udg_KB_TempPoint [udg_KB_TotalKnockUnits] )
- Custom script: call RemoveLocation (udg_KB_StartPositions [udg_KB_TotalKnockUnits] )
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Get Knockback
-
Events
- Time - Every 0.02 seconds of game time
- Conditions
-
Actions
-
For each (Integer KB_GeneralIntegers[1]) from 1 to KB_TotalKnockUnits, do (Actions)
-
Loop - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- (KB_Units[KB_GeneralIntegers[1]] is in KB_KnockbackedUnits) Equal to True
-
Then - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_ReachedDistance[KB_GeneralIntegers[1]] Greater than or equal to KB_MaxDistance[KB_GeneralIntegers[1]]
-
Then - Actions
- Unit Group - Remove KB_Units[KB_GeneralIntegers[1]] from KB_KnockbackedUnits
- Set KB_CountBuffs = (KB_CountBuffs - 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_TotalKnockUnits Greater than KB_GeneralIntegers[1]
-
Then - Actions
- Set KB_Levels[KB_GeneralIntegers[1]] = KB_Levels[KB_TotalKnockUnits]
- Set KB_Units[KB_GeneralIntegers[1]] = KB_Units[KB_TotalKnockUnits]
- Set KB_Angle[KB_GeneralIntegers[1]] = KB_Angle[KB_TotalKnockUnits]
- Set KB_MaxDistance[KB_GeneralIntegers[1]] = KB_MaxDistance[KB_TotalKnockUnits]
- Set KB_ReachedDistance[KB_GeneralIntegers[1]] = KB_ReachedDistance[KB_TotalKnockUnits]
- Set KB_ReduceSpeedReal[KB_GeneralIntegers[1]] = KB_ReduceSpeedReal[KB_TotalKnockUnits]
- Set KB_SpecificSpeed[KB_GeneralIntegers[1]] = KB_SpecificSpeed[KB_TotalKnockUnits]
- Set KB_Effects_1[KB_GeneralIntegers[1]] = KB_Effects_1[KB_TotalKnockUnits]
- Set KB_Effects_2[KB_GeneralIntegers[1]] = KB_Effects_2[KB_TotalKnockUnits]
- Set KB_DestroyTrees[KB_GeneralIntegers[1]] = KB_DestroyTrees[KB_TotalKnockUnits]
- Set KB_EffectCounter[KB_GeneralIntegers[1]] = KB_EffectCounter[KB_TotalKnockUnits]
- Set KB_EffectCounter2[KB_GeneralIntegers[1]] = KB_EffectCounter2[KB_TotalKnockUnits]
- Set KB_GeneralIntegers[1] = (KB_GeneralIntegers[1] - 1)
- Else - Actions
-
If - Conditions
- Set KB_Units[KB_TotalKnockUnits] = No unit
- Set KB_TotalKnockUnits = (KB_TotalKnockUnits - 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_CountBuffs Equal to 0
-
Then - Actions
- Set KB_TotalKnockUnits = 0
- Trigger - Turn off (This trigger)
- Else - Actions
-
If - Conditions
-
Else - Actions
- Set KB_ReducedReal = ((KB_SpecificSpeed[KB_GeneralIntegers[1]] / KB_MaxDistance[KB_GeneralIntegers[1]]) x KB_ReachedDistance[KB_GeneralIntegers[1]])
- Set KB_ReduceSpeedReal[KB_GeneralIntegers[1]] = (KB_ReducedReal - (KB_ReduceSpeedReal[KB_GeneralIntegers[1]] x 0.10))
- Set KB_TempReal = ((KB_SpecificSpeed[KB_GeneralIntegers[1]] - KB_ReduceSpeedReal[KB_GeneralIntegers[1]]) x 2.00)
- Set KB_TempPoint[1] = (Position of KB_Units[KB_GeneralIntegers[1]])
- Set KB_TempPoint[2] = (KB_TempPoint[1] offset by KB_TempReal towards KB_Angle[KB_GeneralIntegers[1]] degrees)
- Set KB_EffectCounter[KB_GeneralIntegers[1]] = (KB_EffectCounter[1] + 1)
- Set KB_EffectCounter2[KB_GeneralIntegers[1]] = (KB_EffectCounter2[KB_GeneralIntegers[1]] + 1)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_DestroyTrees[KB_GeneralIntegers[1]] Equal to True
-
Then - Actions
-
Destructible - Pick every destructible within 200.00 of KB_TempPoint[2] and do (Actions)
-
Loop - Actions
- Destructible - Kill (Picked destructible)
-
Loop - Actions
-
Destructible - Pick every destructible within 200.00 of KB_TempPoint[2] and do (Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_EffectCounter[KB_GeneralIntegers[1]] Equal to 6
-
Then - Actions
- Set KB_EffectCounter2[KB_GeneralIntegers[1]] = 0
- Special Effect - Create a special effect at KB_TempPoint[1] using KB_Effects_1[KB_GeneralIntegers[1]]
- Special Effect - Destroy (Last created special effect)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
- KB_EffectCounter2[KB_GeneralIntegers[1]] Equal to 8
-
Then - Actions
- Set KB_EffectCounter2[KB_GeneralIntegers[1]] = 0
- Special Effect - Create a special effect at KB_TempPoint[1] using KB_Effects_2[KB_GeneralIntegers[1]]
- Special Effect - Destroy (Last created special effect)
- Else - Actions
-
If - Conditions
- Unit - Move KB_Units[KB_GeneralIntegers[1]] instantly to KB_TempPoint[2]
- Custom script: call RemoveLocation (udg_KB_TempPoint[1])
- Custom script: call RemoveLocation (udg_KB_TempPoint[2])
- Set KB_ReachedDistance[KB_GeneralIntegers[1]] = (KB_ReachedDistance[KB_GeneralIntegers[1]] + KB_TempReal)
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
- Else - Actions
-
If - Conditions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
Loop - Actions
-
For each (Integer KB_GeneralIntegers[1]) from 1 to KB_TotalKnockUnits, do (Actions)
-
Events