// ********************************************************
// * *
// * RECYCLING SYSTEM *
// * for AC, by Simplar Duoson *
// * aka bowser499 *
// * *
// ********************************************************
// Timer Recycling
function RS_GetRecycledTimer takes nothing returns timer
local integer timerIndex = LoadInteger(udg_E_RecycleHash,1,0)
if timerIndex == 0 then
call SaveTimerHandle(udg_E_RecycleHash,1,timerIndex,CreateTimer())
else
set timerIndex = timerIndex - 1
call SaveInteger(udg_E_RecycleHash,1,0,timerIndex)
endif
return LoadTimerHandle(udg_E_RecycleHash,1,timerIndex)
endfunction
function RS_RecycleTimer takes timer whichTimer returns nothing
local integer timerIndex = LoadInteger(udg_E_RecycleHash,1,0)
if whichTimer != null then
call PauseTimer(whichTimer)
call SaveTimerHandle(udg_E_RecycleHash,1,timerIndex,whichTimer)
call SaveInteger(udg_E_RecycleHash,1,0,timerIndex+1)
endif
endfunction
// Unit Recycling
function RS_PlaceRecycledUnit takes player unitOwner, integer unitType, real unitX, real unitY, real unitFacing returns unit
local integer unitIndex = LoadInteger(udg_E_RecycleHash,unitType,0)
local unit loadedUnit
if unitIndex == 0 then
call SaveUnitHandle(udg_E_RecycleHash,unitType,unitIndex,CreateUnit(unitOwner,unitType,unitX,unitY,unitFacing))
else
set unitIndex = unitIndex - 1
call SaveInteger(udg_E_RecycleHash,unitType,0,unitIndex)
set loadedUnit = LoadUnitHandle(udg_E_RecycleHash,unitType,unitIndex)
call SetUnitAnimation(loadedUnit,"stand")
call SetUnitX(loadedUnit,unitX)
call SetUnitY(loadedUnit,unitY)
call SetUnitFacing(loadedUnit,unitFacing)
set loadedUnit = null
endif
return LoadUnitHandle(udg_E_RecycleHash,unitType,unitIndex)
endfunction
function RS_RecycleUnit takes unit whichUnit returns nothing
local integer unitType = GetUnitTypeId(whichUnit)
local integer unitIndex = LoadInteger(udg_E_RecycleHash,unitType,0)
if whichUnit != null then
call SetUnitX(whichUnit,GetRectMinX(bj_mapInitialPlayableArea))
call SetUnitY(whichUnit,GetRectMinY(bj_mapInitialPlayableArea))
call SaveUnitHandle(udg_E_RecycleHash,unitType,unitIndex,whichUnit)
call SaveInteger(udg_E_RecycleHash,unitType,0,unitIndex+1)
endif
endfunction
// Timed Unit Recycling
function RS_RecycleUnitTimed_Timer takes nothing returns nothing
local timer timePasser = GetExpiredTimer()
local integer timePasserId = GetHandleId(timePasser)
local unit whichUnit = LoadUnitHandle(udg_E_RecycleHash,timePasserId,0)
call RS_RecycleUnit(whichUnit)
call FlushChildHashtable(udg_E_RecycleHash,timePasserId)
call RS_RecycleTimer(timePasser)
set timePasser = null
set whichUnit = null
endfunction
function RS_RecycleUnitTimed takes unit whichUnit, real timeBeforeRecycling returns nothing
local timer timePasser = RS_GetRecycledTimer()
local integer timePasserId = GetHandleId(timePasser)
call SaveUnitHandle(udg_E_RecycleHash,timePasserId,0,whichUnit)
call TimerStart(timePasser,timeBeforeRecycling,false,function RS_RecycleUnitTimed_Timer)
set timePasser = null
endfunction
function RS_RecycleUnitWithModel takes unit whichUnit, real deathAnimDuration returns nothing
call SetUnitAnimation(whichUnit,"death")
call RS_RecycleUnitTimed(whichUnit,deathAnimDuration)
endfunction
// Recycle Initialization
function RS_Initialization takes nothing returns nothing
set udg_E_RecycleHash = InitHashtable()
endfunction
Name | Type | is_array | initial_value |
E_RecycleHash | hashtable | No |