• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Is Point Reachable! [Solved]

Level 10
Joined
Jun 20, 2017
Messages
337
I found these two threads that could help me figure out how a unit can't go where he can't go and stop/hold him in his position! so that he couldn't walk and move around!
I modified the map and added some Boundary (like a square and the unit can blink there but can't move there), Pathing Blocker (Both) or Water so the unit can't move there.
I added these two in the first map, but it didn't work!
Unit - Order (Ordered unit) to Stop.
Unit - Order (Ordered unit) to Hold Position.
In the second map, the Rifleman attached to a Gryphon Rider and cannot move where he cannot (I want something like this).
Check Walkability
About Movement
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
I didn't click any of those links, but issuing a Stop order to a unit in response to an issued order will not work unless you also do this:
  • Unit - Pause (Triggering unit)
  • Unit - Order (Triggering unit) to Stop
  • Unit - Unpause (Triggering unit)
Alternatively, you can use the "Stun" variant which may be more efficient and have less potential for bugs:
  • Custom script: call BlzPauseUnitEx( GetTriggerUnit(), true )
  • Unit - Order (Triggering unit) to Stop
  • Custom script: call BlzPauseUnitEx( GetTriggerUnit(), false )
^ Only available on 1.31+.

Note that this issues the Stop order many times in that single frame, which by itself should be fine. Just be aware of your other triggers that may detect when an "Order with no target" is issued, worst case you can turn them off prior to issuing the Order then turn them back on. It's likely not an issue, though.
 
Last edited:
Level 20
Joined
Feb 27, 2019
Messages
593
I got thinking about this issue after you posted this thread. It led to me trying to do some funky stuff with Battle Stations. When casting Battle Stations, nearby Peons will run to the Burrow but if they cant find a path, using the inbuilt logic, they wont move. So you can instantly check if they found a path by checking their current order.

But... and theres a big butt.

1. It can only check the path for units with less than 32.00 collision size.
2. It has limited range to check if a point is reachable which seems to vary depending on position and other map pathing.

Could you give it a try and see if it works for you? Post results.
 

Attachments

  • Is Point Reachable.w3m
    18.9 KB · Views: 3

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
Warcraft III lacks the required functionality for this? I do not think Reforged added natives to check if a path exists between points. In StarCraft II there is a trivial single function call solution to check for a path between points, which is likely the sort of solution desired here.

The brute force approach might be to code every pathing island as regions, and then check if the point is in the same region as the other point. If not, then they cannot be reached and so you can cancel the order. If they are in the same region, then they can be reached by walking. Might need separate regions for flying, swimming, e.t.c. Region in this context is JASS type region and not the GUI region which is JASS type rect, the two types have very different uses.

The "Terrain pathing at ..." condition is checking the base pathing flags at the specified point, it does not factor in pathing modifications such as from buildings or destructables. Since it is a single point, it cannot tell you if a path exists between two points, although it might be used in a system that tries to implement its own path finder to do so.

The function "Distance between ..." returns the euclidian distance between the points. This does not factor in pathing, or even terrain Z height, at all. Literally sqrt((x2 - x1)^2 + (y2 - y1)^2).
 
Level 10
Joined
Jun 20, 2017
Messages
337
I'm trying to detect when a player wants to build a certain build in a blocked location, then stop him or cancel his order.
The trigger below sort of solves that! But I have to use many regions and if my units are in blocked locations or they enter to those locations, they can't move again!
  • Untitled Trigger 003
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • Trigger - Turn off (This trigger)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Point is unreachable <gen> contains (Target point of issued order)) Equal to False
        • Then - Actions
          • Game - Display to (All players) the text: YES
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Point is unreachable <gen> contains (Target point of issued order)) Equal to True
            • Then - Actions
              • Custom script: call BlzPauseUnitEx( GetTriggerUnit(), true )
              • Unit - Order (Triggering unit) to Stop.
              • Custom script: call BlzPauseUnitEx( GetTriggerUnit(), false )
              • Game - Display to (All players) the text: NO
            • Else - Actions
      • -------- --------
      • Trigger - Turn on (This trigger)
Also when you right click on something in blocked locations, your unit will still go there or try to find a way to go there!

As Dr Super Good said, it is difficult to check everything! I have to code everything.
Which locations are blocked and which are not!
Which units are in blocked locations and which are not!
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,583
I made some changes to make the point reachability check work for all units, not only Peon 0001. I also made it check for targeted objects, not only point target.
Nice idea, very useful. You should turn it into a system with some more variables for easy porting into new maps. Also, I suggest to Hide the Peon/Burrow and Unhide whenever needed, similar to how systems use hidden Items to test pathing. I could do it if you can't be bothered :)
 
Level 20
Joined
Feb 27, 2019
Messages
593
Nice idea, very useful. You should turn it into a system with some more variables for easy porting into new maps. Also, I suggest to Hide the Peon/Burrow and Unhide whenever needed, similar to how systems use hidden Items to test pathing. I could do it if you can't be bothered :)
Thanks Uncle :) Im seeing if I can improve the mechanic and Ill give a shot at turning it into a system when I got it figured out!
 
Top