Random Start Zone Vacancy

Uszi

New Member
Reaction score
5
Hey guys.

I want my players to spawn in 1 of 9 zones randomly. However, since there are 6 players and 9 zones, and they all spawn at the same time, the odds of 2 or more players spawning together in the same region is pretty easy.

I want to prevent this. I'm trying to design a trigger that would check whether a zone is vacant or not before spawning the unit there.

Right now I have:

Code:
Spawn Players
    Events
    Conditions
    Actions
        Player Group - Pick every player in (All players) and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        ((Picked player) slot status) Equal to Is playing
                        ((Picked player) controller) Equal to User
                    Then - Actions
                        Unit - Create 1 Unit for (Picked player) at (Center of GameStartSpawnZone[(Random integer number between 1 and 9)]) facing Default building facing degrees
                        Camera - Pan camera for (Picked player) to (Position of (Last created unit)) over 0.00 seconds
                    Else - Actions
                        Do nothing

All of the methods I have tried so far wind up being too complicated, or having some sort of bug somewhere that I couldn't find.

This is the unaltered, first version of my spawn trigger: where should I go from here?

Thanks for the help!
 

jig7c

Stop reading me...-statement
Reaction score
123
you could use variables...

set Zone[1] = region 1
set Zone[2] = region 2
so on

and then check when a unit enters Zone[1,2,3,4,5,6,7,8,9]

set ZoneCheck[1] = true (boolean variable)

and then add ZoneCheck to your original trigger above...

if you need more help let me know....
 

the_ideal

user title
Reaction score
61
Create a region variable array with size 9 called "Start Regions." At map initialization, set Start Regions[1] to the one region, Start Regions[2] equal to the next, until you've set each variable in the array to a separate region.
Trigger:
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Start_Regions[1] = (Region1)
      • Set Start_Regions[2] = (Region2)

I'll work out the rest and post it in a second.

edit: oh, the guy above you has the right idea. Post if you need more help.
 

Uszi

New Member
Reaction score
5
"Create 1 Unit for (Picked player) at (Center of GameStartSpawnZone[(Random integer number between 1 and 9)]) "

I've got that much worked out.

Right now I'm trying to see if there's away to remove the region that was selected randomly from the array...

Maybe go player by player for the spawning...
Pick a random player from player group
Create one unit for picked player at starzone[random 1 to 9]
Remove player from player group
Remove the zone from startzone
loop

That was my current attempt. Problem is there doesn't seem to be a RegionGroup like a Playergroup or a Unitgroup, so that idea kinda fell on its face...

you could use variables...

set Zone[1] = region 1
set Zone[2] = region 2
so on

and then check when a unit enters Zone[1,2,3,4,5,6,7,8,9]

set ZoneCheck[1] = true (boolean variable)

and then add ZoneCheck to your original trigger above...

if you need more help let me know....

Yeah... Please elaborate?
How can I use the check to not pick the region in my randomizing trigger?

I'm thinking now I need to change my randomizing system.
Create 1 Unit for (Picked player) at (Center of GameStartSpawnZone[(Random integer number between 1 and 9)])
--doesn't seem like it lends itself easily to regulation.


