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

Make things not spawn in water when triggered?

Status
Not open for further replies.
Level 6
Joined
Mar 17, 2012
Messages
105
I have a trigger that creates some Berry Bushes at random points across the map. However, they will spawn in water, too. I don't want that. How can I have it so that my bushes won't be created in water via trigger? Current trigger:


  • Berry creation
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Unit - Create 5 Berry Bush for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
      • Unit - Create 5 Berry Bush for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
      • Unit - Create 5 Berry Bush for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
      • Unit - Create 5 Berry Bush for Neutral Passive at (Random point in (Playable map area)) facing Default building facing degrees
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Method 1
Test if the point is in water and if so find a new point. Repeat many times until a valid point is found or a limit was reached in which case defer to another thread to prevent a thread crash due to op-limit.

Method 2
Break the map apart into regions that do not contain water. Based on the are you then assign a probability that each region will get picked to generate a location. The location then is generated randomly inside that region. This has the advantage over method 1 in that it is always guaranteed to succeed as success is not left to chance.
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
  • water
    • Events
    • Conditions
    • Actions
      • Set point = (Random point in (Playable map area))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at point of type Floatability is off) Equal to False
        • Then - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: water
        • Else - Actions
          • Game - Display to Player Group - Player 1 (Red) the text: not water
      • Custom script: call RemoveLocation(udg_point)
 
Status
Not open for further replies.
Top