So I have a trigger that goes off when a unit enters a region that causes the units movement speed decrease every 3 seconds by an amount and if it enters another area, that its movement speed is set back to normal.
The issue is that setting it back doesn't "disable" the trigger that periodically slows down the unit. Is there a way to "stop trigger" non-globally or a clever way of setting up run/stop actions that would make this work?
p.s. Or is there a way to make this "Repeat Action forever" work differently?
[
Events:
Unit - Any Unit Enters Region1
Unit - Any Unit Enters Region2
Conditions:
(Owner of (Trriggering unit)) == 1
Actions:
General - If (Conditions) then do (Actions) else do (Actions)
- If
((Triggering unit) is in region1) == True
- Then
Unit - Set (Triggering unit) Movement Speed Max to ((Unit type of (Triggering unit)) Movement Speed)
- Else
- General - If (Conditions) then do (Actions) else do (Actions)
If
(Triggering unit) is in region2) == True
Then
General - Repeat (Actions) forever
Actions
Timer - Start (New timer) as a One Shot timer that will elxpire in 3.0 Game Time seconds
General - Wait for (Last started timer) to have 0.0 seconds Remaining
Unit - Set (Triggering unit) Movement Speed Max to (((Triggering unit) Movement Speed Max (Current)) * 0.9)
Timer - Restart (Last started timer)
Else
Instead of using Repeat Forever, use a while loop with a condition. A while loop will repeat infinitely as long as the condition is true, then break out as soon as it is false.
You can also use the Wait action to add delay instead of using a timer. Timers are for when you want to display a timer for the players.
When unit leaves region remove behavior when unit enters region add b Javier if unit gas behavior then you're trigger that you have when unit leaves region remove behavior but you woul have to make a blank behavior lik a reference.
@ZMilla93
That worked well, but for some reason, when the unit goes to region2 where the movement speed is reset, it still gets one instance of a slowdown right after and then stops.
I think it may be because the time waiting isn't stopped, so even if the unit enters region1, the 3 seconds delay will still count down.
I'm not sure how to fix that a clean way, but I patched it by setting a trigger with:
Event - Unit property (movement speed max) changed
Condition - decreased to less than standard & is in region1
Action - Set to standard movement speed max.
It's the patch that works. But then if I make like marauders, I come back to the same problem of: how do you ignore triggers with things your doing for specific events and/or units?
*Is there an actions that would be something like: "Make Unit/Player Immune to Trigger" with duration, while, and things like that that you could add to it?
@Doomedearti
I see what you're saying, I'm just a little lazy to do that right now :P but seems like a very good clever solution. I hope there's a way to do it with triggers alone though, I would think it's possible.
While loops only check the condition at the start of the loop, then it executes everything in the action section before ever rechecking the condition. So yes you are correct in thinking the trigger is not being canceled during the wait. There are certainly ways to make triggers ignore specific units/players, but a much more straight forward way to fix your problem is to just move your wait action to the very end of the while loop. That way you are executing all your actions in the same game tick that you are checking your conditions, rather than running actions based on the conditions of the game 3 seconds ago.
The one thing this changes is that originally when your unit entered a region there would be a 3 second delay before the first speed debuff is applied. After making this change the first speed debuff would be applied instantly. If that change is fine with you, then you are good to go. If you wanted to readd the initial delay you could add an extra wait statement before the while loop even starts.
So I have a trigger that goes off when a unit enters a region that causes the units movement speed decrease every 3 seconds by an amount and if it enters another area, that its movement speed is set back to normal.
The issue is that setting it back doesn't "disable" the trigger that periodically slows down the unit. Is there a way to "stop trigger" non-globally or a clever way of setting up run/stop actions that would make this work?
p.s. Or is there a way to make this "Repeat Action forever" work differently?
[
Events:
Unit - Any Unit Enters Region1
Unit - Any Unit Enters Region2
Conditions:
(Owner of (Trriggering unit)) == 1
Actions:
General - If (Conditions) then do (Actions) else do (Actions)
- If
((Triggering unit) is in region1) == True
- Then
Unit - Set (Triggering unit) Movement Speed Max to ((Unit type of (Triggering unit)) Movement Speed)
- Else
- General - If (Conditions) then do (Actions) else do (Actions)
If
(Triggering unit) is in region2) == True
Then
General - Repeat (Actions) forever
Actions
Timer - Start (New timer) as a One Shot timer that will elxpire in 3.0 Game Time seconds
General - Wait for (Last started timer) to have 0.0 seconds Remaining
Unit - Set (Triggering unit) Movement Speed Max to (((Triggering unit) Movement Speed Max (Current)) * 0.9)
Timer - Restart (Last started timer)
Else
]
help?
@EagleXs: Go
Instead of using Repeat Forever, use a while loop with a condition. A while loop will repeat infinitely as long as the condition is true, then break out as soon as it is false.
You can also use the Wait action to add delay instead of using a timer. Timers are for when you want to display a timer for the players.
When unit leaves region remove behavior when unit enters region add b Javier if unit gas behavior then you're trigger that you have when unit leaves region remove behavior but you woul have to make a blank behavior lik a reference.
@ZMilla93
That worked well, but for some reason, when the unit goes to region2 where the movement speed is reset, it still gets one instance of a slowdown right after and then stops.
I think it may be because the time waiting isn't stopped, so even if the unit enters region1, the 3 seconds delay will still count down.
I'm not sure how to fix that a clean way, but I patched it by setting a trigger with:
Event - Unit property (movement speed max) changed
Condition - decreased to less than standard & is in region1
Action - Set to standard movement speed max.
It's the patch that works. But then if I make like marauders, I come back to the same problem of: how do you ignore triggers with things your doing for specific events and/or units?
*Is there an actions that would be something like: "Make Unit/Player Immune to Trigger" with duration, while, and things like that that you could add to it?
@Doomedearti
I see what you're saying, I'm just a little lazy to do that right now :P but seems like a very good clever solution. I hope there's a way to do it with triggers alone though, I would think it's possible.
@EagleXs: Go
While loops only check the condition at the start of the loop, then it executes everything in the action section before ever rechecking the condition. So yes you are correct in thinking the trigger is not being canceled during the wait. There are certainly ways to make triggers ignore specific units/players, but a much more straight forward way to fix your problem is to just move your wait action to the very end of the while loop. That way you are executing all your actions in the same game tick that you are checking your conditions, rather than running actions based on the conditions of the game 3 seconds ago.
The one thing this changes is that originally when your unit entered a region there would be a 3 second delay before the first speed debuff is applied. After making this change the first speed debuff would be applied instantly. If that change is fine with you, then you are good to go. If you wanted to readd the initial delay you could add an extra wait statement before the while loop even starts.
@ZMilla93:
Awesome, that makes sense, thanks!