So yeah... I need more help. :(
 

Uszi

New Member
Reaction score
5
I'm trying to work out that system posted...

Do I need a seperate trigger for each region?

Code:
Spawn Players II
    Events
        Unit - A unit enters Survivor Start Spawn 01 <gen>
    Conditions
        (Unit-type of (Triggering unit)) Equal to Survival Novice
    Actions
        Set ZoneCheck[1] = True

Like that?

And then how do I use zonecheck to keep units from spawning if I'm using random integer 1-9 and a region array to spawn them?
 

jig7c

Stop reading me...-statement
Reaction score
123
Trigger:
  • Map Init
    • Events
      • Map Initialization
    • Conditions
    • Actions
      • Set Region[1] = Survivor Start Spawn 01 &lt;gen&gt;
      • Set Region[2] = Survivor Start Spawn 02 &lt;gen&gt;
      • Set Region[3] = Survivor Start Spawn 03 &lt;gen&gt;
      • Set Region[4] = Survivor Start Spawn 04 &lt;gen&gt;
      • Set Region[5] = Survivor Start Spawn 05 &lt;gen&gt;
      • Set Region[6] = Survivor Start Spawn 06 &lt;gen&gt;
      • Set Region[7] = Survivor Start Spawn 07 &lt;gen&gt;
      • Set Region[8] = Survivor Start Spawn 08 &lt;gen&gt;
      • Set Region[9] = Survivor Start Spawn 09 &lt;gen&gt;


Trigger:
  • Spawn Players II
    • Events
      • Unit - A unit enters a region
    • Conditions
      • (Unit-type of (Entering Unit)) Equal to Survival Novice
    • Actions
      • For each integer A from 1 to 9 do actions
        • Set ZoneCheck[A] = True


Trigger:
  • Spawn Players
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
              • ((Picked player) controller) Equal to User
              • ZoneCheck[?] equal to True <b>not sure?</b>
            • Then - Actions
              • Set Integer = ZoneCheck(Random integer between 1 and 9) <b>not sure?</b>
              • Unit - Create 1 Unit for (Picked player) at (Center of Region[(Integer)]) facing Default building facing degrees
              • Set Point = Position of (Last Created Unit)
              • Camera - Pan camera for (Picked player) to (Position of (Point)) over 0.01 seconds
              • call RemoveLocation (udg_Point)
            • Else - Actions
              • Do nothing


NOT THE EXACT TRIGGERS, MATTER OF FACT THIS TRIGGER HAS ERRORS IN THEM, THIS IS ONLY TO GUIDE YOU IN THE RIGHT DIRECTION.

I don't have WE on this comp so I can't make the exact triggers...
 

Uszi

New Member
Reaction score
5
"Unit - A unit enters a region"

Is that a generic unit event?

Also:
"Set Integer = (Random integer between 1 and 9)
Unit - Create 1 Unit for (Picked player) at (Center of Region[(Integer)])"

is integer a region or an integer?
Is it a the region array you set up earlier?
 

jig7c

Stop reading me...-statement
Reaction score
123
"Unit - A unit enters a region"

Is that a generic unit event?

yes

Also:
"Set Integer = (Random integer between 1 and 9)
Unit - Create 1 Unit for (Picked player) at (Center of Region[(Integer)])"

is integer a region or an integer? Integer
Is it a the region array you set up earlier? an array set up in map init trigger
 

Emu.Man00

New Member
Reaction score
41
But that will only run once, if the boolean is true (i.e. region is used alrady) the unfortunate player that got that random region will not have any units.
 

jig7c

Stop reading me...-statement
Reaction score
123
help fix the trigger... read my above note in bold
if the zone check is true, (boolean) then it'll spawn the unit... only once... i think that's what he wants...

if he only had 6 players in game, with 6 regions.. the triggers would be so much simple
 

Uszi

New Member
Reaction score
5
Trigger:
  • <b><u>NOT THE EXACT TRIGGERS, MATTER OF FACT THIS TRIGGER HAS ERRORS IN THEM, THIS IS ONLY TO GUIDE YOU IN THE RIGHT DIRECTION.</u></b>
    • I don&#039;t have WE on this comp so I can&#039;t make the exact triggers...
Trigger:
  • Alright, alright.
    • ---------------------------------------
    • &quot;Unit - A unit enters a region&quot; is not a generic event, so far as I can see. Closest is &quot;Unit - A unit enters region ____&quot; for which I supply the region. This would still work, I suppose, if I do 9 separate 1 region triggers.
    • I want the unit to spawn once, but that shouldn&#039;t be a problem--if I only create 1 unit per player, and I only run the trigger once, then there shouldn&#039;t be any issues with people getting more than one unit.
    • <u>What I really want is to avoid having 2 units spawn in one location</u>. So far as I can see, having only 6 regions for 6 players wouldn&#039;t fix this. If I still pick a random region from the array, 1-6, then I face the exact same issues and limitations than if I picked 1-9. In fact, the problem becomes simpler as I add regions: if I was picking 1-500, then the odds of people spawing together are very low.
    • I mean, the only reason I have 9 is for aesthetic reasons. 9 is the maximum number I could use for my purposes. If I need to duck and run, I could just have player 1 spawn here, and 6 there, each player having their own spawn zone. Problem is that if one location sucks and one is better, than your in-game fate is determined by how soon you joined the game.
    • Thanks for your help, though. And sorry if I annoyed you.
 

the_ideal

user title
Reaction score
61
I just thought of an easier way. Create a footman (or any unit) at the center of each location. Then, for every integer from 1 to 6, pick a random unit, kill it, and create starting units at its location.
Then remove all footmen from the map.
 

jig7c

Stop reading me...-statement
Reaction score
123
who makes it so or when does the spawning in the regions occur...

after certain time?
when a player types in a command?
you tell me that and I can most likely fix the trigger!
 

jig7c

Stop reading me...-statement
Reaction score
123
u didn't annoy me, and what you want can be done...

what you are thinking is that if 1 - 500 regions are in your map, then the chances are 1/500 a unit will spawn twice in one region, but if there are only 6 regions, then you can set each region with each player when the units are about to spawn so only one unit will spawn in one region... randomly if you like...

sorry for double post, didn't realize it til now!
 

Uszi

New Member
Reaction score
5
who makes it so or when does the spawning in the regions occur...

after certain time?
when a player types in a command?
you tell me that and I can most likely fix the trigger!

Here, I guesss it would help to put everything. Well, everything relevant:

Trigger:
  • game settings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set SpawnZone[1] = Survivor Start Spawn 07 &lt;gen&gt;
      • Set SpawnZone[2] = Survivor Start Spawn 06 &lt;gen&gt;
      • Set SpawnZone[3] = Survivor Start Spawn 05 &lt;gen&gt;
      • Set SpawnZone[4] = Survivor Start Spawn 04 &lt;gen&gt;
      • Set SpawnZone[5] = Survivor Start Spawn 03 &lt;gen&gt;
      • Set SpawnZone[6] = Survivor Start Spawn 08 &lt;gen&gt;
      • Set SpawnZone[7] = Survivor Start Spawn 02 &lt;gen&gt;
      • Set SpawnZone[8] = Survivor Start Spawn 01 &lt;gen&gt;
      • Set SpawnZone[9] = Survivor Start Spawn 09 &lt;gen&gt;

Minus other stuff, like time of day, etc.

Trigger:
  • Start
    • Events
      • Time - Elapsed game time is 1.50 seconds
    • Conditions
    • Actions
      • Dialog - Change the title of GameDiffDial to Choose the Game Mod...
      • Dialog - Create a dialog button for GameDiffDial labelled Easy Mode
      • Set DiffDialButt[1] = (Last created dialog Button)
      • Dialog - Create a dialog button for GameDiffDial labelled Normal Mode
      • Set DiffDialButt[2] = (Last created dialog Button)
      • Dialog - Create a dialog button for GameDiffDial labelled Hard Mode
      • Set DiffDialButt[3] = (Last created dialog Button)
      • Dialog - Create a dialog button for GameDiffDial labelled Insane Mode
      • Set DiffDialButt[4] = (Last created dialog Button)
      • Dialog - Show GameDiffDial for Player 1 (Red)

A dialogue to choose game difficulty...

Trigger:
  • Pick Difficulty
    • Events
      • Dialog - A dialog button is clicked for GameDiffDial
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to DiffDialButt[1]
        • Then - Actions
          • Set GameDifficulty = 0
          • Player Group - Pick every player in (All players) and do (Hero - Make Player 1 (Red) Heroes gain 80.00% experience from future kills)
          • Cinematic - Clear the screen of text messages for (All players)
          • Game - Display to (All players) for 5.00 seconds the text: |cff32cd32The host ...
          • Sound - Play EasyMode &lt;gen&gt;
          • Dialog - Clear GameDiffDial
          • Dialog - Hide GameDiffDial for Player 1 (Red)
        • Else - Actions
          • Do nothing
      • [blah blah blah]
        • Trigger - Run Spawn Players &lt;gen&gt; (checking conditions)

Trigger:
  • Spawn Players
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
              • ((Picked player) controller) Equal to User
            • Then - Actions
              • Set Variable = (Random integer number between 1 and 9)
              • Unit - Create 1 Survival Novice for (Picked player) at (Center of Integer0) facing Default building facing degrees
              • Hero - Modify unspent skill points of (Last created unit): Add 2 points
              • Camera - Pan camera for (Picked player) to (Position of (Last created unit)) over 0.00 seconds
            • Else - Actions
              • Do nothing

So basically, start map --> difficulty dialog --> spawn players. After that, I could turn the trigger off.

There are a few work arounds within my skill level:
1). Have a big area and randomly spawn everyone using Random Point in Region. This seems like it would be hugely unfair to some people though.
2). Spawn everyone in the same region.

