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

Terrain pathing at point - detection not working?

Status
Not open for further replies.
Level 19
Joined
Apr 25, 2006
Messages
1,309
  • (Terrain pathing at Point_Temp2 of type Walkability is off) Equal to True
Is there something wrong with this terrain condition or why do I get false from the condition every time at all points?
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
How can I detect the whole pathing? Currently the unit goes in the middle of unwalkable terrain and gets stuck there or teleports out.

It's an ability that should work only if it is cast on walkable point.
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
I don't understand that part, how do I get the boolean into a condition trigger after that? Is the boolean returned as some variable?
Do I need only GetVarObject 3.0.0.5 with that? I get error //! runtextmacro LUA_FILE_HEADER() unable to find textmacro "LUA_FILE_HEADER"
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,198
The boolean is returned...
You use it the same way you use every function that returns a value. It basically acts as a boolean value.

1.
if IsPathable( udg_Integer_Temp,udg_Integer_Temp2,PATH_TYPE_WALKABILITY) then
endif
2.
local boolean b = IsPathable( udg_Integer_Temp,udg_Integer_Temp2,PATH_TYPE_WALKABILITY)
3.
set booleanvar = IsPathable( udg_Integer_Temp,udg_Integer_Temp2,PATH_TYPE_WALKABILITY)
4.
loop
exitwhen IsPathable( udg_Integer_Temp,udg_Integer_Temp2,PATH_TYPE_WALKABILITY)
endloop

Need any other examples of use?
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
I don't understand that part, how do I get the boolean into a condition trigger after that? Is the boolean returned as some variable?
Do I need only GetVarObject 3.0.0.5 with that? I get error //! runtextmacro LUA_FILE_HEADER() unable to find textmacro "LUA_FILE_HEADER"


Be sure to go through all of the requireds links. In LUA_GET_VAR_OBJECT, it says it requires things too. In LUA_FILE_HEADER, you will find a simple tutorial on running Lua scripts.


It's a bit more work than the simple cnp item libs, but it doesn't bug up in the scenarios that they bug up in and it can detect different types of pathing =). I plan on adding a couple of other pathing types to it like water ^)^.
 
Level 19
Joined
Feb 4, 2009
Messages
1,313
you can also do this in GUI if you are more familiar with it

0. Create an item

1. Every time you want to check if a point is walkable move the item there
The item will automatically snap to the next walkable point (there are some exceptions)
2. Check the distance between the item and the point you moved it to
If the distance is small enough the point is likely to be walkable

Problems:
-the item might be blocked by another item (all items in the target region could be hidden and unhidden before moving the item for checking walkability)
-this way you can't check for collision size (unless you repeat that check for some points around it which will make things rather slow)
-items are unhidden if you move them (not really a problem since you can hide them again but might be worth to mention to avoid bugs)
-the item won't snap to the nearest position if it is on a unwalkable cliff or in deep water
you can use a second item to detect such a case since it would snap to another point because the target point is occupied by the first item already
but if both points are above each other the item did not snap away and the point is unwalkable
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
What is the difference between local boolean b and set booleanvar. Is b a boolean variable I can then use in gui triggers?
Does this work?
  • Custom script: set udg_Boolean_Temp = IsPathable( udg_Integer_Temp,udg_Integer_Temp2,PATH_TYPE_WALKABILITY)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Boolean_Temp Equal to False
    • Then - Actions
    • Else - Actions
Hey I copied the two other scripts and now I get this: library IsPathable uses WorldBounds - missing requirement: WorldBounds (libraries cannot require scopes)
What does that mean? I have all the 4 scripts copied in the map.
 
