• 🏆 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!

[Solved] Stop unit from going to a certain location when ordered

in this trigger , a unit can isntantly move to a smart-move location, but only if not in the blue zone. so if it is order to go to the blue zone, it doesnt instantly move there, but still starts to go. as you can see i tried with trigger order unit to hold position, but doesnt work?

  • move instantl
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Set TempLoc = (Target point of issued order)
      • Unit - Order (Triggering unit) to Hold Position
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Player number of (Owner of (Triggering unit))) Less than 6
              • (blue zone <gen> contains TempLoc) Equal to False
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Player number of (Owner of (Triggering unit))) Greater than or equal to 6
              • (blue zone <gen> contains TempLoc) Equal to True
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
      • Custom script: call RemoveLocation(udg_TempLoc)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
I don't think I fully understand what you're trying to do but I cleaned the trigger up:
  • move instantly
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Set TempLoc = (Target point of issued order)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player number of (Owner of (Triggering unit))) Less than 6
          • (blue zone <gen> contains TempLoc) Equal to False
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (blue zone <gen> contains TempLoc) Equal to True
            • Then - Actions
              • Unit - Move (Triggering unit) instantly to TempLoc
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempLoc)
Remember that all conditions need to be True by default. The use of the AND is unnecessary:
  • And - All (Conditions) are true
AND would only be used in cases where you're using OR as well. It is meant to allow you to create a combination of Conditions like:

If Condition A is True OR Condition B AND Condition C are True then proceed to the Actions...

Also, a trick for interrupting an issued order is to do this:
  • Unit - Pause (Triggering unit)
  • Unit - Order (Triggering unit) to Stop
  • Unit - Unpause (Triggering unit)
You can use that to interrupt the smart order. Keep in mind it may cause some unwanted side effects, especially if you have triggers revolving around the "Stop" order.
 
Last edited:
I don't think I fully understand what you're trying to do but I cleaned the trigger up:
  • move instantly
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Set TempLoc = (Target point of issued order)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player number of (Owner of (Triggering unit))) Less than 6
          • (blue zone <gen> contains TempLoc) Equal to False
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (blue zone <gen> contains TempLoc) Equal to True
            • Then - Actions
              • Unit - Move (Triggering unit) instantly to TempLoc
            • Else - Actions
      • Custom script: call RemoveLocation(udg_TempLoc)
Remember that all conditions need to be True by default. The use of the AND is unnecessary:
  • And - All (Conditions) are true
AND would only be used in cases where you're using OR as well. It is meant to allow you to create a combination of Conditions like:

If Condition A is True OR Condition B AND Condition C are True then proceed to the Actions...

Also, a trick for interrupting an issued order is to do this:
  • Unit - Pause (Triggering unit)
  • Unit - Order (Triggering unit) to Stop
  • Unit - Unpause (Triggering unit)
You can use that to interrupt the smart order. Keep in mind it may cause some unwanted side effects, especially if you have triggers revolving around the "Stop" order.
oh, pausing and un-pausing is an excellent idea, thanks!

With or without AND it's the same. I think it looks neater.

Can you give me idea how to also check if the area is not fly-able? the worker im ordering has move type fly and there are areas with fly-path blockers
I tried this but not working. So as of right now, when ordered to go to no-fly area, it moves to the nearest available instead.
  • move instantly
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Issued order) Equal to (Order(smart))
    • Actions
      • Set TempLoc = (Target point of issued order)
      • Unit - Pause (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player number of (Owner of (Triggering unit))) Less than 6
          • (blue zone <gen> contains TempLoc) Equal to False
          • (Terrain pathing at TempLoc of type Flyability is off) Equal to False
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player number of (Owner of (Triggering unit))) Greater than or equal to 6
          • (blue zone <gen> contains TempLoc) Equal to True
          • (Terrain pathing at TempLoc of type Flyability is off) Equal to False
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
      • Unit - Unpause (Triggering unit)
      • Custom script: call RemoveLocation(udg_TempLoc)
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
I would only Pause/Unpause the unit when you want to interrupt the order. At the moment you're always doing it regardless of where they clicked.

This:
  • (Terrain pathing at TempLoc of type Flyability is off) Equal to False
Is checking if the Flyability is NOT off, so in other words it's asking:

"Is the terrain at TempLoc Flyable? If yes, proceed to the Actions."

Is that what you want to check? I know those Terrain Pathing checks can be weird.

