HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Checking for Pathability?

04-26-2007, 10:28 AM#1
Kojiro
Now, I could have sworn I saw 'something' that returned whether a point was pathable or not looking through triggers...

...but looking back, I can't seem to find it.

I want to move a hero to target point, if target point != pathable, I want it to let me know so I can stop the knockback effects.

Thanks in advance.
04-26-2007, 11:50 AM#2
TheSecretArts
I think it has somehting to do with GetTerrainType takes real x, real y, returns integer
04-26-2007, 12:55 PM#3
substance
Collapse JASS:
if IsTerrainPathable(x,y,false) == true then
.
04-26-2007, 01:23 PM#4
Vexorian
IsTerrainPathable returns the opposite to what you'll expect.

And it ignores destructables
04-26-2007, 06:48 PM#5
Maley
I think there is no function from blizzard which checks that. But you can easily make your own. You just have to create a unit at the loc you wanna check and check after creation if the unit is still on the loc you created it on.
Because if the loc is unpathable it wont create the unit there but somewhere else at a point which is pathable.

WFR Maley
04-26-2007, 07:42 PM#6
TheSecretArts
Did you read posts above before replying?
04-27-2007, 06:54 AM#7
Jazradel
He has a better answer.
04-27-2007, 07:00 AM#8
PitzerMike
Items will be better
http://www.wc3jass.com/viewtopic.php...light=pathable
04-29-2007, 07:00 AM#9
Kojiro
Thanks for the replies folks, greatly appreciated.
04-30-2007, 01:30 AM#10
Pyrogasm
You could also use this code by grim001:
Quote:
Originally Posted by grim001
Collapse JASS:
function CheckPathability takes unit u, real x, real y returns boolean
    local real ox = GetUnitX(u)
    local real oy = GetUnitY(u)
    if x > MAX_X then
        return false
    elseif x < MIN_X then
        return false
    if y > MAX_Y then
        return false
    elseif y < MIN_Y then
        return false
    endif
    call SetUnitX(u, -9472.)
    call SetUnitY(u, 9216.)
    call SetUnitPosition(PATHUNIT, x, y)
    set x = GetUnitX(PATHUNIT)-x
    set y = GetUnitY(PATHUNIT)-y
    call SetUnitX(PATHUNIT, -9472.)
    call SetUnitY(PATHUNIT, 9216.)
    call SetUnitX(u, ox)
    call SetUnitY(u, oy)
    return x*x+y*y <= 100.
endfunction

-9472, 9216 is a chosen safespot on my map where units are moved to temporarily during this function and where the PATHUNIT is stored.

MIN_X, MIN_Y and so on are the map boundries. It's best if you actually place the map boundry numbers directly into the function rather than using a variable since it will be slightly faster.

PATHUNIT is a global unit variable containing a ground unit with 32 collision radius and no model. Do not create and destroy a unit because this function is designed to be as speedy as possible and could wind up executing it hundreds of times per second. Also rapidly creating/destroying handles increases WC3's memory usage substantially.

Really a function like this is the only way to check if another unit gets in the way while you're moving around units with SetUnitX and SetUnitY unless you want the horrible lag of making WC3's check its pathing map.