So yeah.

I just thought of an easier way. Create a footman (or any unit) at the center of each location. Then, for every integer from 1 to 6, pick a random unit, kill it, and create starting units at its location.
Then remove all footmen from the map.


I should try it... I guess, what I'm having trouble with, is how to keep track of which regions have footmen, which regions have footmen who have been killed, etc. And again, if randomly pick each region, kill a random unit, then couldn't we potentially kill a player character?

I guess I should try it first... But every system seems to have the same problem: the propensity to double pick one of the "random regions." I'm looking for a way that removes a region from a the list of potential regions once it's filled with a player's spawned unit.

EDIT: sorry, tried to put spoiler tags on the code, so you could choose to look at it or not, but I guess I did it wrong.
 

jig7c

Stop reading me...-statement
Reaction score
123
Here, I guesss it would help to put everything. Well, everything relevant:

Trigger:
  • game settings
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set SpawnZone[1] = Survivor Start Spawn 07 &lt;gen&gt;
      • Set SpawnZone[2] = Survivor Start Spawn 06 &lt;gen&gt;
      • Set SpawnZone[3] = Survivor Start Spawn 05 &lt;gen&gt;
      • Set SpawnZone[4] = Survivor Start Spawn 04 &lt;gen&gt;
      • Set SpawnZone[5] = Survivor Start Spawn 03 &lt;gen&gt;
      • Set SpawnZone[6] = Survivor Start Spawn 08 &lt;gen&gt;
      • Set SpawnZone[7] = Survivor Start Spawn 02 &lt;gen&gt;
      • Set SpawnZone[8] = Survivor Start Spawn 01 &lt;gen&gt;
      • Set SpawnZone[9] = Survivor Start Spawn 09 &lt;gen&gt;


