• 🏆 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 on and on and on...

Level 5
Joined
Aug 19, 2021
Messages
33
  • Timer Expires
    • Events
      • Time - RoundWindow expires
    • Conditions
    • Actions
      • Custom script: bj_wantDestroyGroup = true
      • Wait until ((All units of (Units owned by Player 24 (Peanut).) are dead) Equal to True), checking every 1.00 seconds
      • Game - Display to (All players) the text: A rumbling echoed i...
      • Countdown Timer - Start RoundWindow as a Repeating timer that will expire in 60.00 seconds
      • Set VariableSet RoundWindow = (Last started timer)
      • Countdown Timer - Create a timer window for (Last started timer) with title The snow rumbles fo...
  • Spawning
    • Events
      • Time - RoundWindow expires
    • Conditions
    • Actions
      • Set VariableSet LvlNum = (LvlNum + 1)
      • For each (Integer A) from 1 to Unit_Amount_1[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_1[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer A) from 1 to Unit_Amount_2[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_2[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer A) from 1 to Unit_Amount_3[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_3[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer A) from 1 to Unit_Amount_4[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_4[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer A) from 1 to Unit_Amount_5[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_5[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
This was a wave test i tried which works wonder and flawlessly with a timer set to it! The problem is, i want it to loop BACK to the first wave again, basically an endless loop for the user to beat up as much as they want to, is there a way to modify em to do so?
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
Integer loops with waits are a REALLY bad idea. You are going to to overwrite the loop bounds or the current loop position if anything else uses an Integer A loop during that time.

Create a new integer variable and use that for looping in these triggers (and nothing else).

To start over at the top of the list: check the value of LvlNum after incrementing it and if it’s more than the last wave set it back to 1. That’s an integer comparison.
 
Level 5
Joined
Aug 19, 2021
Messages
33
Should i make one for every wave's Loop integer for each waves or just one would be enough? Cause i fear it would overwrite each other again if it ever happened...
 
Level 39
Joined
Feb 27, 2007
Messages
5,019
The integer B loops don't have a wait in them so they all happen in a row. That is usually fine but if something you do in the loop causes another trigger to fire, that trigger will go off first. Imagine you have a trigger that uses an Integer B loop that runs when a unit enters the spawn region. In that case it would go off when the first unit is created and would change those numbers.

You need 2 integers. One replaces int A and one replaces int B. That will be fine as long as you don't use those variables for anything else. In case you're not aware of leaks you may want to read this (and the thread it links to): Things That Leak.
 
Level 5
Joined
Aug 19, 2021
Messages
33
  • Spawning
    • Events
      • Time - RoundWindow expires
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LvlNum Equal to 5
        • Then - Actions
          • Set VariableSet LvlNum = 1
        • Else - Actions
      • Set VariableSet LvlNum = (LvlNum + 1)
      • For each (Integer LoopCommand1) from 1 to Unit_Amount_1[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer LoopCommand2) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_1[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer LoopCommand1) from 1 to Unit_Amount_2[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer LoopCommand2) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_2[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer LoopCommand1) from 1 to Unit_Amount_3[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer LoopCommand2) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_3[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer LoopCommand1) from 1 to Unit_Amount_4[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer LoopCommand2) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_4[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
      • For each (Integer LoopCommand1) from 1 to Unit_Amount_5[LvlNum], do (Actions)
        • Loop - Actions
          • For each (Integer LoopCommand2) from 1 to 2, do (Actions)
            • Loop - Actions
              • Unit - Create 1 Unit_Type_5[LvlNum] for Player 24 (Peanut) at (Position of Circle of Power (large) 0022 <gen>) facing Default building facing degrees
              • Unit - Order (Last created unit) to Attack-Move To (Center of Attack Point <gen>)
          • Wait 0.75 game-time seconds
So it should be looking quiet like this rite?
 
Top