• 🏆 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!
  • ✅ HD Level Design Contest #1 POLL is now OPEN! Check out the stunning visuals of the final entries. 🔗Click here to cast your vote!

[Solved] Creating units in a region randomly that omit areas with deep water

Status
Not open for further replies.
Level 4
Joined
Aug 17, 2008
Messages
81
I don't know if this is possible or not. Maybe I did at one point, but now I forget.

The region covers an entire island, and because the island is circle instead of square, the region covers a lot of deep water areas as well. As such the randomly created units are often placed in unreachable areas, which I'd like to avoid.

I'm looking for the simplest fix possible for this, anyone know what I should do?

:vw_death:
 
Level 37
Joined
Mar 6, 2006
Messages
9,240
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at point of type Walkability is off) Equal to False // Boolean -> Environment - Terrain pathing is off
    • Then - Actions
      • Game - Display to Player Group - Player 1 (Red) the text: walk
    • Else - Actions
      • Game - Display to Player Group - Player 1 (Red) the text: no walk
 
Level 4
Joined
Aug 17, 2008
Messages
81
  • Set Resource_Integer = (Random integer number between 1 and 2)
  • For each (Integer A) from 1 to Resource_Integer, do (Actions)
    • Loop - Actions
      • Set RandomPoint = (Random point in SWC island 2 <gen>)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at RandomPoint of type Walkability is off) Equal to False
        • Then - Actions
          • Unit - Create 1 Uranium for Player 9 (Gray) at RandomPoint facing Default building facing degrees
        • Else - Actions
          • Set Resource_Integer = (Resource_Integer + 1)
How does this look? ;) It's supposed to loop infinitely until it finds a valid area in the region.
 
Level 4
Joined
Aug 17, 2008
Messages
81
  • Actions
    • Set Resource_Integer = (Random integer number between 5 and 10)
    • For each (Integer A) from 1 to Resource_Integer, do (Actions)
      • Loop - Actions
        • Set RandomPoint = (Random point in SWC island 2 <gen>)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • (Terrain pathing at RandomPoint of type Walkability is off) Equal to False
          • Then - Actions
            • Unit - Create 1 Uranium for Player 9 (Gray) at RandomPoint facing Default building facing degrees
          • Else - Actions
            • Set Resource_Integer = (Resource_Integer + 1)
    • Custom script: call RemoveLocation(udg_RandomPoint)
The point of the trigger is to generate 5-10 units randomly within a region that are on walkable terrain. I can't seem to get it working, something is wrong with the Integer update within the loop. It's supposed to make it loop longer to guarantee 5-10 units are created, but I'm constantly getting less than 5 units created. Help me more please? ;) lol
 

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
  • Set Resource_Integer = (Random integer number between 5 and 10)
  • Custom script: loop
  • Custom script: exitwhen 0 == udg_Resource_Integer
  • Set RandomPoint = (Random point in SWC island 2 <gen>)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Terrain pathing at RandomPoint of type Walkability is off) Equal to False
    • Then - Actions
      • Unit - Create 1 Uranium for Player 9 (Gray) at RandomPoint facing Default building facing degrees
      • Set Resource_Integer = (Resource_Integer - 1)
    • Else - Actions
  • Custom script: call RemoveLocation(udg_RandomPoint)
  • Custom script: endloop
 
Status
Not open for further replies.
Top