• 🏆 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!

[Trigger] Random Point Multi-Spawn

Status
Not open for further replies.
Level 10
Joined
May 20, 2008
Messages
433
Well I'm having the trouble with: ((spawning X units in random places in one region)*30)*3 (for those who can't do math, its spawning units in a random point in a region multiplied by 90 (give or take a few)).

I have about 30 hallways that needs population by 3 different types of units at the start of a game (determined through variables done at start). What I'm currently doing is setting a variable (with an array of 30, approximately the amount of hallways) to a random point in a region at the start (therefore it is much easier to destroy the leak). The problem with this is that X units will spawn at the same random point. Is there any way to spawn a bunch of units at random points in a region without causing a leak?

Note that the second trigger is extremely far from finished, where the leaks are not fixed, nor are all the hallways dealt with (I would rather do it wrong 5 times then do it wrong 90)

  • Game Startup
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Game - Turn the day/night cycle Off
      • Game - Set the time of day to 24.00
      • -------- Variables --------
      • Set RRed_Controls = Red Controls <gen>
      • Set RYellow_Controls = Yellow Controls <gen>
      • Set RGreen_Controls = Green Controls <gen>
      • Set RBlue_Controls = Blue Controls <gen>
      • Set Objective_RNum1 = (Random integer number between 1 and 1)
      • Set Hallways[1] = (Random point in Hall1A <gen>)
      • Set Hallways[2] = (Random point in Hall1B <gen>)
      • Set Hallways[3] = (Random point in Hall2A <gen>)
      • Set Hallways[4] = (Random point in Hall2B <gen>)
      • Set Hallways[5] = (Random point in Hall3A <gen>)
      • Set Hallways[6] = (Random point in Hall3B <gen>)
      • Set Hallways[7] = (Random point in Hall4A <gen>)
      • Set Hallways[8] = (Random point in Hall4B <gen>)
      • Set Hallways[9] = (Random point in Hall5 <gen>)
      • Set Hallways[10] = (Random point in Hall6 <gen>)
      • Set Hallways[11] = (Random point in Hall7A <gen>)
      • Set Hallways[12] = (Random point in Hall7B <gen>)
      • Set Hallways[13] = (Random point in Hall8 <gen>)
      • Set Hallways[14] = (Random point in Hall9A <gen>)
      • Set Hallways[15] = (Random point in Hall9B <gen>)
      • Set Hallways[16] = (Random point in Hall9C <gen>)
      • Set Hallways[17] = (Random point in Hall9D <gen>)
      • Set Hallways[18] = (Random point in HallEco <gen>)
      • Set Hallways[19] = (Random point in HallMainA <gen>)
      • Set Hallways[20] = (Random point in HallMainB <gen>)
      • Set Hallways[21] = (Random point in HallMainC <gen>)
      • Set Hallways[22] = (Random point in HallMainD <gen>)
      • Set Hallways[23] = (Random point in HallMainE <gen>)
      • Set Hallways[24] = (Random point in HallMainF <gen>)
      • ...(unrelated trigger mass)...
      • -------- Detrun --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Set Enemy_Type[1] = Dethnor (Detrun) (Grunt)
          • Trigger - Turn on Detruns <gen>
          • Trigger - Run Detruns <gen> (ignoring conditions)
        • Else - Actions
  • Detruns (Disabled at start))
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 5 Enemy_Type[1] for Player 5 (Yellow) at Hallways[1] facing Default building facing degrees
      • Unit - Create 35 Enemy_Type[1] for Player 5 (Yellow) at Hallways[2] facing Default building facing degrees
      • Unit - Create 18 Enemy_Type[2] for Player 5 (Yellow) at Hallways[2] facing Default building facing degrees
      • Unit - Create 9 Enemy_Type[3] for Player 5 (Yellow) at Hallways[2] facing Default building facing degrees
      • Unit - Create 10 Enemy_Type[1] for Player 5 (Yellow) at Hallways[3] facing Default building facing degrees
      • Unit - Create 5 Enemy_Type[2] for Player 5 (Yellow) at Hallways[3] facing Default building facing degrees
      • Unit - Create 20 Enemy_Type[1] for Player 5 (Yellow) at Hallways[4] facing Default building facing degrees
      • Unit - Create 10 Enemy_Type[1] for Player 5 (Yellow) at Hallways[5] facing Default building facing degrees
Please note that hallway 2 is how all actions will look when the trigger is done (the number of units spawned is related to the size of the hallway).

As a final note, for those who still don't see the problem: All the 5 units, who are set to spawn in Hallway[1], will spawn at the same point which will change every time the trigger is run. I want it so that those 5 units will spawn in their own random points in Hallway[1] without creating a leak (I know how to do it with right now, but it will create a leak that I have not found a fix for).

