• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

IsWalkabilityOff 1.3

Why?
The native IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY) excludes destructible and building pathing
This library contains two distinct functions for detecting if pathing type walkability is off that includes destructible and building pathing

API
function IsWalkabilityOff takes real x, real y returns boolean

Checks if walkability is off at certain xy, including units

function IsTerrainWalkabilityOff takes real x, real y returns boolean
Checks if walkability is off at certain cell containing xy, excluding units
NOTE: Requires other players to have SHARED_CONTROL_WALK_PLAYER towards WALK_PLAYER to exclude units. This is handled by the library at map init, though if overwritten it will stop excluding units. In short, only use set aspect of alliance towards WALK_PLAYER and dont turn off ALLIANCE_SHARED_CONTROL towards WALK_PLAYER

Story
This library is the result of me trying to find the fastest and most efficient method for detecting walkability by comparing existing methods

JASS
JASS:
library IsWalkabilityOff//by Duckfarter

    /*    Configuration
        ¯¯¯¯¯¯¯¯¯¯¯¯¯    */
    globals
        private constant integer WALK_CHECKER  = 'iWO0'
        private constant integer WALK_CHECK  = 'iWO1'
        private constant integer WALK_CHECK_TERRAIN = 'iWO2'
        private constant player  WALK_PLAYER  = Player(PLAYER_NEUTRAL_PASSIVE)
        private constant boolean SHARED_CONTROL_WALK_PLAYER = true
    endglobals
/*
                    IsWalkabilityOff 1.3
                    ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯
        Description:
        ¯¯¯¯¯¯¯¯¯¯¯¯
            Contains two distinct functions for detecting if pathing type walkability is off that includes
            destructible and building pathing

        API:
        ¯¯¯¯
            1. Used for checking if walkability is off at certain xy, including units

                | function IsWalkabilityOff takes real x, real y returns boolean

            2. Used for checking if walkability is off at certain cell containing xy, excluding units

                | function IsTerrainWalkabilityOff takes real x, real y returns boolean
               
                NOTE: Requires other players to have SHARED_CONTROL_WALK_PLAYER towards WALK_PLAYER to
                exclude units. This is handled by the system at map init, though if overwritten it will stop
                excluding units. In short, only use set aspect of alliance towards WALK_PLAYER and dont turn
                off ALLIANCE_SHARED_CONTROL towards WALK_PLAYER.

        How to import:
        ¯¯¯¯¯¯¯¯¯¯¯¯¯¯
            1. Copy units WalkCheck ID: iWO1, WalkCheckTerrain ID: iWO2 and WalkChecker ID: iWO0
            2. Copy category/trigger IsWalkabilityOff 1.3

        Credits:
        ¯¯¯¯¯¯¯¯
            - Kazeon for PathingLib which this library is based on.

        Link:
        ¯¯¯¯¯
            https://www.hiveworkshop.com/threads/iswalkabilityoff-1-3.354129/
*/
    globals
        private unit walkChecker
    endglobals

    function IsWalkabilityOff takes real x, real y returns boolean
        return IssueBuildOrderById(walkChecker, WALK_CHECK, x, y)
    endfunction

    function IsTerrainWalkabilityOff takes real x, real y returns boolean
        return IssueBuildOrderById(walkChecker, WALK_CHECK_TERRAIN, x, y)
    endfunction

    private function SharedControlWalkPlayer takes nothing returns nothing
        call SetPlayerAllianceBJ(GetEnumPlayer(), ALLIANCE_SHARED_CONTROL, true, WALK_PLAYER)
    endfunction

    private module Init
        private static method onInit takes nothing returns nothing
            call init()
        endmethod
    endmodule

    private struct InitStruct extends array
        private static method init takes nothing returns nothing
            set walkChecker = CreateUnit(WALK_PLAYER, WALK_CHECKER, 0, 0, 0)
            call BlzPauseUnitEx(walkChecker, true)
            call ShowUnit(walkChecker, false)
            if SHARED_CONTROL_WALK_PLAYER then
                call ForForce(GetPlayersAll(), function SharedControlWalkPlayer)
            endif
        endmethod
        implement Init
    endstruct

endlibrary
07-07-2024
Version 1.0: Released
XX-07-2024
Version 1.1: Changed description, added more demo, made units non-hero, other miscellaneous changes
17-07-2024
Version 1.2: Simplified demo triggers
11-05-2025
Version 1.3: Reworked description to be more informative
Credits:
Kazeon for PathingLib which this library is based on
Keywords:
check, detect, walkability, walkable, pathing, pathability, terrain, off
Previews
Contents

IsWalkabilityOff 1.3 (Map)

