System IsPathable

Nestharus

o-o
Reaction score
84
Is Point Pathable

Not to be confused with IsTerrainPathable, this script will check to see if a point is currently pathable given a pathing type. For example, it will be able to detect if a building is at that point, unlike IsTerrainPathable, which only checks the terrains pathability (including doodads and what not).

This takes advantage of SetUnitPosition in order to determine whether a point is pathable or not. However, SetUnitPosition may bug in cases where the closest pathable point is at least 1024 units away (in which case the unit is just placed at the original point regardless as to whether it was pathable or not). This avoid that bug with a special algorithm that no other is pathable resource has.

Installation Script
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", "PathTextures\\2x2Default.tga")
        //! i makechange(current, "ushb", "")
        //! i makechange(current, "uubs", "")
        //! i makechange(current, "uabr", "0")
        //! i makechange(current, "uabt", "")
        //! i makechange(current, "ucol", "0")
        //! i makechange(current, "usid", "")
        //! i makechange(current, "usin", "")
        //! i makechange(current, "usca", ".01")
        //! i makechange(current, "uabi", "Avul")
        //! 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


Script
JASS:

library IsPathable /* v1.0.2.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)
*
************************************************************************************
*
*   */uses/*
*
*       */ WorldBounds /*           hiveworkshop.com/forums/jass-functions-413/snippet-worldbounds-180494/
*       */ optional UnitIndexer /*  hiveworkshop.com/forums/jass-resources-412/system-unit-indexer-172090/
*
************************************************************************************
*
*   SETTINGS
*/
    globals
        /*
            Enables the 1024 path checking for warcraft 3 (100% accurate path checking)
            The 1024 case is a very rare case and may not be present in the map
            Only enable this if it is truly needed (major performance hit).
        */
        private constant boolean SAFE_PATHING = false
    endglobals
