• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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,201
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,240
  • 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