library APB initializer init
globals
private constant integer UNWALKABLE = 'YTpb'
private constant integer UNWALKABLE_LARGE = 'YTpc'
private constant integer UNWALKABLE_HORIZONTAL = 'B007'
private constant integer UNWALKABLE_VERTICAL = 'B008'
private constant integer UNWALKABLE_DIAGONAL1 = 'B006'
private constant integer UNWALKABLE_DIAGONAL2 = 'B009'
endglobals
private function Replace takes nothing returns boolean
local destructable d = GetFilterDestructable()
local integer i = GetDestructableTypeId(d)
local real x
local real y
if i == UNWALKABLE then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x-16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x-16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x+16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x+16, y-16, PATHING_TYPE_WALKABILITY, false)
call RemoveDestructable(d)
elseif i == UNWALKABLE_LARGE then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x -16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y+48, PATHING_TYPE_WALKABILITY, false)
call RemoveDestructable(d)
elseif i == UNWALKABLE_HORIZONTAL then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x -16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -80, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -80, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +80, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +80, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -112, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -112, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +112, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +112, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -144, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -144, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +144, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +144, y+16, PATHING_TYPE_WALKABILITY, false)
call RemoveDestructable(d)
elseif i == UNWALKABLE_VERTICAL then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x -16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y-80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y-112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y-144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+144, PATHING_TYPE_WALKABILITY, false)
call RemoveDestructable(d)
elseif i == UNWALKABLE_DIAGONAL1 then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x -16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y-80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -80, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -80, y-80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -112, y-112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -112, y-144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -144, y-112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -144, y-144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y+80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +80, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +80, y+80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +112, y+112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +112, y+144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +144, y+112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +144, y+144, PATHING_TYPE_WALKABILITY, false)
call RemoveDestructable(d)
elseif i == UNWALKABLE_DIAGONAL2 then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x -16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y-16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +16, y+16, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -48, y+80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -80, y+48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -80, y+80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -112, y+112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -112, y+144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -144, y+112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x -144, y+144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +48, y-80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +80, y-48, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +80, y-80, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +112, y-112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +112, y-144, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +144, y-112, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x +144, y-144, PATHING_TYPE_WALKABILITY, false)
call RemoveDestructable(d)
endif
set d = null
return false
endfunction
private function init takes nothing returns nothing
local rect r = GetWorldBounds()
local integer i = 0
call EnumDestructablesInRect(r, Filter(function Replace), null)
call DestroyBoolExpr(Filter(function Replace))
call RemoveRect(r)
set r = null
set initcheckerbool2 = true
endfunction
endlibrary