library WaterPathing
globals
hashtable WP_Hash = InitHashtable()
endglobals
function WP_Add_Pathing takes location p, real radius returns nothing
local real centerX = GetLocationX(p)
local real centerY = GetLocationY(p)
local real stepsX = radius / 16 // Calculate how many steps are needed based on radius
local real stepsY = radius / 16
local real currentX = centerX - radius
local real currentY
local integer waterCount = 0
local integer x = 0
local integer y = 0
// For debugging:
//local effect sfx
loop
exitwhen currentX > centerX + radius
set currentY = centerY - radius
loop
exitwhen currentY > centerY + radius
// For debugging:
//set sfx = AddSpecialEffect("Abilities\\Spells\\Undead\\AbsorbMana\\AbsorbManaBirthMissile.mdl", currentX, currentY)
//call BlzSetSpecialEffectScale(sfx, 0.4)
set x = R2I(currentX)
set y = R2I(currentY)
set waterCount = LoadInteger(WP_Hash, x, y)
call SaveInteger(WP_Hash, x, y, waterCount + 1)
// Add pathing if this is the first instance of this pathing at the given coordinates
if (waterCount == 0) then
call SetTerrainPathable(currentX, currentY, PATHING_TYPE_FLOATABILITY, true)
endif
set currentY = currentY + 16.0
endloop
set currentX = currentX + 16.0
endloop
endfunction
function WP_Remove_Pathing takes location p, real radius returns nothing
local real centerX = GetLocationX(p)
local real centerY = GetLocationY(p)
local real stepsX = radius / 16 // Calculate how many steps are needed based on radius
local real stepsY = radius / 16
local real currentX = centerX - radius
local real currentY
local integer waterCount = 0
local integer x = 0
local integer y = 0
loop
exitwhen currentX > centerX + radius
set currentY = centerY - radius
loop
exitwhen currentY > centerY + radius
set x = R2I(currentX)
set y = R2I(currentY)
set waterCount = LoadInteger(WP_Hash, x, y)
call SaveInteger(WP_Hash, x, y, waterCount - 1)
// Remove pathing if this is the last instance of this pathing at the given coordinates
if (waterCount == 1) then
call SetTerrainPathable(currentX, currentY, PATHING_TYPE_FLOATABILITY, false)
endif
set currentY = currentY + 16.0
endloop
set currentX = currentX + 16.0
endloop
endfunction
endlibrary