why not set each region with the correct number? or is it because the way regions are layed out in your map....


Trigger:
  • Pick Difficulty
    • Events
      • Dialog - A dialog button is clicked for GameDiffDial
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Clicked dialog button) Equal to DiffDialButt[1]
        • Then - Actions
          • Set GameDifficulty = 0
          • Player Group - Pick every player in (All players) and do (Hero - Make Player 1 (Red) Heroes gain 80.00% experience from future kills)
          • Cinematic - Clear the screen of text messages for (All players)
          • Game - Display to (All players) for 5.00 seconds the text: |cff32cd32The host ...
          • Sound - Play EasyMode &lt;gen&gt;
          • Dialog - Clear GameDiffDial
          • Dialog - Hide GameDiffDial for Player 1 (Red)
        • Else - Actions
          • Do nothing
      • [blah blah blah]
        • Trigger - Run Spawn Players &lt;gen&gt; (checking conditions)

Trigger:
  • Spawn Players
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) slot status) Equal to Is playing
              • ((Picked player) controller) Equal to User
            • Then - Actions
              • Set Variable = (Random integer number between 1 and 9)
              • Unit - Create 1 Survival Novice for (Picked player) at (Center of Integer0) facing Default building facing degrees
              • Hero - Modify unspent skill points of (Last created unit): Add 2 points
              • Camera - Pan camera for (Picked player) to (Position of (Last created unit)) over 0.00 seconds
            • Else - Actions
              • Do nothing

