Azlier
Old World Ghost
- Reaction score
- 461
Well, you know those pathing blockers everybody loves right? This little script takes all of the preplaced ones and removes them, but leaves the pathing just as you wanted it.
That way, your handle count is lowered and the computer doesn't need to use CPU to take care of those destructables that you probably won't ever touch.
Also, you can create some artificial pathing blockers dynamically with these functions. Artificial pathing blockers don't even exist, so destroying them isn't all that possible.
That way, your handle count is lowered and the computer doesn't need to use CPU to take care of those destructables that you probably won't ever touch.
Also, you can create some artificial pathing blockers dynamically with these functions. Artificial pathing blockers don't even exist, so destroying them isn't all that possible.
JASS:
CreateWalkabilityBlocker takes real x, y, boolean walkable
//Creates a 64x64 pathing blocker that turns whether you can walk there on or off.
CreateFlyabilityBlocker takes real x, y, boolean walkable
//Creates a 64x64 pathing blocker that turns whether you can fly there on or off.
CreateMoveabilityBlocker takes real x, y, boolean moveable
//Creates a 64x64 pathing blocker that turns whether you can move there on or off.
CreateLargeWalkabilityBlocker takes real x, y, boolean walkable
//Creates a 128x128 pathing blocker that turns whether you can walk there on or off.
CreateLargeFlyabilityBlocker takes real x, y, boolean walkable
//Creates a 128x128 pathing blocker that turns whether you can fly there on or off.
CreateLargeMoveabilityBlocker takes real x, y, boolean moveable
//Creates a 128x128 pathing blocker that turns whether you can move there on or off.
JASS:
library APB initializer Init
// ** ! ** READ ME ** ! **
//These ObjectMerger commands will create walkable pathing blockers.
//! external ObjectMerger w3b YTpb YTwb bnam "Pathing Blocker (Walkable)" bwal 1 bptx "PathTextures\2x2Unbuildable.tga"
//! external ObjectMerger w3b YTpc YTwc bnam "Pathing Blocker (Walkable) (Large)" bwal 1 bptx "PathTextures\4x4Unbuildable.tga"
//Save the map with this, close the map, and open it again. Delete the ObjectMerger calls, and save again.
globals
private constant integer UNWALKABLE = 039;YTpb039;
private constant integer UNWALKABLE_LARGE = 039;YTpc039;
private constant integer UNFLYABLE = 039;YTab039;
private constant integer UNFLYABLE_LARGE = 039;YTac039;
private constant integer NO_MOVEMENT = 039;YTfb039;
private constant integer NO_MOVEMENT_LARGE = 039;YTfc039;
private constant integer WALKABLE = 039;YTwb039;
private constant integer WALKABLE_LARGE = 039;YTwc039;
endglobals
function CreateWalkabilityBlocker takes real x, real y, boolean walkable returns nothing
call SetTerrainPathable(x, y, PATHING_TYPE_WALKABILITY, walkable)
endfunction
function CreateFlyabilityBlocker takes real x, real y, boolean flyable returns nothing
call SetTerrainPathable(x, y, PATHING_TYPE_FLYABILITY, flyable)
endfunction
function CreateMoveabilityBlocker takes real x, real y, boolean moveable returns nothing
call CreateWalkabilityBlocker(x, y, moveable)
call CreateFlyabilityBlocker(x, y, moveable)
endfunction
function CreateLargeWalkabilityBlocker takes real x, real y, boolean walkable returns nothing
call CreateWalkabilityBlocker(x + 16, y + 16, walkable)
call CreateWalkabilityBlocker(x - 16, y - 16, walkable)
call CreateWalkabilityBlocker(x + 16, y - 16, walkable)
call CreateWalkabilityBlocker(x - 16, y + 16, walkable)
endfunction
function CreateLargeFlyabilityBlocker takes real x, real y, boolean flyable returns nothing
call CreateFlyabilityBlocker(x + 16, y + 16, flyable)
call CreateFlyabilityBlocker(x - 16, y - 16, flyable)
call CreateFlyabilityBlocker(x + 16, y - 16, flyable)
call CreateFlyabilityBlocker(x - 16, y + 16, flyable)
endfunction
function CreateLargeMoveabilityBlocker takes real x, real y, boolean moveable returns nothing
call CreateWalkabilityBlocker(x + 16, y + 16, moveable)
call CreateWalkabilityBlocker(x - 16, y - 16, moveable)
call CreateWalkabilityBlocker(x + 16, y - 16, moveable)
call CreateWalkabilityBlocker(x - 16, y + 16, moveable)
call CreateFlyabilityBlocker(x + 16, y + 16, moveable)
call CreateFlyabilityBlocker(x - 16, y - 16, moveable)
call CreateFlyabilityBlocker(x + 16, y - 16, moveable)
call CreateFlyabilityBlocker(x - 16, y + 16, moveable)
endfunction
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
call SetTerrainPathable(GetWidgetX(d), GetWidgetY(d), 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 RemoveDestructable(d)
elseif i == UNFLYABLE then
call SetTerrainPathable(GetWidgetX(d), GetWidgetY(d), PATHING_TYPE_FLYABILITY, false)
call RemoveDestructable(d)
elseif i == UNFLYABLE_LARGE then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x + 16, y + 16, PATHING_TYPE_FLYABILITY, false)
call SetTerrainPathable(x - 16, y - 16, PATHING_TYPE_FLYABILITY, false)
call SetTerrainPathable(x + 16, y - 16, PATHING_TYPE_FLYABILITY, false)
call SetTerrainPathable(x - 16, y + 16, PATHING_TYPE_FLYABILITY, false)
call RemoveDestructable(d)
elseif i == WALKABLE then
call SetTerrainPathable(GetWidgetX(d), GetWidgetY(d), PATHING_TYPE_WALKABILITY, true)
call RemoveDestructable(d)
elseif i == WALKABLE_LARGE then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x + 16, y + 16, PATHING_TYPE_WALKABILITY, true)
call SetTerrainPathable(x - 16, y - 16, PATHING_TYPE_WALKABILITY, true)
call SetTerrainPathable(x + 16, y - 16, PATHING_TYPE_WALKABILITY, true)
call SetTerrainPathable(x - 16, y + 16, PATHING_TYPE_WALKABILITY, true)
call RemoveDestructable(d)
elseif i == NO_MOVEMENT then
set x = GetWidgetX(d)
set y = GetWidgetY(d)
call SetTerrainPathable(x, y, PATHING_TYPE_WALKABILITY, false)
call SetTerrainPathable(x, y, PATHING_TYPE_FLYABILITY, false)
call RemoveDestructable(d)
elseif i == NO_MOVEMENT_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 + 16, y + 16, PATHING_TYPE_FLYABILITY, false)
call SetTerrainPathable(x - 16, y - 16, PATHING_TYPE_FLYABILITY, false)
call SetTerrainPathable(x + 16, y - 16, PATHING_TYPE_FLYABILITY, false)
call SetTerrainPathable(x - 16, y + 16, PATHING_TYPE_FLYABILITY, false)
call RemoveDestructable(d)
endif
set d = null
return false
endfunction
private function Init takes nothing returns nothing
local rect r = GetWorldBounds()
call EnumDestructablesInRect(r, Filter(function Replace), null)
call DestroyBoolExpr(Filter(function Replace))
call RemoveRect(r)
set r = null
endfunction
endlibrary