• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Loop with waits

Status
Not open for further replies.
Level 7
Joined
May 30, 2018
Messages
290
Hello, I tried to make a really basic trigger to achieve a kind of "burst fire" effect on one of my units attacks

  • Burst Fire
    • Events
      • Unit - A unit Is attacked
    • Conditions
      • (Unit-type of (Attacking unit)) Equal to Clone Arc Trooper (Minigun)
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Current order of (Attacking unit)) Equal to (Order(attack))
            • Then - Actions
              • Wait 1.00 seconds
              • Unit - Order (Attacking unit) to Stop.
              • Wait 1.00 seconds
              • Unit - Order (Attacking unit) to Attack (Attacked unit)
            • Else - Actions
It actually functions alright for the attack itself, the only problem is I don't know how to make the unit leave the loop, I can't pull it away from its target once it starts attacking, since the loop always forces it back into attacking...Is there a way I can make the unit leave the loop after it gets a move order?

Thanks!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
You can use a global variable to communicate with the loop, allowing you to skip the remaining iterations should a condition be met. This global variable could be set every time the exit condition is met. It could also be used to change the attack target rather than exiting the loop.

Using the standard GUI wait action is not recommended due to it being network synchronized and approximating real time rather than game time. Using a timer or periodic trigger is much more accurate and the recommended approach.
 
Level 7
Joined
May 30, 2018
Messages
290
You can use a global variable to communicate with the loop, allowing you to skip the remaining iterations should a condition be met. This global variable could be set every time the exit condition is met. It could also be used to change the attack target rather than exiting the loop.

Using the standard GUI wait action is not recommended due to it being network synchronized and approximating real time rather than game time. Using a timer or periodic trigger is much more accurate and the recommended approach.
mhhh, thanks, I will have a look into that...could you give me a hint on how to create a global variable in GUI? (if thats even possible)
 
Level 12
Joined
Feb 5, 2018
Messages
521
mhhh, thanks, I will have a look into that...could you give me a hint on how to create a global variable in GUI? (if thats even possible)

All GUI variables are global in warcraft 3 editor by default. In the trigger editor you can see a button called "Create new variable".
 
Level 7
Joined
May 30, 2018
Messages
290
All GUI variables are global in warcraft 3 editor by default. In the trigger editor you can see a button called "Create new variable".
Thanks for the answer :)! Anyways I solved the problem in another way with the help of a dummy unit that casts silence on the attacking unit, so it can't attack for a given time!
 
Status
Not open for further replies.
Top