• 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.

Random spawn in random region

Status
Not open for further replies.
Level 4
Joined
Apr 16, 2012
Messages
83
Basically I have 6 players, all allies. I want each player to have 1 unit created for them in 1 out of 6 regions, but I want them spawned at a random one out of these 6. I don't want any units spawned in the same region as each other. How would I go about doing this?
 
Level 13
Joined
Jun 3, 2011
Messages
1,058
  • Event
  • Condition
  • Action
    • Unit - Create 1 Footman for Player 1(Red) (Random point in (Spawning Region)) facing Default building facing
 
Level 11
Joined
May 8, 2009
Messages
275
You can do something like this.
Set your regions to variables and choose the amount of "possible configuration" you want. Let's say 5: ask he trigger to choose a random number between 1 and 5. For each number possible, you set where which hero shall spawn.
Here's a demonstration.
  • Spawn
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Set Region[1] = Your Region 1
      • Set Region[2] = Your Region 2
      • Set Region[3] = Your Region 3
      • Set Region[4] = Your Region 4
      • Set Region[5] = Your Region 5
      • Set Region[6] = Your Region 6
      • Set Random_Number = (Random integer number between 1 and 5
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random_Number Equal to 1
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Set Point = (Random point in Region[(Integer A)])
              • Unit - Create 1 Hero for (Player((Integer A))) at Point facing Default building facing degrees
              • Custom script: call RemoveLocation (udg_Point)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random_Number Equal to 2
        • Then - Actions
          • Set Point = (Random point in Region[6])
          • Unit - Create 1 Hero for Player 1 (Red) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[5])
          • Unit - Create 1 Hero for Player 2 (Blue) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[4])
          • Unit - Create 1 Hero for Player 3 (Teal) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[3])
          • Unit - Create 1 Hero for Player 4 (Purple) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[2])
          • Unit - Create 1 Hero for Player 5 (Yellow) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[1])
          • Unit - Create 1 Hero for Player 6 (Orange) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Random_Number Equal to 3
        • Then - Actions
          • Set Point = (Random point in Region[2])
          • Unit - Create 1 Hero for Player 1 (Red) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[1])
          • Unit - Create 1 Hero for Player 2 (Blue) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[4])
          • Unit - Create 1 Hero for Player 3 (Teal) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[3])
          • Unit - Create 1 Hero for Player 4 (Purple) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[6])
          • Unit - Create 1 Hero for Player 5 (Yellow) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
          • Set Point = (Random point in Region[5])
          • Unit - Create 1 Hero for Player 6 (Orange) at Point facing Default building facing degrees
          • Custom script: call RemoveLocation (udg_Point)
        • Else - Actions
          • and so on....
in the trigger above, if the integer is randomly set to 1, red's 1 hero will spawn in region 1, blue's hero in region 2 and so on... If the integer is 2, another configuration... and you can make like that as many as you want. More possibilities you have, more it will be unpredicatable.
 
Status
Not open for further replies.
Top