/*
************************************************************************************
*
*   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)
*
************************************************************************************/
    globals
        //pathing types
        constant integer PATH_TYPE_AMPHIBIOUS=0
        constant integer PATH_TYPE_BLIGHT=1
        constant integer PATH_TYPE_BUILDABILITY=2
        constant integer PATH_TYPE_FLOATABILITY=3
        constant integer PATH_TYPE_FLYABILITY=4
        constant integer PATH_TYPE_WALKABILITY=5
        
        private pathingtype array pt
        private unit array u                                //unit pathability checkers array
    endglobals
    function GetPathingUnit takes integer pt returns unit
        return u[pt]
    endfunction
    function IsPathable takes integer x, integer y, integer p returns boolean
        local boolean b                                     //was point pathable?
        
        call SetUnitPosition(u[p],x,y)                      //use SetUnitPosition to determine if point is pathable
        set b=GetUnitX(u[p])==x and GetUnitY(u[p])==y       //if coordinates are identical, coordinate *may* be
                                                            //pathable
                                                            
        static if SAFE_PATHING then
            if (b) then
                //if the point was found as pathable, it may not be pathable
                //units are placed at the original coordinates if the closest pathable point is
                //at least 1024 units out
                set x=x+32                      //go out by 32
                call SetUnitPosition(u[p],x,y)  //set unit to new position
                set b=GetUnitX(u[p])<x          //check to see if unit shifted towards original position
                //if unit didn't shift towards original position, check second position with another unit
                
                //where all points are not pathable, place a unit at an arbitrary point
                //it will stay at that point even though it isn't pathable
                /*
                    *   *   *   *
                    *   *   *   *
                    *   U   *   *
                    *   *   *   *
                */
                
                //shift the unit over by 1 and see if it doesn't shift
                //if it did shift, then the original position was pathable
                //if it didn't shift, then both positions may or may not be pathable
                /*
                    *   *   *   *
                    *   *   *   *
                    *   *   U   *
                    *   *   *   *
                */
                
                //place a second unit on top of the first unit
                //if it didn't shift left, then the first position was not pathable
                /*
                    *   *   *   *
                    *   *   *   *
                    *   *   <-UU   *
                    *   *   *   *
                    
                    --------------------------
                    *   *   *   *
                    *   *   *   *
                    *   U   U   *
                    *   *   *   *
                */
                //the reason it will shift left is because 64 is only half a square, meaning it
                //will still be closest to the first position
                
                //the reason why two units are required
                /*
                    *   *   *   *
                    *   *   *   *
                    *           *
                    *   *   *   *
                */
                //in this case, both positions are pathable, meaning the unit will not shift
                //it would be identical to this case
                /*
                    *   *   *   *
                    *   *   *   *
                    *   *   *   *
                    *   *   *   *
                */
                //and the reason for moving right is due to this case
                /*
                    *   *   *   *
                    *   *   *   *
                    *       *   *
                    *   *   *   *
                */
                //in this case, a unit placed on top of the original unit will not shift anywhere
                //and nothing is known
                if (not b) then
                    call SetUnitPosition(u[p+6],x-32,y)
                    set b=GetUnitX(u[p+6])<x
                    call SetUnitX(u[p+6],WorldBounds.minX)
                    call SetUnitY(u[p+6],WorldBounds.minY)
                endif
            endif
        endif
        call SetUnitX(u[p],WorldBounds.minX)
        call SetUnitY(u[p],WorldBounds.minY)
        return b
    endfunction
    private module N
        private static method onInit takes nothing returns nothing
            local player p=Player(15)
            
            set pt[PATH_TYPE_FLYABILITY]=PATHING_TYPE_FLYABILITY
            set pt[PATH_TYPE_AMPHIBIOUS]=PATHING_TYPE_AMPHIBIOUSPATHING
            set pt[PATH_TYPE_BUILDABILITY]=PATHING_TYPE_BUILDABILITY
            set pt[PATH_TYPE_WALKABILITY]=PATHING_TYPE_WALKABILITY
            set pt[PATH_TYPE_FLOATABILITY]=PATHING_TYPE_FLOATABILITY
            set pt[PATH_TYPE_BLIGHT]=PATHING_TYPE_BLIGHTPATHING
            
            static if LIBRARY_UnitIndexer then
                set UnitIndexer.enabled = false
            endif
            set u[PATH_TYPE_FLYABILITY]=CreateUnit(p,UNITS_PATH_unflyable,0,0,0)
            set u[PATH_TYPE_AMPHIBIOUS]=CreateUnit(p,UNITS_PATH_unamph,0,0,0)
            set u[PATH_TYPE_BUILDABILITY]=CreateUnit(p,UNITS_PATH_unbuildable,0,0,0)
            set u[PATH_TYPE_WALKABILITY]=CreateUnit(p,UNITS_PATH_unwalkable,0,0,0)
            set u[PATH_TYPE_FLOATABILITY]=CreateUnit(p,UNITS_PATH_unfloat,0,0,0)
            set u[PATH_TYPE_BLIGHT]=CreateUnit(p,UNITS_PATH_blighted,0,0,0)
            
            set u[PATH_TYPE_FLYABILITY+6]=CreateUnit(p,UNITS_PATH_unflyable,0,0,0)
            set u[PATH_TYPE_AMPHIBIOUS+6]=CreateUnit(p,UNITS_PATH_unamph,0,0,0)
            set u[PATH_TYPE_BUILDABILITY+6]=CreateUnit(p,UNITS_PATH_unbuildable,0,0,0)
            set u[PATH_TYPE_WALKABILITY+6]=CreateUnit(p,UNITS_PATH_unwalkable,0,0,0)
            set u[PATH_TYPE_FLOATABILITY+6]=CreateUnit(p,UNITS_PATH_unfloat,0,0,0)
            set u[PATH_TYPE_BLIGHT+6]=CreateUnit(p,UNITS_PATH_blighted,0,0,0)
            static if LIBRARY_UnitIndexer then
                set UnitIndexer.enabled = true
            endif
            
            call SetUnitX(u[PATH_TYPE_FLYABILITY],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_FLYABILITY],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_AMPHIBIOUS],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_AMPHIBIOUS],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_BUILDABILITY],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_BUILDABILITY],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_WALKABILITY],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_WALKABILITY],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_FLOATABILITY],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_FLOATABILITY],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_BLIGHT],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_BLIGHT],WorldBounds.minY)
            
            call SetUnitX(u[PATH_TYPE_FLYABILITY+6],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_FLYABILITY+6],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_AMPHIBIOUS+6],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_AMPHIBIOUS+6],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_BUILDABILITY+6],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_BUILDABILITY+6],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_WALKABILITY+6],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_WALKABILITY+6],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_FLOATABILITY+6],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_FLOATABILITY+6],WorldBounds.minY)
            call SetUnitX(u[PATH_TYPE_BLIGHT+6],WorldBounds.minX)
            call SetUnitY(u[PATH_TYPE_BLIGHT+6],WorldBounds.minY)
            
            set p=null
        endmethod
    endmodule
    private struct I extends array
        implement N
    endstruct
