Random Start Zone Vacancy

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
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?

Try this:

This way it preserves all the regions, and resets the availableRegionCount to 9.

Trigger:
  • Map Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set Places[1] = Region 000 <gen>
      • Set Places[2] = Region 000 Copy <gen>
      • Set Places[3] = Region 000 Copy 2 <gen>
      • Set Places[4] = Region 000 Copy 3 <gen>
      • Set Places[5] = Region 000 Copy 4 <gen>
      • Set Places[6] = Region 000 Copy 5 <gen>
      • Set Places[7] = Region 000 Copy 6 <gen>
      • Set Places[8] = Region 000 Copy 7 <gen>
      • Set Places[9] = Region 000 Copy 8 <gen>
      • Set availableRegionCount = 9
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • Set tempInt = (Random integer number between 1 and availableRegionCount)
          • Set PlayersStartRegions[(Integer A)] = Places[tempInt]
          • Set tempRegion = Places[tempInt]
          • Set Places[tempInt] = Places[availableRegionCount]
          • Set Places[availableRegionCount] = tempRegion
          • Set availableRegionCount = (availableRegionCount - 1)
      • Set availableRegionCount = 9


Trigger:
  • Start Players
    • Events
    • Conditions
    • Actions
      • Set tempInt = (Random integer number between 1 and availableRegionCount)
      • Unit - Create 1 Footman for (Owner of (Dying unit)) at (Center of PlayersStartRegions[tempInt]) facing Default building facing degrees
      • Set tempRegion = Places[tempInt]
      • Set Places[tempInt] = Places[availableRegionCount]
      • Set Places[availableRegionCount] = tempRegion
      • Set availableRegionCount = (availableRegionCount - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • availableRegionCount is equal to 0
        • Then - Actions
          • Set availableRegionCount = 9
        • Else - Actions


This would automatically randomly distribute units to the regions, is this what you wanted?
 

jig7c

Stop reading me...-statement
Reaction score
123
why don't you just make it so that it's like this:

Trigger:
  • Start Players
    • Events
      • Elapsed game time is 5.00 seconds
    • 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


use darthfett's, it looks good

hey darthfett,

shouldn't you set availableRegionCount = 9 in the map init trigger right after you set Place [9] = Region 000 Copy 8 <gen>
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
hey darthfett,

shouldn't you set availableRegionCount = 9 in the map init trigger right after you set Place [9] = Region 000 Copy 8 <gen>

Well I originally said that he should just initialize it to 9, but I changed the code in several edits so that he wouldn't need to bother.
 

A.Dominion

New Member
Reaction score
0
hi i think there is an easier way to solve it

you define the region at first:

region[array] = region (1 for each region)
RegionNumber[array] = integer (1 for each player)
TempNumber = integer
PlayerOk[array] = boolean (1 for each player)

triggers:

Trigger:
  • ini
    • Events
      • Temps - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Set Region[1] = Region 000 &lt;gen&gt;
      • Set Region[2] = Region 001 &lt;gen&gt;
      • Set Region[3] = Region 002 &lt;gen&gt;
      • Set Region[4] = Region 003 &lt;gen&gt;
      • Set Region[5] = Region 004 &lt;gen&gt;
      • Set Region[6] = Region 005 &lt;gen&gt;
      • Set Region[7] = Region 006 &lt;gen&gt;
      • Set Region[8] = Region 007 &lt;gen&gt;
      • Set Region[9] = Region 008 &lt;gen&gt;


Trigger:
  • Check Player
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Boucle - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • ((Player((Integer A))) slot status) Egal to_ Joue
              • ((Player((Integer A))) controller) Egal to_ Utilisateur
            • Alors - Actions
              • Set PlayerOK[(Integer A)] = TRUE
            • Sinon - Actions
      • Wait 1.00 seconds
      • Trigger - Run player 1 &lt;gen&gt; (checking conditions)


Trigger:
  • player 1
    • Events
    • Conditions
    • Actions
      • Set TempNumber = (Random integer number between 1 and 9)
      • Set RegionNumber[1] = TempNumber
      • Trigger - Run player 2 &lt;gen&gt; (checking conditions)


Trigger:
  • player 2
    • Events
    • Conditions
    • Actions
      • Set TempNumber = (Random integer number between 1 and 9)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • TempNumber Egal to_ RegionNumber[1]
        • Alors - Actions
          • Triggerr - Run (This trigger) (checking conditions)
        • Sinon - Actions
          • Set RegionNumber[2] = TempNumber
          • Trigger - Run player 3 &lt;gen&gt; (checking conditions)


Trigger:
  • player 3
    • Events
    • Conditions
    • Actions
      • Set TempNumber = (Random integer number between 1 and 9)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • TempNumber Egal to_ RegionNumber[1]
              • TempNumber Egal to_ RegionNumber[2]
        • Alors - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Sinon - Actions
          • Set RegionNumber[3] = TempNumber
          • Trigger - Run player 4 &lt;gen&gt; (checking conditions)


Trigger:
  • player 4
    • Events
    • Conditions
    • Actions
      • Set TempNumber = (Random integer number between 1 and 9)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • TempNumber Egal to_ RegionNumber[1]
              • TempNumber Egal to_ RegionNumber[2]
              • TempNumber Egal to_ RegionNumber[3]
        • Alors - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Sinon - Actions
          • Set RegionNumber[4] = TempNumber
          • Trigger - Run player 5 &lt;gen&gt; (checking conditions)


Trigger:
  • player 5
    • Events
    • Conditions
    • Actions
      • Set TempNumber = (Random integer number between 1 and 9)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • TempNumber Egal to_ RegionNumber[1]
              • TempNumber Egal to_ RegionNumber[2]
              • TempNumber Egal to_ RegionNumber[3]
              • TempNumber Egal to_ RegionNumber[4]
        • Alors - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Sinon - Actions
          • Set RegionNumber[5] = TempNumber
          • Trigger - Run player 6 &lt;gen&gt; (checking conditions)


Trigger:
  • player 6
    • Events
    • Conditions
    • Actions
      • Set TempNumber = (Random integer number between 1 and 9)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • Si - Conditions
          • Or - Any (Conditions) are true
            • Conditions
              • TempNumber Egal to_ RegionNumber[1]
              • TempNumber Egal to_ RegionNumber[2]
              • TempNumber Egal to_ RegionNumber[3]
              • TempNumber Egal to_ RegionNumber[4]
              • TempNumber Egal to_ RegionNumber[5]
        • Alors - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Sinon - Actions
          • Set RegionNumber[6] = TempNumber
          • Trigger - Run Create Units &lt;gen&gt; (checking conditions)


Trigger:
  • Create Units
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Boucle - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • Si - Conditions
              • PlayerOK[(Integer A)] Egal to_ TRUE
            • Alors - Actions
              • Units - Create 1 Fantassin for (Player((Integer A))) at (Center of Region[RegionNumber[(Integer A)]]) facing Orientation building par default degrees
            • Sinon - Actions


ok so this was the long way, the easier way is just to use a dummy unit at each location, to add all dummy to region (unitgroup) and then region unit from unit group when a unit is created at position of dummy. (if not clear i can trigger it for you)
 

A.Dominion

New Member
Reaction score
0
Try this:

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;
      • Set availableRegionCount = 9
      • For each (Integer A) from 1 to 9, do (Actions)
        • Loop - Actions
          • Set tempInt = (Random integer number between 1 and availableRegionCount)
          • Set PlayersStartRegions[(Integer A)] = Places[tempInt]
          • Set tempRegion = Places[tempInt]
          • Set Places[tempInt] = Places[availableRegionCount]
          • Set Places[availableRegionCount] = tempRegion
          • Set availableRegionCount = (availableRegionCount - 1)
      • Set availableRegionCount = 9

There is a fatal flaw in you system :( , you never check if region or number is allready given, you only randomly distrube random number.
here is an example:
first loop random number = 7
Trigger:
  • Set PlayersStartRegions[1] = Places[7]
    • Set tempRegion = Places[7]
    • Set Places[7] = Places[9]
    • Set Places[9] = tempRegion
    • Set availableRegionCount = (availableRegionCount - 1)

TempRegion = Place [7] so you set that Place [9] = Place [7] ok
now what happen if the next or any next number is also 7

here it come loop 2
Trigger:
  • Set PlayersStartRegions[2] = Places[7]
    • Set tempRegion = Places[7]
    • Set Places[7] = Places[8]
    • Set Places[8] = tempRegion
    • Set availableRegionCount = (availableRegionCount - 1)

TempRegion = Place [7] so you set that Place [8] = Place [7]

so any time the random integer will fire twice a number, your trigger will bug and have a chance to give the same location for 2 players.
PS: with 7 you have only 3 chance out of 9 to fire it more than once, but if the number is 1 then you have 9 chance to fire it more than once.
 

Darthfett

Aerospace/Cybersecurity Software Engineer
Reaction score
615
There is a fatal flaw in you system :( , you never check if region or number is allready given, you only randomly distrube random number.

There is no flaw in the system except that the regions do not retain the original order. There is no need to check if a region or number is already given, because the system moves the regions around so that they are out of bounds for the next array-pick.

Read on for more explanation.

Lets say we have Places[1-9] set to Region 1 <gen>, Region 2 <gen>, Region 3 <gen>, etc.

first loop random number = 7

Trigger:
  • Set PlayersStartRegions[1] = Places[7] //Player 1&#039;s start location set to Region 7 &lt;gen&gt;
    • Set tempRegion = Places[7]
    • Set Places[7] = Places[9]
    • Set Places[9] = tempRegion
    • Set availableRegionCount = (availableRegionCount - 1)


after this:
PlayersStartRegions[1] = Region 7 <gen>
Places[1] = Region 1 <gen>
Places[2] = Region 2 <gen>
...
Places[7] = Region 9 <gen>
Places[8] = Region 8 <gen>
Places[9] = Region 7 <gen>
availableRegionCount = 8

Now if we do this again, it would pick a random number between 1 and 8.

If it picks 7 again, it would be referring to Region 9 <gen>. It can not pick Places[9] or Region 7 <gen> again because it can only pick a number between 1 and availableRegionCount, which is now 8.

The only flaw with this system is that it doesn't preserve the order of the Regions (and possibly readability as well, if you don't already understand the code).
 

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.
Is there anything wrong with this? Make the footman have no model so you can't see it and this is perfect. (oh and you might need to add Boolean - (mathing unit) is alive equal to (true), but that's easy)
 

Uszi

New Member
Reaction score
5
First of all, sorry to bump an ancient thread.

Second of all, seriously, lots of thanks everyone: I was having trouble with options coming up twice in random systems in general, so just figuring out ways to eliminate options from the random pool has helped me a lot. I have a very scatter brained approach to map making, so I have three maps that all have some sort of randomized starting zone game mechanic, and this system has helpful implications for all of them.

Finally, and most importantly, I did run across a bug.

When I test the map with one player, It randomly starts me in a spot, which is good.

But it also creates one unit for me for each of the players not playing in the center of the map. They all retain their original colors.

I tried a couple of fixes before I found one that worked.

It seems like the decision to spawn units was made independently of the decision to give them a random region. This means that unused players received no region, and their units just spawn in the center of the playable map area.

The fix was to just make a slot status check before running the spawn:

Trigger:
  • Spawn Players
    • Events
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set tempINT = (Random integer number between 1 and AvRegCount)
          • Set PlayerStartZone[(Player number of (Picked player))] = SpawnZone[tempINT]
          • Set SpawnZone[tempINT] = SpawnZone[AvRegCount]
          • Set AvRegCount = (AvRegCount - 1)
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) slot status) Equal to Is playing
            • Then - Actions
              • Unit - Create 1 Survival Novice for (Player((Integer A))) at (Center of PlayerStartZone[(Integer A)]) facing Default building facing degrees
                • Else - Actions
              • Do nothing


I think that wrapped it up pretty nicely, but this seems to work now if people are searching for a system like this.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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