So basically, start map --> difficulty dialog --> spawn players. After that, I could turn the trigger off.

There are a few work arounds within my skill level:
1). Have a big area and randomly spawn everyone using Random Point in Region. This seems like it would be hugely unfair to some people though.
2). Spawn everyone in the same region.

So yeah.


what is the blah blah blah stuff in the second trigger... that's the key man...
what is (Center of Integer0)
 

Uszi

New Member
Reaction score
5
Blahblah is the same thing repeated, 3 more times for the 3 remaining difficulty options: Different difficulty settings, it's not related at all to whats going on.

Here it is anyway if you're curious:

Trigger:
  • * If - Conditions
    • o (Clicked dialog button) Equal to DiffDialButt[2]
    • * Then - Actions
      • o Set GameDifficulty = 1
      • o Player Group - Pick every player in (All players) and do (Hero - Make Player 1 (Red) Heroes gain 100.00% experience from future kills)
      • o Cinematic - Clear the screen of text messages for (All players)
      • o Game - Display to (All players) for 5.00 seconds the text: |cff32cd32The host ...
      • o Sound - Play NormalMode &lt;gen&gt;
      • o Dialog - Clear GameDiffDial
      • o Dialog - Hide GameDiffDial for Player 1 (Red)
    • * Else - Actions
      • o Do nothing


Change to Hard mode, rinse repeat.
Change to Insane Mode, rinse repeat.

As far as the array and the regions, I just set them up with how they were oriented in the map. It might be a little confusing, but I'm not sure how much difference it would make.

I started working with the killing footmen idea. But to be honest, I'm going to hit the sack and address the issue in my free time tommorrow.

er, I should point out that I haven't run any sort of trigger yet: so there isn't yet any need to debug anything. I just knew as I was writing the original version, that it was entirely possible for two players to spawn on top of each other.
 

the_ideal

user title
Reaction score
61
I just thought of an easier way. Create a footman (or any unit) at the center of each location. Then, for every integer from 1 to 6 (or copy paste the trigger 6 times), pick a random unit (of type footman), kill (last created unit), and create starting units at its location.
Then remove all footmen from the map.

This makes it a lot easier.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
Easiest/most efficient way is just to loop through players, and give them a random region, and removing the region from the list of available regions:

Trigger:
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Places[1] = Region 000 &lt;gen&gt;
      • Set Places[2] = Region 000 Copy &lt;gen&gt;
      • Set Places[3] = Region 000 Copy 2 &lt;gen&gt;
      • Set Places[4] = Region 000 Copy 3 &lt;gen&gt;
      • Set Places[5] = Region 000 Copy 4 &lt;gen&gt;
      • Set Places[6] = Region 000 Copy 5 &lt;gen&gt;
      • Set Places[7] = Region 000 Copy 6 &lt;gen&gt;
      • Set Places[8] = Region 000 Copy 7 &lt;gen&gt;
      • Set Places[9] = Region 000 Copy 8 &lt;gen&gt;


Trigger:
  • Start Players
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in Players and do (Actions)
        • Loop - Actions
          • Set tempInt = (Random integer number between 1 and availableRegionCount)
          • Set PlayersStartRegions[(Player number of (Picked player))] = Places[tempInt]
          • Set Places[tempInt] = Places[availableRegionCount]
          • Set availableRegionCount = (availableRegionCount - 1)
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for (Player((Integer A))) at (Center of PlayersStartRegions[(Integer A)]) facing Default building facing degrees
 

Uszi

New Member
Reaction score
5
That looks pretty good!
I'll let you know if it works... but I'll need more than one person to test it.

I have another question, and this is totally theoretical at this point: If it wasn't a one time spawn, but say every time a unit respawned after dying it would go to one of the random locations, how would you change the trigger?

Seems like you could no longer remove the regions as being available. Or maybe you could just add the region back after X amount of time.
 
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