Name | Type | is_array | initial_value |
CB_angle | real | No | |
CB_attacked_loc | location | No | |
CB_attacker | unit | No | |
CB_attacking_loc | location | No | |
CB_BOOOM | boolean | No | |
CB_chance_to_knockback | integer | Yes | |
CB_defender | unit | No | |
CB_distance | real | No | |
CB_distance_setup | real | Yes | |
CB_group | group | No | |
CB_hash | hashtable | No | |
CB_temp_unit | unit | No | |
CB_temploc | location | No | |
CB_temploc_2 | location | No | |
CB_time | real | No | |
Center | location | No | |
GRUPOFelens | group | No | |
Leniador | unitcode | No | H000 |
mision | quest | No | |
MisionSasquatch | quest | No | |
objeto | itemcode | Yes | I001 |
Player_Camera_Bond | player | Yes | |
RW_Unidades | unit | No | |
Sasquatchbarril | item | No | ItemNull |
TRdummyh | unit | No | |
TRhash | hashtable | No | |
TRindexD | integer | No | |
TRindexN | integer | No | |
TRisEnabled | boolean | No | |
TRtimers | timer | Yes | |
TRtrig | trigger | No | |
Unit_Camera_Lock | unit | Yes | |
Unit_Pan_Location | location | Yes | |
Variabletextoini | texttag | No |
//TESH.scrollpos=0
//TESH.alwaysfold=0
//************************************************************************************************
//* ____ ___ ___ *
//* /_ _| _ \/ __/ Tree Revival System *
//* | || /\__ \ by Spinnaker *
//* |_||_|\_\___/ v1.2.3.1 *
//* *
//************************************************************************************************
//*********************************************************
//* Globals required
//*********************************************************
//* udg_TRtrig Trigger for handling the revive actions
//* udg_TRhash Hashtable for timer issues
//* udg_TRindexD Stores revival instances
//* udg_TRindexN Parameter for timers manipulation
//* udg_TRtimers Timer array variable for recycle issues
//* udg_TRdummyh Dummy harvester for IsDestructibleTree function
//* udg_TRisEnabled Boolean parameter for enabling/disabling the system
//*********************************************************
//* Important
//*********************************************************
// Note: Units which step on position of tree which is currently
// being resurrected may get stuck between trees in that area
//*********************************************************
//* Constant configurable functions
//*********************************************************
//* Rawdata of undead locust unit type
constant function TR_dummyhId takes nothing returns integer
return 'uloc'
endfunction
//* Rawdata of dummy ghoul harvest ability
constant function TR_harvestId takes nothing returns integer
return 'Ahrl'
endfunction
//* Harvest order ID
constant function TR_orderId takes nothing returns integer
return 852018
endfunction
//* Delay before tree gets resurrected
constant function TR_ReviveDelay takes nothing returns real
return 5.
endfunction
//* Tells if birth animation should be shown while resurrecting a tree
constant function TR_ShowAnimation takes nothing returns boolean
return true
endfunction
//*********************************************************
//* System itself
//*********************************************************
function TR_recycleTimer takes timer t returns nothing
debug if t == null then
debug call BJDebugMsg("Attempt to release a null timer")
else
call PauseTimer(t)
set udg_TRtimers[udg_TRindexN] = t
set udg_TRindexN = udg_TRindexN + 1
endif
endfunction
function TR_getTimer takes nothing returns timer
if 0 == udg_TRindexN then
return CreateTimer()
endif
set udg_TRindexN = udg_TRindexN - 1
return udg_TRtimers[udg_TRindexN]
endfunction
function TR_Callback takes nothing returns nothing
local destructable d = LoadDestructableHandle(udg_TRhash, 0, GetHandleId(GetExpiredTimer()))
call DestructableRestoreLife(d, GetDestructableMaxLife(d), TR_ShowAnimation())
call TR_recycleTimer(GetExpiredTimer())
set udg_TRindexD = udg_TRindexD - 1
if udg_TRindexD == 0 then
call FlushChildHashtable(udg_TRhash, 0)
endif
set d = null
endfunction
function TR_CallRevive takes nothing returns boolean
local timer t
if udg_TRisEnabled then
set t = TR_getTimer()
set udg_TRindexD = udg_TRindexD + 1
call SaveDestructableHandle(udg_TRhash, 0, GetHandleId(t), GetTriggerDestructable())
call TimerStart(t, TR_ReviveDelay(), false, function TR_Callback)
set t = null
endif
return false
endfunction
function TR_IsDestructableTree takes destructable dest returns boolean
return IssueTargetOrderById(udg_TRdummyh, TR_orderId(), dest)
endfunction
function TR_AddTree takes nothing returns nothing
if TR_IsDestructableTree(GetEnumDestructable()) then
call TriggerRegisterDeathEvent(udg_TRtrig, GetEnumDestructable())
endif
endfunction
//***************************************************************************
function InitTrig_TreeRevival takes nothing returns nothing
set udg_TRtrig = CreateTrigger()
set udg_TRhash = InitHashtable()
//* By default enabled
set udg_TRisEnabled = true
//* Actions required for IsDestructibleTree function
set udg_TRdummyh = CreateUnit(Player(15), TR_dummyhId(), 0., 0., 0.)
call ShowUnit(udg_TRdummyh, false)
call UnitAddAbility(udg_TRdummyh, TR_harvestId())
call UnitRemoveAbility(udg_TRdummyh, 'Amov')
//* Revival setup
call EnumDestructablesInRect(bj_mapInitialPlayableArea, null, function TR_AddTree)
call TriggerAddCondition(udg_TRtrig, Condition(function TR_CallRevive))
endfunction