• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Working on a Loop!

Status
Not open for further replies.
Level 7
Joined
Dec 8, 2005
Messages
319
Ok so basicly, here are the variables to start out with. I was just wondering if there was a way to set the number of times maxium number of times to the number of "Generators" in the regions? like i dont want to set it to 150 because it is inefficant with it running 150 times. when it only has to run like 10 or 20 or 30 but any ideas?
  • Variables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TwentyBuilding[0] = Infantry Generator
      • Set TwentyBuilding[1] = Machine Gunner Generator
      • Set TwentyBuilding[2] = Tactics Generator
      • Set TwentyBuilding[3] = Rocket Generator
      • Set TwentyBuilding[4] = Heavy Infantry Generator
      • Set TwentyBuilding[5] = Repair Generator
      • Set TwentyUnit[0] = Clockwerk Goblin 20 Seconds
      • Set TwentyUnit[1] = Clockwerk Machine Gunner 20 Seconds
      • Set TwentyUnit[2] = Clockwerk Tactical 20 Seconds
      • Set TwentyUnit[3] = Clockwerk Rocket Launcher 20 Seconds
      • Set TwentyUnit[4] = Clockwerk Heavy Tank 30 Seconds
      • Set TwentyUnit[5] = Clockwerk Repairer 20 Seconds
      • Set UnitSpawner[0] = Crystal1 Team1 <gen>
      • Set UnitSpawner[1] = Crystal2 Team1 <gen>
      • Set UnitSpawner[2] = Crystal3 Team1 <gen>
      • Set UnitSpawner[3] = Crystal1 Team2 <gen>
      • Set UnitSpawner[4] = Crystal2 Team2 <gen>
      • Set UnitSpawner[5] = Crystal3 Team2 <gen>
      • Set UnitSelector[0] = UnitSelector1 Team1 <gen>
      • Set UnitSelector[1] = UnitSelector2 Team1 <gen>
      • Set UnitSelector[2] = UnitSelector3 Team1 <gen>
      • Set UnitSelector[3] = UnitSelector1 Team 2 <gen>
      • Set UnitSelector[4] = UnitSelector2 Team 2 <gen>
      • Set UnitSelector[5] = UnitSelector3 Team 2 <gen>
  • [/hidden]
Ok so lets clear this up. This is what the variables mean.
TwentyBuilding = specific building
TwentyUnit = Spawned unit... if player has the correctly built building
UnitSpawner = the region where the units are spawned.
UnitSelector = the region where you can build.

now there are 3 lanes. with a team1+team2 on either side. so units have to stay in the correct lane and spawn in the correct lane. but now here is my loop.(I guess you can say I am a noob at loops)

  • Spawner 20 Seconds
    • Events
      • Time - TimerforSpawning[0] expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • For each (Integer B) from 1 to 10, do (Actions)
            • Loop - Actions
              • Custom script: set bj_wantDestroyGroup = true
              • Unit Group - Pick every unit in (Units in UnitSelector[(Integer B)]) and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Unit-type of (Picked unit)) Equal to TwentyBuilding[(Integer A)]
                      • (Owner of (Picked unit)) Equal to Player 1 (Red)
                      • (Owner of (Picked unit)) Equal to Player 2 (Blue)
                      • (Owner of (Picked unit)) Equal to Player 3 (Teal)
                    • Then - Actions
                      • Unit - Create 1 TwentyUnit[(Integer A)] for Player 7 (Green) at (Center of UnitSpawner[(Integer B)]) facing Default building facing degrees
                    • Else - Actions
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Unit-type of (Picked unit)) Equal to TwentyBuilding[(Integer A)]
                          • (Owner of (Picked unit)) Equal to Player 4 (Purple)
                          • (Owner of (Picked unit)) Equal to Player 5 (Yellow)
                          • (Owner of (Picked unit)) Equal to Player 6 (Orange)
                        • Then - Actions
                          • Unit - Create 1 TwentyUnit[(Integer A)] for Player 8 (Pink) at (Center of UnitSpawner[(Integer B)]) facing Default building facing degrees
                        • Else - Actions
  • [/hidden]
and honestly if anyone feels they can help me to improve the trigger it self in anyway... please feel free to tell me. i like to learn new stuff so any technique helps. =D

***EDIT***
ok well i seems like i got a double post... sorry for the confusion but this is what i ment... and this is the correct code this time around. sorry about that guy and my question is at the top... and yes ghost this is leakable... will fix it in a bit. but hey lets try this one more time =D
 
Last edited:
Level 29
Joined
Jul 29, 2007
Messages
5,174
You have a big unit group leak.
Add a custom script with this text "set bj_wantDestroyGroup = true" right before the line that you pick the units.

As for the 12 location leaks Flood mentioned, im not really sure if Center Of Region leaks, but just in case (since I don't think anyone really knows it) set a point variable to that point and remove it after you create the units.
 
Level 7
Joined
Dec 8, 2005
Messages
319
sorry guys... please read my edit note. I had 2 post and everyone commented this one while i was editing my first one... lol
and honestly about leaking with regions.... i have never seen a leak when i made a variables as regions... and my regions are not moving... so they are all set areas... so honestly i dont think it matters but yes the pick units leak i need to fix real fast
 
Level 7
Joined
Dec 8, 2005
Messages
319
um... it is 0-5 which means there are 6 and no there will be about 150 variables total but this was just to make the loop... and 1 to 10 was enough... i could but it to 150... but thereit just seems pointless because i dont think even one would spam one build constantly... this map is like a Boreal Conflict... but just seeing if there was an easy way to make it... i technically added every building owned by each player except the computer and yet that still adds builds that might spawn units that are not on the 20 second spawner... but that is why i was asking about a better way or custom value the buildings or whatever.
 
Status
Not open for further replies.
Top