[JASS] Pathability Check fails on new patch

Status
Not open for further replies.
Level 19
Joined
Oct 29, 2007
Messages
1,184
[SOLVED]

I'm using the pathability check by rising_dusk in my mod, but after I downloaded the new patch it seems to make my map unplayable. Is there a way to make the system work with the new patch, or maybe another pathability check system that works with the new path I could use? Only ground pathing is important. Thanks for helping.

System code:

JASS:
library TerrainPathability initializer Initialization
globals
    
    constant integer TERRAIN_PATHING_DEEP                           = 1
    constant integer TERRAIN_PATHING_SHALLOW                        = 2
    constant integer TERRAIN_PATHING_LAND                           = 3
    constant integer TERRAIN_PATHING_WALKABLE                       = 4
    
    private unit Dummy                                              = null
    private constant integer DUMMY_UNIT_ID                          = 'h00C'
    private constant integer DUMMY_WINDWALK_ID                      = 'A004'
    private constant player OWNING_PLAYER                           = Player(15)
    
    private real WorldMinX                                          = 0.
    private real WorldMinY                                          = 0.
    
endglobals


function IsTerrainPathingType takes real x, real y, integer terrainPathingType returns boolean
    local boolean b = false
    if terrainPathingType == TERRAIN_PATHING_DEEP then
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    elseif terrainPathingType == TERRAIN_PATHING_SHALLOW then
        return not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    elseif terrainPathingType == TERRAIN_PATHING_LAND then
        return IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
    elseif terrainPathingType == TERRAIN_PATHING_WALKABLE then
        call SetUnitPosition(Dummy, x, y)
        set b = GetUnitX(Dummy) == x and GetUnitY(Dummy) == y and not (not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY))
        call SetUnitX(Dummy, WorldMinX)
        call SetUnitY(Dummy, WorldMinY)
    endif
    return b
endfunction

private function Initialization takes nothing returns nothing
    local rect r = GetWorldBounds()
    
    set WorldMinX = GetRectMinX(r)
    set WorldMinY = GetRectMinY(r)
    set Dummy = CreateUnit(OWNING_PLAYER, DUMMY_UNIT_ID, 0., 0., 0.)
    call UnitAddAbility(Dummy, DUMMY_WINDWALK_ID)
    call UnitAddAbility(Dummy, 'Avul')
    call IssueImmediateOrderById(Dummy, 852129)
    call SetUnitX(Dummy, WorldMinX)
    call SetUnitY(Dummy, WorldMinY)
    
    call RemoveRect(r)
    set r = null
endfunction
endlibrary
 
Last edited:
Level 8
Joined
Aug 4, 2006
Messages
357
Apparently the new patch causes problems with returns inside if/else statements. Just change the IsTerrainPathingType function to this (should work but I haven't tested it):

JASS:
function IsTerrainPathingType takes real x, real y, integer terrainPathingType returns boolean
    local boolean b = false
    if terrainPathingType == TERRAIN_PATHING_DEEP then
        set b = not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    elseif terrainPathingType == TERRAIN_PATHING_SHALLOW then
        set b = not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and not IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY)
    elseif terrainPathingType == TERRAIN_PATHING_LAND then
        set b = IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY)
    elseif terrainPathingType == TERRAIN_PATHING_WALKABLE then
        call SetUnitPosition(Dummy, x, y)
        set b = GetUnitX(Dummy) == x and GetUnitY(Dummy) == y and not (not IsTerrainPathable(x, y, PATHING_TYPE_FLOATABILITY) and IsTerrainPathable(x, y, PATHING_TYPE_WALKABILITY))
        call SetUnitX(Dummy, WorldMinX)
        call SetUnitY(Dummy, WorldMinY)
    endif
    return b
endfunction

Edit: Turns out Rising_Dusk updated it for 1.24, doing exactly as I did above: Terrain Pathability
 
Status
Not open for further replies.
Top