Please take into consideration that I will be doing this ~90 times, so if you know a shortcut without creating/keeping a leak, let me know.
 
Last edited:
Level 10
Joined
May 20, 2008
Messages
433
Enemy_Type. Did you ever set that as a unit? Else it dosen't work??

At the end of Trigger A:
  • Game Startup
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • Game - Turn the day/night cycle Off
      • Game - Set the time of day to 24.00
      • -------- Variables --------
      • Set RRed_Controls = Red Controls <gen>
      • Set RYellow_Controls = Yellow Controls <gen>
      • Set RGreen_Controls = Green Controls <gen>
      • Set RBlue_Controls = Blue Controls <gen>
      • Set Objective_RNum1 = (Random integer number between 1 and 1)
      • Set Hallways[1] = (Random point in Hall1A <gen>)
      • Set Hallways[2] = (Random point in Hall1B <gen>)
      • Set Hallways[3] = (Random point in Hall2A <gen>)
      • Set Hallways[4] = (Random point in Hall2B <gen>)
      • Set Hallways[5] = (Random point in Hall3A <gen>)
      • Set Hallways[6] = (Random point in Hall3B <gen>)
      • Set Hallways[7] = (Random point in Hall4A <gen>)
      • Set Hallways[8] = (Random point in Hall4B <gen>)
      • Set Hallways[9] = (Random point in Hall5 <gen>)
      • Set Hallways[10] = (Random point in Hall6 <gen>)
      • Set Hallways[11] = (Random point in Hall7A <gen>)
      • Set Hallways[12] = (Random point in Hall7B <gen>)
      • Set Hallways[13] = (Random point in Hall8 <gen>)
      • Set Hallways[14] = (Random point in Hall9A <gen>)
      • Set Hallways[15] = (Random point in Hall9B <gen>)
      • Set Hallways[16] = (Random point in Hall9C <gen>)
      • Set Hallways[17] = (Random point in Hall9D <gen>)
      • Set Hallways[18] = (Random point in HallEco <gen>)
      • Set Hallways[19] = (Random point in HallMainA <gen>)
      • Set Hallways[20] = (Random point in HallMainB <gen>)
      • Set Hallways[21] = (Random point in HallMainC <gen>)
      • Set Hallways[22] = (Random point in HallMainD <gen>)
      • Set Hallways[23] = (Random point in HallMainE <gen>)
      • Set Hallways[24] = (Random point in HallMainF <gen>)
      • ...(large mass of unrelated triggers)...
      • -------- Detrun --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
        • Then - Actions
          • Set Enemy_Type[1] = Dethnor (Detrun) (Grunt)
          • Trigger - Turn on Detruns <gen>
          • Trigger - Run Detruns <gen> (ignoring conditions)
        • Else - Actions
No enemy type 2 or 3 yet though. The Detruns trigger is Trigger B. Will edit it in 1st post.
 
Level 13
Joined
Feb 18, 2009
Messages
1,381
aah, well ok :) It does not seem to leek, but i am not sure. Maybe remove all locations, because you create them again every 10 seconds, so basically, you would get millions of random points within minutes?
 
Level 10
Joined
May 20, 2008
Messages
433
aah, well ok :) It does not seem to leek, but i am not sure. Maybe remove all locations, because you create them again every 10 seconds, so basically, you would get millions of random points within minutes?

Thats why the trigger gets turned off.
Its not the leaks or trigger that's the problem, its the location. I would use (spawn at (random point in region)) but that would create a leak. Do it 90 or so times and it comes out to 90 or so leaks.
 
You can do this to avoid the leak:
  • Set Hallway[1] = (Random point in Region)
  • Set Hallway[2] = (Random point in Region2)
  • Set Hallway[3] = ...
  • ...
  • Set Hallway[30] = (Random point in Region30)
  • For each (IntegerA) from 1 to 30, do (Actions)
    • Loop - Actions
      • Set X[(IntegerA)] = (X of Hallway[(IntegerA)])
      • Set Y[(IntegerA)] = (Y of Hallway[(IntegerA)])
      • Custom script: call RemoveLocation (udg_Hallway[GetForLoopIndexA()]
X & Y are real variables. The custom script will remove instantly the leak of all those set points. Setting the points with X and Y will let you remake the point you referred to, with no leak stored.
Here is how to recall the point:
  • For each (IntegerB) from 1 to 30, do (Actions)
    • Loop - Actions
      • Set Hallway[(IntegerB)] = (X[(IntegerB)], Y[(IntegerB)])
      • Unit - Create 1 Unit for Neutral Passive at Hallway[(IntegerB)]
      • Custom script: call RemoveLocation (udg_Hallway[GetForLoopIndexB()])
Hallway[] is done through Conversion - Convert Coordinates to Point.
 
Status
Not open for further replies.
Top