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

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 10
Joined
May 8, 2009
Messages
253
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