# [Trigger] Knockback not stopping!

Discussion in 'Triggers & Scripts' started by Raging Ent, May 12, 2011.

1. ### Raging Ent

Joined:
Jul 15, 2009
Messages:
552
Resources:
40
Icons:
34
Packs:
3
Maps:
3
Resources:
40
Hello,

I'm working on a item that knocks the caster back (or forward in this case).
Now, the unit starts moving but it never stops, what am I doing wrong?

(I made it so that every player can use it at once, no need to make multiple units use it since it's only for heroes, of which players only have 1)

Triggers

• Warp
• Events
• Unit - A unit Uses an item
• Conditions
• (Item-type of (Item being manipulated)) Equal to Warping Stick
• Actions
• Set KnockbackAngle[(Player number of (Owner of (Triggering unit)))] = (Facing of (Triggering unit))
• Set KnockbackDistance[(Player number of (Owner of (Triggering unit)))] = 300.00
• Set KnockbackEffect[(Player number of (Owner of (Triggering unit)))] = Abilities\Spells\Human\FlakCannons\FlakTarget.mdl
• Set KnockbackUnit[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
• Unit Group - Add (Triggering unit) to KnockbackGroup

• KnockbackLoops
• Events
• Time - Every 0.03 seconds of game time
• Conditions
• Actions
• For each (Integer A) from 1 to 8, do (Actions)
• Loop - Actions
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• (KnockbackUnit[(Integer A)] is in KnockbackGroup) Equal to True
• Then - Actions
• Set TempPoint = ((Position of KnockbackUnit[(Integer A)]) offset by 25.00 towards KnockbackAngle[(Integer A)] degrees)
• Special Effect - Create a special effect at TempPoint using KnockbackEffect[(Integer A)]
• Special Effect - Destroy (Last created special effect)
• Unit - Move KnockbackUnit[(Integer A)] instantly to TempPoint
• Set KnockbackDistance[(Integer A)] = (KnockbackDistance[(Integer A)] - 25.00)
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• KnockbackDistance[(Integer A)] Equal to 0.00
• Then - Actions
• Unit Group - Remove KnockbackUnit[(Integer A)] from KnockbackGroup
• Set KnockbackUnit[(Integer A)] = No unit
• Set KnockbackAngle[(Integer A)] = 0.00
• Set KnockbackEffect[(Integer A)] = <Empty String>
• Else - Actions
• Else - Actions
• Custom script: call RemoveLocation( udg_TempPoint )

2. ### Pharaoh_

Joined:
Nov 6, 2008
Messages:
8,128
Resources:
11
Icons:
3
Skins:
1
Spells:
6
Tutorials:
1
Resources:
11
First off, you can use hashtables.

Secondly, you can use Unit - Pick Units in Group action, instead of looping with Integer A:
• KnockbackLoops
• Events
• Time - Every 0.03 seconds of game time
• Conditions
• Actions
• If (All conditions are true) then do (Actions) else do (Actions)
• If - Conditions
• (KnockbackGroup is empty) Equal to True
• Then - Actions
• Trigger - Turn off (This trigger)
• Else - Actions
• Unit Group - Pick every unit in KnockbackGroup and do (Actions)
• Loop - Actions
• Set Point = (Position of (Picked unit))
• Set Point1 = (Point offset by 25.00 towards KnockbackAngle[(Player number of (Owner of (Picked unit)))]
• Unit - Move (Picked unit) instantly to Point1
• Special Effect - Create a special effect at Point1 using KnockbackEffect[(Player number of (Owner of (Picked unit)))]
• Special Effect - Destroy (Last created special effect)
• Set KnockbackDistance[(Player number of (Owner of (Picked unit)))] = (KnockbackDistance[(Player number of (Owner of (Picked unit)))] - 25.00)
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• KnockbackDistance[(Player number of (Owner of (Picked unit)))] Less than or Equal to 0.00
• Then - Actions
• Unit Group - Remove (Picked unit) from KnockbackGroup
• Else - Actions
• Custom script: call RemoveLocation (udg_Point)
• Custom script: call RemoveLocation (udg_Point1)

3. ### Dark_Axl

Joined:
Dec 12, 2007
Messages:
472
Resources:
2
Maps:
1
Spells:
1
Resources:
2
try to change the last check,
• If (All Conditions are True) then do (Then Actions) else do (Else Actions)
• If - Conditions
• KnockbackDistance[(Integer A)] Equal to 0.00

change from "Equal to" into "Less than or equal to" for safety...

and for additional info, your trigger leaks lots of locations... on the polar projection.

4. ### Leak-

Joined:
Jan 12, 2010
Messages:
162
Resources:
0
Resources:
0
How about in the Warp section, add a trigger that turns on KnockbackLoops
Then at the end of KnockbackLoops, add an If-Then statement:

If(KnockbackGroup is empty) equal to True, then Turn off this trigger.

" Moving multiple units different distances and directions with the same loop" section

5. ### Raging Ent

Joined:
Jul 15, 2009
Messages:
552
Resources:
40
Icons:
34
Packs:
3
Maps:
3
Resources:
40
Thanks, that really looks quite simple - didn't think of that.
Thanks!! (Again)

6. ### Raging Ent

Joined:
Jul 15, 2009
Messages:
552
Resources:
40
Icons:
34
Packs:
3
Maps:
3
Resources:
40
Leak!

If you like, you can help testing TA in a bit, on Northrend though so make a account..