Reviews
Antares
Simple and working as intended. Approved
Level 24
Joined
Feb 27, 2019
Messages
835
What does this do differently than IsTerrainPathable or your other library?
IsTerrainPathable is a native that doesnt always return correct values because it doesnt consider all destructible, buildings or unit pathing. It is a shown unreliable native that spawned the likes of Rising_Dusk's IsTerrainPathable, Anitarf and Vexorian IsTerrainPathable, Nestharus' IsPathable, PathingLib and PurgeandFire's CheckWalkability.

This system can use that native to an advantage, but is not the only one that can, by inverting how it checks for pathing it can use the native to narrow the search. Simply, the native is fast so if it can be used its good. This system is best compared to PathingLib since is uses the same method but inverted and with a few more quirks.

My other resource is practically unrelated to this one. They are totally seperate.
 
IsTerrainPathable is a native that doesnt always return correct values because it doesnt consider all destructible, buildings or unit pathing. It is a shown unreliable native that spawned the likes of Rising_Dusk's IsTerrainPathable, Anitarf and Vexorian IsTerrainPathable, Nestharus' IsPathable, PathingLib and PurgeandFire's CheckWalkability.
I see. Good to know, thanks. Make sure to add this to your description (see our resource submission rules regarding descriptions).
 
Level 24
Joined
Feb 27, 2019
Messages
835
Okay really though how much faster is it? Because as it stands this really looks like it should be a pr for the pathing lib
Haha sorry for the weird reply before I dont know how that happened XD I guess I was trying to respond yesterday. Anyway, the reason this system and the inverted method is faster is twofold. This method of checking pathability by trying to issue a build order is much faster if the result is false. By inverting this system the result is false when the path is walkable and I believe walkable paths are more commonly checked than unwalkable paths. Secondly, thanks to BlzPauseEx and Limit construction of units, its 6.5x faster to check for with this system unwalkable paths, but PathingLib could add this method and make its walkable paths 6.5x faster to check as well. Remember the mentioned paths are the ones that are slow to check. Thirdly, it can exclude player units thanks to adding a pathing map to one of the units built and sharing control with the WALK_PLAYER to exclude that player from the search, which is the size of a cell, which is also very useful for systems like Bresenham Pathchecker since their method is built on checking a cell at a time. A pathing map on a built unit on a walkable path would cause a unit to move out of the way, but that doesnt happen with unwalkable paths. So I intentionally limited this system in an inverted way. What does PR mean, part? Maybe, but it hasnt happened yet.
 
Level 6
Joined
May 29, 2013
Messages
139
I applied this system to my map and it doesn't work. I set the objectid, I set the unit exactly the same as your demo trigger.
I suspected that an existing trigger in my map was causing error, so I tried deleting all other triggers, but that didn't work either. Do gameplay constants or other settings affect whether this system works or not?
 
Level 24
Joined
Feb 27, 2019
Messages
835
I applied this system to my map and it doesn't work. I set the objectid, I set the unit exactly the same as your demo trigger.
I suspected that an existing trigger in my map was causing error, so I tried deleting all other triggers, but that didn't work either. Do gameplay constants or other settings affect whether this system works or not?
There are no gameplay constants or other settings that are required for this system to work. I cant imagine any gameplay constant or setting that would cause any issues either. What I do know is that for the function IsTerrainWalkabilityOff to work, it requires that all players have shared control towards neutral passive which is handled automatically by the system.

The function IsWalkabilityOff() takes unit collision into consideration. That means that if the starting co-ordinates are on top of a unit with collision it will return true as in walkability is off.
Did you try both the function IsWalkabilityOff and IsTerrainWalkabilityOff?

Could you per heaps show me how you are using this system in a trigger?
 
The IsWalkabilityOff library is clean and works as intended.

You have packaged the IsPathWalkable function with the test map. As far as I can tell, this is its own stand-alone system (that is based on someone else's library, but you modified). You can package those in the same resource or upload them separately - that's up to you. But it shouldn't be in the Demo section, because it's its own system and not for demo purposes.

The demo triggers are quite byzantine. They add unnecessary confusion to what should be a simple-to-use library. Why is this not a simple if IsWalkabilityOff(x, y) then print X else print Y endif?. Please clean them up a bit.

The Knight trigger message shows the inverse of what it should show.

Awaiting Update
 
Level 24
Joined
Feb 27, 2019
Messages
835
The IsWalkabilityOff library is clean and works as intended.

You have packaged the IsPathWalkable function with the test map. As far as I can tell, this is its own stand-alone system (that is based on someone else's library, but you modified). You can package those in the same resource or upload them separately - that's up to you. But it shouldn't be in the Demo section, because it's its own system and not for demo purposes.

The demo triggers are quite byzantine. They add unnecessary confusion to what should be a simple-to-use library. Why is this not a simple if IsWalkabilityOff(x, y) then print X else print Y endif?. Please clean them up a bit.

The Knight trigger message shows the inverse of what it should show.

Awaiting Update
Makes sense. Thank you.
 
Top