Last edited:
Level 31
Joined
Jul 10, 2007
Messages
6,306
JASS:
library IsPathable /* v1.0.1.2
*************************************************************************************
*
*   The IsTerrainPathable native does not work.
*
*   This library will also check if a point is currently pathable. Will even be
*   able to detect buildings and large clusters of units (avoids the 1024 warcraft
*   limit to pathing by checking via a loop).
*
************************************************************************************
*
*   */uses/*
*
*       */ WorldBounds /*       hiveworkshop.com/forums/jass-functions-413/snippet-worldbounds-180494/
*
************************************************************************************
*
*   constant integer PATH_TYPE_AMPHIBIOUS
*   constant integer PATH_TYPE_BLIGHT
*   constant integer PATH_TYPE_BUILDABILITY
*   constant integer PATH_TYPE_FLOATABILITY
*   constant integer PATH_TYPE_FLYABILITY
*   constant integer PATH_TYPE_WALKABILITY
*
*   function IsPathable takes integer x, integer y, integer pathingType returns boolean
*       -   i.e. call IsPathable(0,0,PATH_TYPE_AMPHIBIOUS)
*
************************************************************************************/

Notice the part that says uses =P

There is even a link =)
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
lol
Do I need this for something?
JASS:
//! externalblock extension=lua ObjectMerger $FILENAME$
    //! runtextmacro LUA_FILE_HEADER()
    //! i dofile("GetVarObject")
    
    //! i local function create(id,pt)
        //! i createobject("hwtw", id)
        //! i makechange(current, "unsf", "( " .. pt .. " )")
        //! i makechange(current, "upat", "")
        //! i makechange(current, "ushb", "")
        //! i makechange(current, "uubs", "")
        //! i makechange(current, "uabr", "0")
        //! i makechange(current, "uabt", "")
        //! i makechange(current, "ucol", "16")
        //! i makechange(current, "usid", "")
        //! i makechange(current, "usin", "")
        //! i if (pt~="blighted") then
            //! i makechange(current, "upap", pt)
        //! i else
            //! i makechange(current, "upar", pt)
            //! i makechange(current, "upap", "")
        //! i end
        //! i if (pt=="unflyable") then
            //! i makechange(current, "umvt", "fly")
        //! i elseif (pt=="unamph") then
            //! i makechange(current, "umvt", "amph")
        //! i elseif (pt=="unfloat") then
            //! i makechange(current, "umvt", "float")
        //! i else
            //! i makechange(current, "umvt", "foot")
        //! i end
    //! i end
    //! i create(getvarobject("hwtw", "units", "UNITS_PATH_" .. "unflyable", true),"unflyable")
    //! i create(getvarobject("hwtw", "units", "UNITS_PATH_" .. "unamph", true),"unamph")
    //! i create(getvarobject("hwtw", "units", "UNITS_PATH_" .. "unbuildable", true),"unbuildable")
    //! i create(getvarobject("hwtw", "units", "UNITS_PATH_" .. "unwalkable", true),"unwalkable")
    //! i create(getvarobject("hwtw", "units", "UNITS_PATH_" .. "unfloat", true),"unfloat")
    //! i create(getvarobject("hwtw", "units", "UNITS_PATH_" .. "blighted", true),"blighted")
    
    //! i updateobjects()
//! endexternalblock
 
Level 19
Joined
Apr 25, 2006
Messages
1,309
I think I have them all but was it imported rightly when I copied then all in trigger editor to the first map picture trigger custom script space? I'm not sure what that icon is called up there.
 
The lua scripts might be confusing to implement for GUI users.

If you want a bit simpler implementation, then you can use:
http://www.wc3c.net/showthread.php?t=103862

Nes' script probably covers something that the wc3c one doesn't, but the one above will most likely handle everything you need it for. (You would have to have weird circumstances for it to bug out)

To implement it:
  • Create a new trigger, name it whatever you'd like.
  • Convert it to custom text, and remove all the text. Then copy the entire code from wc3c into your trigger.
  • Now you are ready to use it. Here is an example of using it in GUI:
    • Actions
      • Set PathableLoc = Position of (Triggering Unit)
      • Custom script: set udg_IsLocPathable = IsTerrainWalkable( GetLocationX(udg_PathableLoc), GetLocationY(udg_PathableLoc))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsLocPathable Equal to True
        • Then - Actions
          • ------- Do your actions if it is pathable -------
        • Else - Actions

You can change whatever "PathableLoc" is equal to. If you are using different variable names, make sure change it in the custom script as well.

Good luck. :)
 
Status
Not open for further replies.
Top