Spawn units at random places but not the same place as another unit.

minikrampan

Ultra Cool Member
Reaction score
28
As usual I lack the ability to make good headlines. Anyway, I'ts like a minigame and i hate minigames where you always spawn at the same place, so i was gonna do this randomly. And heres what I got

Trigger:
  • unit place
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, 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
              • Set start_int = (Random integer number between 1 and 12)
              • Set temp_point = (Center of Spawns[start_int])
              • Set temp_group = (Units in Spawns[start_int])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Number of units in temp_group) Equal to 0
                • Then - Actions
                  • Unit - Create 1 Unit for (Player((Integer A))) at temp_point facing Default building facing (270.0) degrees
                • Else - Actions
              • Custom script: call RemoveLocation(udg_temp_point)
              • Custom script: call DestroyGroup(udg_temp_group)
            • Else - Actions

The problem is that all units doesn't spawn. It trigger checks everytime it's about to spawn a unit if a unit already is there, and if it is it won't spawn anything. So how can I add a condition to spawn somewhere else if theres already a unit where the new unit is supposed to spawn?

ps. I also lack the ability of explaining myself in understandable ways.
 

SGT Vejito

New Member
Reaction score
9
from the looks of it, you just need to rerun the trigger again, to generate a new location out of the 12 possible (if i'm reading your trigger properly)

in the second to last Else statement (before the custom scripts) try putting this:

Trigger:
  • Trigger - Run (This trigger) (checking conditions)


either this trigger or the add to trigger queue button should cause this trigger to just repeat itself. As long as a player needs to be placed it should keep rolling random numbers until it has everyone at a separate location.
 

Komaqtion

You can change this now in User CP.
Reaction score
469
That makes it run through the loop of 12 too, which is unneccesary :D

Just make another trigger with all the actions in the first "If", and then add SGT's action in the "Else" part, but change (This trigger) to the newly created trigger ;)
 

minikrampan

Ultra Cool Member
Reaction score
28
Doesn't work really
Trigger:
  • 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
        • Set start_int = (Random integer number between 1 and 12)
        • Set temp_point = (Center of Spawns[start_int])
        • Set temp_group = (Units in Spawns[start_int])
        • Set temp_group2 = (Units owned by (Player((Integer A))))
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Number of units in temp_group) Equal to 0
            • (Number of units in temp_group2) Equal to 0
          • Then - Actions
            • Unit - Create 1 Tiny for (Player((Integer A))) at temp_point facing Default building facing (270.0) degrees
            • Set units[(Integer A)] = (Last created unit)
          • Else - Actions
            • Trigger - Run unit place Copy <gen> (checking conditions)
        • Custom script: call RemoveLocation(udg_temp_point)
        • Custom script: call DestroyGroup(udg_temp_group)
        • Custom script: call DestroyGroup(udg_temp_group2)
      • Else - Actions


Trigger:
  • unit place Copy
    • Events
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set temp_point = (Center of Spawns[(Integer A)])
          • Set temp_group = (Units in Spawns[(Integer A)])
          • Set temp_group2 = (Units owned by (Player((Integer A))))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Number of units in temp_group) Equal to 0
              • (Number of units in temp_group2) Equal to 0
            • Then - Actions
              • Unit - Create 1 Tiny for (Player((Integer A))) at temp_point facing Default building facing (270.0) degrees
              • Set units[(Integer A)] = (Last created unit)
            • Else - Actions
          • Custom script: call RemoveLocation(udg_temp_point)
          • Custom script: call DestroyGroup(udg_temp_group)
          • Custom script: call DestroyGroup(udg_temp_group2)


2 triggers, a few changes, whats wrong?
 
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