• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Spawn units in a random point from at least 800 of distance from any unit

Level 6
Joined
Jul 12, 2021
Messages
97
Hi. I want to spawn units in a random point from at least 800 of distance from any other units. I'm having some trouble doing this. I tried assigning a random point in world map to a variable, then pick every unit within 800 of distance of the point, and the if there was no unit in range, to create the desired unit. The problem was that the actions for this type of triggers are executed once per unit. So, if the group has no units, the actions aren't executed.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
Not sure what group your question is referring to.

If referring to the test group, then you count number of units in it, or check if the first unit in the group is null/nil. Then use that check in a if then else flow control statement to execute the spawn or not.

If referring to running spawning attempts, then that should likely be done from a regular for integer loop and not a for unit in unit group loop. You will want some maximum number of attempts to prevent frame pacing issues, and you will likely want to keep trying to spawn units until some limit of spawns is reached. The more units in the spawn area, the less likely each spawn attempt will succeed, so more attempts would be needed to spawn the same number of units.
 
Top