If you want a unit to ignore collision when moving it instantly you can use SetUnitX/Y:
  • Set TempUnit = (Triggering unit)
  • Set TempLoc = (Target point of issued order)
  • Set X = (X of TempLoc)
  • Set Y = (Y of TempLoc)
  • Custom script: call SetUnitX(udg_TempUnit, udg_X)
  • Custom script: call SetUnitY(udg_TempUnit, udg_Y)
 
Last edited:
I would only Pause/Unpause the unit when you want to interrupt the order. At the moment you're always doing it regardless of where they clicked.

This:
  • (Terrain pathing at TempLoc of type Flyability is off) Equal to False
Is checking if the Flyability is NOT off, so in other words it's asking:

"Is the terrain at TempLoc Flyable? If yes, proceed to the Actions."

Is that what you want to check? I know those Terrain Pathing checks can be weird.

If you want a unit to ignore collision when moving it you can use SetUnitX/Y:
  • Set TempUnit = (Triggering unit)
  • Set TempLoc = (Target point of issued order)
  • Set X = (X of TempLoc)
  • Set Y = (Y of TempLoc)
  • Custom script: call SetUnitX(udg_TempUnit, udg_X)
  • Custom script: call SetUnitY(udg_TempUnit, udg_Y)
if I set it to TRUE it wont even move on flyiable terrain. My goal is to stop it from doing anything when ordered to move to an area that has flying path blockers / flying pathing is off.


EDIT: Oh, I came up with another idea. To check the terrain type. And it worked!
Threads solved I suppose

  • move instantly
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Equal to (Order(move))
    • Actions
      • Set TempLoc = (Target point of issued order)
      • Unit - Pause (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Player number of (Owner of (Triggering unit))) Less than 6
              • (blue zone <gen> contains TempLoc) Equal to False
              • (Terrain type at TempLoc) Not equal to Cityscape - Brick
              • (Terrain type at TempLoc) Not equal to Cityscape - Square Tiles
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player number of (Owner of (Triggering unit))) Greater than or equal to 6
          • (blue zone <gen> contains TempLoc) Equal to True
          • (Terrain type at TempLoc) Not equal to Cityscape - Brick
          • (Terrain type at TempLoc) Not equal to Cityscape - Square Tiles
        • Then - Actions
          • Unit - Move (Triggering unit) instantly to TempLoc
        • Else - Actions
      • Unit - Unpause (Triggering unit)
      • Custom script: call RemoveLocation(udg_TempLoc)
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,557
Glad you found a solution. I came up with one as well which might work better. The idea is to find all of the Pathing Blocker (Air) and Pathing Blocker (Large) (Air) destructibles in your map and use the SetTerrainPathable() function to disable the Flyability pathing around them. I found that this function works with the (Terrain pathing at Point) condition where as the Pathing Blockers didn't work for some reason.