endlibrary
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Varine Varine:
    How can you tell the difference between real traffic and indexing or AI generation bots?
  • The Helper The Helper:
    The bots will show up as users online in the forum software but they do not show up in my stats tracking. I am sure there are bots in the stats but the way alot of the bots treat the site do not show up on the stats
  • Varine Varine:
    I want to build a filtration system for my 3d printer, and that shit is so much more complicated than I thought it would be
  • Varine Varine:
    Apparently ABS emits styrene particulates which can be like .2 micrometers, which idk if the VOC detectors I have can even catch that
  • Varine Varine:
    Anyway I need to get some of those sensors and two air pressure sensors installed before an after the filters, which I need to figure out how to calculate the necessary pressure for and I have yet to find anything that tells me how to actually do that, just the cfm ratings
  • Varine Varine:
    And then I have to set up an arduino board to read those sensors, which I also don't know very much about but I have a whole bunch of crash course things for that
  • Varine Varine:
    These sensors are also a lot more than I thought they would be. Like 5 to 10 each, idk why but I assumed they would be like 2 dollars
  • Varine Varine:
    Another issue I'm learning is that a lot of the air quality sensors don't work at very high ambient temperatures. I'm planning on heating this enclosure to like 60C or so, and that's the upper limit of their functionality
  • Varine Varine:
    Although I don't know if I need to actually actively heat it or just let the plate and hotend bring the ambient temp to whatever it will, but even then I need to figure out an exfiltration for hot air. I think I kind of know what to do but it's still fucking confusing
  • The Helper The Helper:
    Maybe you could find some of that information from AC tech - like how they detect freon and such
  • Varine Varine:
    That's mostly what I've been looking at
  • Varine Varine:
    I don't think I'm dealing with quite the same pressures though, at the very least its a significantly smaller system. For the time being I'm just going to put together a quick scrubby box though and hope it works good enough to not make my house toxic
  • Varine Varine:
    I mean I don't use this enough to pose any significant danger I don't think, but I would still rather not be throwing styrene all over the air
  • The Helper The Helper:
    New dessert added to recipes Southern Pecan Praline Cake https://www.thehelper.net/threads/recipe-southern-pecan-praline-cake.193555/
  • The Helper The Helper:
    Another bot invasion 493 members online most of them bots that do not show up on stats
  • Varine Varine:
    I'm looking at a solid 378 guests, but 3 members. Of which two are me and VSNES. The third is unlisted, which makes me think its a ghost.
    +1
  • The Helper The Helper:
    Some members choose invisibility mode
    +1
  • The Helper The Helper:
    I bitch about Xenforo sometimes but it really is full featured you just have to really know what you are doing to get the most out of it.
  • The Helper The Helper:
    It is just not easy to fix styles and customize but it definitely can be done
  • The Helper The Helper:
    I do know this - xenforo dropped the ball by not keeping the vbulletin reputation comments as a feature. The loss of the Reputation comments data when we switched to Xenforo really was the death knell for the site when it came to all the users that left. I know I missed it so much and I got way less interested in the site when that feature was gone and I run the site.
  • Blackveiled Blackveiled:
    People love rep, lol
    +1
  • The Helper The Helper:
    The recipe today is Sloppy Joe Casserole - one of my faves LOL https://www.thehelper.net/threads/sloppy-joe-casserole-with-manwich.193585/
  • The Helper The Helper:
    Decided to put up a healthier type recipe to mix it up - Honey Garlic Shrimp Stir-Fry https://www.thehelper.net/threads/recipe-honey-garlic-shrimp-stir-fry.193595/

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top