Spawning at a random point in a random region?

maldruzard

Member
Reaction score
2
As the title suggests, I am trying to trigger in spawning units at a random point in a random region (out of a selection of regions, not all of mine would be appropriate). This would be wonderful if it were possible, as I really need random spawn points. Spawning at a random point in the playable map area doesn't work due to it sometimes spawning in the ocean/inside trees/inside a mountainside.

If there is some way of making this work I would much appreciate it :)
 

Juggernaut

I don't know what to change it to
Reaction score
33
First you should create the regions (via editor).
Then have 2 variables. One integer variable, the other region variable (with X number of arrays)
Where X = the number of regions.
Then at map initialization.
Set Region[1] = first region
Set Region[2] = second region
... And so on.
THEN ON THE OTHER TRIGGER (which would trigger the units spawning) DO.
Trigger:
  • Actions
    • Set Integer = (Random integer number between 1 and 4)
    • ************* Integer is set to a random number between 1 and X, so if Integer is = 2 then unit will spawn in second region and so on *****************************
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Integer Equal to 1
    • Then - Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Random point in Regions[1]) facing Default building facing degrees
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Integer Equal to 2
    • Then - Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Random point in Regions[2]) facing Default building facing degrees
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Integer Equal to 3
    • Then - Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Random point in Regions[3]) facing Default building facing degrees
    • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
    • Integer Equal to 4
    • Then - Actions
    • Unit - Create 1 Footman for Player 1 (Red) at (Random point in Regions[4]) facing Default building facing degrees
    • Else - Actions

I hope you got the general Idea.
 

chukky-jr

Member
Reaction score
15
^just like what above said, simplifying it we got

Trigger:
  • Action
    • set temp_integer = Random number between 1 and 4
    • set temp_point = Random Point in Region[temp_integer]
    • Unit - Create 1 Footman for Player 1 (Red) at (temp_point)
    • custom script : call RemoveLocation(udg_temp_point)


notice that i assign point to a variable called temp_point, since point leaks, we should assign it to a variable and remove it later using
Trigger:
  • custom script : call RemoveLocation(udg_temp_point)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top