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

How can I check if there is a possible path between 2 points?

Level 24
Joined
Jun 26, 2020
Messages
1,852
Hello, I wanna make a system that sometimes moves a unit to a random near location, but I wanna be sure that the unit won't get stucked, so I wanna know if there is a possible path between the old location and the new location, not the smallest path, just if a path exists.
 
Level 20
Joined
Feb 27, 2019
Messages
592
I had an idea for this problem using two units. The first unit starts at the casting position and the second at the target position. They are ordered to interact with each other and if they do so then the path is open.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
Not easily. This was why Blizzard added a native to StarCraft II to do such calculation.

You can try the snippet above, which I assume does some sort of path finder logic. Another approach is to order a unit down a path and check if it gets stuck along the way. The issue with such an approach is the unit is limited to maximum unit movement speed so might take some time to walk down long paths.
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
I don't get it, what do these functions?
vJASS:
function IsPathBlocked takes unit obstruction returns boolean
    // Determines whether or not there is a path after a new unit is placed

function LoadPathingMap takes nothing returns nothing
    // Loads pathing for map
    // Call before using system
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,201
I don't get it, what do these functions?
Top function looks like it is intended for maze tower defences. It seems like it should detect if the placed building, obstruction fragments the pathing map.

Bottom function seems to be an initialisation function. It should be called once before using the system. It likely loads in the current pathing map state.
 
Level 24
Joined
Jun 26, 2020
Messages
1,852
Top function looks like it is intended for maze tower defences. It seems like it should detect if the placed building, obstruction fragments the pathing map.

Bottom function seems to be an initialisation function. It should be called once before using the system. It likely loads in the current pathing map state.
Very well, thanks, but where is the function that tells me if 2 points can have a path?
 
Top