• 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.

Random Unit Placement

Status
Not open for further replies.
Level 4
Joined
Feb 3, 2011
Messages
56
Hey is there a way to spawn a single type of unit in multiple places in a region, possibly facing random directions? Trying to spawn villagers in a village.
 
  • For each (Integer A) from 1 to NumberOfPoints, do (Actions)
    • Loop - Actions
      • Set Point1 = (Random point in YourRegion <gen>)
      • Unit - Create 1 Unit at Point1 facing Default Building Facing degrees
      • Set Point2 = (Point1 offset by 200.00 towards (Random angle) degrees)
      • Unit - Order (Last created unit) to Patrol To Point2
      • Custom script: call RemoveLocation (udg_Point1)
      • Custom script: call RemoveLocation (udg_Point2)
You don't have to set a random angle facing upon spawning, since the patrol command will affect it anyway.

NumberOfPoints is the number of units you want to spawn.
 
Status
Not open for further replies.
Top