Random Spawns but no repeats?

thevoden

New Member
Reaction score
5
I have a random area of "regions" that is 14 big. In the beginning, a player randomly spawns in one of these locations.

How do I make it so that different players won't spawn in the same region?

So lets Player 1 randomly spawns his base on Region 3. I don't want Player 2 to spawn (randomly) on Region 3.
 
T

Tubba

Guest
Use an array to store the regions, and remove the array spawned?
 

thevoden

New Member
Reaction score
5
I know that.

But lets say a trigger says "math, variable number from 1 through 14" , theres nothing from stopping it from landing at 6 twice. Otherwise, how do you remove the array spawned?

Thanks!
 
T

Tubba

Guest
Hmm... Set the random number to a variable, and use another variable to define the max, which you decrease by one each time you generate a random number. Then do a check to check how large the random number is (Is greater than, is less than, etc) and decrease all array regions above it by one? So that if the random region is 7, region 8 becomes 7, 9 becomes 8, etc.
 
T

Tubba

Guest
Code:
SpawnRegs
    Events
    Conditions
    Actions
        Set CheckRandom = (CheckRandom - 1)
        Set ArrayNoRepeat = (Random integer number between 0 and CheckRandom)
        --------------Here you spawn your hero in SetRegion[ArrayNoRepeat]-------------
        For each (Integer A) from ArrayNoRepeat to CheckRandom, do (Actions)
            Loop - Actions
                Set SetRegion[(Integer A)] = SetRegion[((Integer A) - 1)]
Something like this?
 

thevoden

New Member
Reaction score
5
kinda. i can't get that trigger to work though.

So far I have this. I can spawn randomly in all 16 regions but there are repeats.
JASS:
Region Dummy Copy
    Events
        Player - Player 1 (Red) types a chat message containing regiontest as An exact match
    Conditions
    Actions
        Set start_temp_regionspawn = start_set_region[(Random integer number between 1 and start_region_max)]
        Unit - Create 1 Footman for Player 1 (Red) at (Center of start_temp_regionspawn) facing Default building facing degrees
        Set start_region_max = (start_region_max - 1)



Here is my other trigger:

JASS:
Set Regions Copy
    Events
        Map initialization
    Conditions
    Actions
        Set start_region_max = 16
        Set start_set_region[1] = A1 <gen>
        Set start_set_region[2] = A2 <gen>
        Set start_set_region[3] = A3 <gen>
        Set start_set_region[4] = A4 <gen>
        Set start_set_region[5] = B1 <gen>
        Set start_set_region[6] = B2 <gen>
        Set start_set_region[7] = B3 <gen>
        Set start_set_region[8] = B4 <gen>
        Set start_set_region[9] = C1 <gen>
        Set start_set_region[10] = C2 <gen>
        Set start_set_region[11] = C3 <gen>
        Set start_set_region[12] = C4 <gen>
        Set start_set_region[13] = D1 <gen>
        Set start_set_region[14] = D2 <gen>
        Set start_set_region[15] = D3 <gen>
        Set start_set_region[16] = D4 <gen>


I still don't want the same units spawning in the same region.
 

Psiblade94122

In need of sleep
Reaction score
138
before you make the units

set an integer to be that integer +1 (this represents the player number)
if the integer value is greater then (your max ammount of players) then skip the remaining actions
store in a point variable a random location in the playing feild
Detect if there are any units around it
if there are
then remove the location
Force the tirgger to run again
skip all remaining actions
if there is not
then spawn the guy for the player (integer variable) and run the trigger again
 

Psiblade94122

In need of sleep
Reaction score
138
Code:
Bah
    Events
        Time - Elapsed game time is 0.00 seconds
    Conditions
    Actions
        Set Int = (Int + 1)
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                Int Greater than 10
            Then - Actions
                Set Int = 0
            Else - Actions
                Set L = (Random point in (Playable map area))
                Set Temp_UG = (Units within 2000.00 of L)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in Temp_UG) Greater than or equal to 1
                    Then - Actions
                        Set Int = (Int - 1)
                        Trigger - Run (This trigger) (checking conditions)
                    Else - Actions
                        Unit - Create 1 Footman for (Player(Int)) at L facing Default building facing degrees
                Custom script:   call RemoveLocation (udg_L)
                Custom script:   call DestroyGroup (udg_Temp_UG)

something along these lines
 

konerboy

Run piggy Run!
Reaction score
95
you need to make another integear where you can place all the taken numbers.

Re-roll
Events
Conditions
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
randomZone Equal to sameNumber
Then - Actions
Set randomZone = (Random integer number between 1 and 14)
Else - Actions: have noo clue
 

thevoden

New Member
Reaction score
5
What if i want to spawn to the unit in a specified region? Also, is there a way to detect if a unit is inside a region?

I could do the "if region contains this building then do not spawn, otherwise spawn this building
"
 

Psiblade94122

In need of sleep
Reaction score
138
then change (Playable map area) to the regeion you want

also change 2000.00 to whatever you want

for the rest just add an if then else function in there
 

thevoden

New Member
Reaction score
5
I made a more simpler way to do this:

JASS:
Region Dummy Copy
    Events
        Player - Player 1 (Red) types a chat message containing regiontest as An exact match
    Conditions
    Actions
        Set start_REGION_randomnumber = (Random integer number between 1 and start_REGION_max)
        Set start_REGION_Tspawn = start_REGION_set[start_REGION_randomnumber]
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                start_REGION_Boolean[start_REGION_randomnumber] Equal to False
            Then - Actions
                Unit - Create 1 Footman for Player 1 (Red) at (Center of start_REGION_Tspawn) facing Default building facing degrees
                Set start_REGION_Boolean[start_REGION_randomnumber] = True
                Set start_REGION_randomnumber = 0
            Else - Actions
                Trigger - Run (This trigger) (checking conditions)


Not that it will be a problem , but once all the buildings have been spawned in all 16 locations, the game crashes.

Any idea on why?
 

Psiblade94122

In need of sleep
Reaction score
138
because it runs over and over again, you need a way to stop it once it hits 16 or so

after all 16 rects are taken up, all the boolines returns true, meaning your if then statement will run the else (because the conditon is not met) and that will run the trigger over again, thus makeing a infanate loop
 

esb

Because none of us are as cruel as all of us.
Reaction score
328
I think a loop using booleans to check whether an integer has been used shoudl be enough.

At the end of the trigger, make another loop the size of your regions (1-16) and just have it check if BooleanInteger[IntegerA] = False(Not used), then run this trigger.
 

Psiblade94122

In need of sleep
Reaction score
138
>Unit - Create 1 Footman for Player 1 (Red) at (Center of start_REGION_Tspawn) facing Default building facing degrees

set the point to a variable, then remove it after
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top