Here's the code you would need to copy into your map:
vJASS:
library TerrainPathingHelper
    // Note: I have no idea if my math is correct but it seems to work fine in the demo map!

    // Used with Pathing Blocker (Air)
    function TPH_Disable_Flying takes location p returns nothing
        local location p2 = PolarProjectionBJ(p, 36.00, 135.00)
        local real x = GetLocationX(p2)
        local real y = GetLocationY(p2)
        local real newX = x
        local integer i = 0
        local integer mod = 4
        //local effect sfx

        loop
            set i = i + 1
            exitwhen i > 16

            // For debugging (enable local effect sfx):
            //set sfx = AddSpecialEffect("Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl", newX, y)
            //call BlzSetSpecialEffectScale(sfx, 0.1)

            call SetTerrainPathable(newX, y, PATHING_TYPE_FLYABILITY, false)
            set newX = newX + 16.0

            // Reset the x and lower the y at the end of a row
            if ModuloInteger(i, mod) == 0 then
                set y = y - 16.0
                set newX = x
            endif
        endloop

        // Clean up memory leaks
        call RemoveLocation(p2)
        set p2 = null
    endfunction

    // Used with Pathing Blocker (Large) (Air)
    function TPH_Disable_Flying_Large takes location p returns nothing
        local location p2 = PolarProjectionBJ(p, 80.00, 135.00)
        local real x = GetLocationX(p2)
        local real y = GetLocationY(p2)
        local real newX = x
        local integer i = 0
        local integer mod = 8
        //local effect sfx

        loop
            set i = i + 1
            exitwhen i > 64

            // For debugging (enable local effect sfx):
            //set sfx = AddSpecialEffect("Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl", newX, y)
            //call BlzSetSpecialEffectScale(sfx, 0.1)

            call SetTerrainPathable(newX, y, PATHING_TYPE_FLYABILITY, false)
            set newX = newX + 16.0

            // Reset the x and lower the y at the end of a row
            if ModuloInteger(i, mod) == 0 then
                set y = y - 16.0
                set newX = x
            endif
        endloop

        // Clean up memory leaks
        call RemoveLocation(p2)
        set p2 = null
    endfunction

     // Used with Pathing Blocker
     function TPH_Disable_Walkability takes location p returns nothing
        local location p2 = PolarProjectionBJ(p, 36.00, 135.00)
        local real x = GetLocationX(p2)
        local real y = GetLocationY(p2)
        local real newX = x
        local integer i = 0
        local integer mod = 4
        //local effect sfx

        loop
            set i = i + 1
            exitwhen i > 16

            // For debugging (enable local effect sfx):
            //set sfx = AddSpecialEffect("Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl", newX, y)
            //call BlzSetSpecialEffectScale(sfx, 0.1)

            call SetTerrainPathable(newX, y, PATHING_TYPE_WALKABILITY, false)
            set newX = newX + 16.0

            // Reset the x and lower the y at the end of a row
            if ModuloInteger(i, mod) == 0 then
                set y = y - 16.0
                set newX = x
            endif
        endloop

        // Clean up memory leaks
        call RemoveLocation(p2)
        set p2 = null
    endfunction

    // Used with Pathing Blocker (Large)
    function TPH_Disable_Walkability_Large takes location p returns nothing
        local location p2 = PolarProjectionBJ(p, 80.00, 135.00)
        local real x = GetLocationX(p2)
        local real y = GetLocationY(p2)
        local real newX = x
        local integer i = 0
        local integer mod = 8
        //local effect sfx

        loop
            set i = i + 1
            exitwhen i > 64

            // For debugging (enable local effect sfx):
            //set sfx = AddSpecialEffect("Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl", newX, y)
            //call BlzSetSpecialEffectScale(sfx, 0.1)

            call SetTerrainPathable(newX, y, PATHING_TYPE_WALKABILITY, false)
            set newX = newX + 16.0

            // Reset the x and lower the y at the end of a row
            if ModuloInteger(i, mod) == 0 then
                set y = y - 16.0
                set newX = x
            endif
        endloop

        // Clean up memory leaks
        call RemoveLocation(p2)
        set p2 = null
    endfunction

endlibrary

Here's an example of using the system:
  • Disable Flying Pathing
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Destructible - Pick every destructible in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Destructible-type of (Picked destructible)) Equal to Pathing Blocker (Air) (Large)
            • Then - Actions
              • Set TPH_Point = (Position of (Picked destructible))
              • Custom script: call TPH_Disable_Flying_Large( udg_TPH_Point )
              • Custom script: call RemoveLocation( udg_TPH_Point )
              • -------- OPTIONAL: Remove the Pathing Blocker since the system is now disabling the flying pathing there: --------
              • Destructible - Remove (Picked destructible)
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Destructible-type of (Picked destructible)) Equal to Pathing Blocker (Air)
                • Then - Actions
                  • Set TPH_Point = (Position of (Picked destructible))
                  • Custom script: call TPH_Disable_Flying( udg_TPH_Point )
                  • Custom script: call RemoveLocation( udg_TPH_Point )
                  • -------- OPTIONAL: Remove the Pathing Blocker since the system is now disabling the flying pathing there: --------
                  • Destructible - Remove (Picked destructible)
                • Else - Actions
I pick through all of the Destructibles and call the appropriate TPH() function on any (Air) Pathing Blockers found. The system then kicks in and blocks the Flyability pathing at each Point. As a result the (Terrain pathing at Point) condition will now work properly.

Additionally, we can get rid of the Pathing Blocker since the pathing around it is now blocked by the system. Note that the system is assuming that your Pathing Blockers haven't had their Pathing Texture changed and are still using the default values.

Now that the Terrain pathing Flyability has been disabled by the system we can easily create your trigger:
  • Test
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Set TPH_Point = (Target point of issued order)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Terrain pathing at TPH_Point of type Flyability is off) Equal to True
        • Then - Actions
          • Game - Display to (All players) for 1.00 seconds the text: No moving there!
          • Unit - Pause (Triggering unit)
          • Unit - Order (Triggering unit) to Stop.
          • Unit - Unpause (Triggering unit)
        • Else - Actions
      • Custom script: call RemoveLocation( udg_TPH_Point )
 

Attachments

  • Terrain Pathing Helper 1.w3m
    20.4 KB · Views: 0
Last edited:
Top