• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[Spell] Trigger to find nearest source of walkable land

Status
Not open for further replies.
I have a unit with a metamorphosis ability that turns them into a flying hero. When they come out of it and become a land unit again, I want to force them onto the nearest walkable land.

I have a system that checks if land is walkable or not I am using, which works fine. This existing trigger will put the unit onto walkable land when asked, but definitely not the closest land. It just finds arbitrary land that is somewhat closeby. Here's my two triggers.

  • Metamorph Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Metamorphosis
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • TempInt Equal to 1
        • Then - Actions
          • Set VariableSet TempInt = 0
          • Set VariableSet HeroWithFlyingTransformation = (Triggering unit)
          • Set VariableSet LandingPoint = (Position of HeroWithFlyingTransformation)
          • Set VariableSet LandingDistance = 50.00
          • Set VariableSet LandingDegrees = 0.00
          • Trigger - Run Find land <gen> (ignoring conditions)
        • Else - Actions
          • Set VariableSet TempInt = 1
  • Find land
    • Events
    • Conditions
    • Actions
      • Set VariableSet CP_Point = LandingPoint
      • Trigger - Run Check Walkability <gen> (ignoring conditions)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CP_PointIsWalkable Equal to True
        • Then - Actions
          • Unit - Move HeroWithFlyingTransformation instantly to LandingPoint
          • Custom script: call RemoveLocation( udg_LandingPoint )
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LandingDegrees Less than or equal to 360.00
            • Then - Actions
              • Set VariableSet LandingPoint = (LandingPoint offset by LandingDistance towards LandingDegrees degrees.)
              • Set VariableSet LandingDegrees = (LandingDegrees + 25.00)
            • Else - Actions
              • Set VariableSet LandingDegrees = 0.00
              • Set VariableSet LandingDistance = (LandingDistance + 50.00)
          • Trigger - Run (This trigger) (ignoring conditions)
 
Upon morphing, create an Item at the position of the unit. The item will be repositioned by Warcraft 3's pathing system if it's pathing is blocked. Then move your unit to the position of the item and remove the item from the game.
  • Item - Create item at position of triggering unit
  • Unit - Move unit instantly to position of last created item
  • Item - Remove last created item
If Items don't work then you can use a non-amphibious/non-flying unit instead.

(I didn't test this, but I'm pretty sure it works)
 
Last edited:
The item will be repositioned by Warcraft 3's pathing system if it's pathing is blocked. Then move your unit to the position of the item and remove the item from the game.
This works for small unpathable areas, but I think it might break with larger ones as I recall WC3's displacement algorithm just giving up and placing the object in an inappropriate location if no appropriate locations are reasonably nearby.
 
Status
Not open for further replies.
Back
Top