Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
//************************************************************************************************
//* *
//* Tree Revival System *
//* by Spinnaker *
//* *
//************************************************************************************************
//*************************************************************************
//*
//* Globals required
//*
//*************************************************************************
//* udg_TreeRevivalTrig Trigger for handling the revive actions
//* udg_TRhash Hashtable for timer issues
//* udg_dummyh Dummy harvester for IsDestructibleTree function
//* Configurable function for delay before tree gets resurrected
constant function TreeReviveDelay takes nothing returns real
return 5.
endfunction
//* Tells if birth animation should be shown while resurrecting a tree
constant function TreeShowAnimation takes nothing returns boolean
return true
endfunction
//* System itself
function TrCallback takes nothing returns nothing
local timer t = GetExpiredTimer()
local destructable d = LoadDestructableHandle(udg_TRhash, GetHandleId(t), 0)
call DestructableRestoreLife(d, GetDestructableMaxLife(d), TreeShowAnimation())
call PauseTimer(t)
call DestroyTimer(t)
call FlushChildHashtable(udg_TRhash, GetHandleId(t))
set d = null
set t = null
endfunction
function CallTreeRevive takes nothing returns boolean
local timer t = CreateTimer()
call SaveDestructableHandle(udg_TRhash, GetHandleId(t), 0, GetTriggerDestructable())
call TimerStart(t, TreeReviveDelay(), false, function TrCallback)
set t = null
return false
endfunction
function IsDestructableTree takes destructable dest returns boolean
return IssueTargetOrderById(udg_dummyh, 852018, dest)
endfunction
function CallAddTree takes nothing returns nothing
if IsDestructableTree(GetEnumDestructable()) then
call TriggerRegisterDeathEvent(udg_TreeReviveTrig, GetEnumDestructable())
endif
endfunction
//***************************************************************************
function InitTrig_TreeRevive takes nothing returns nothing
set udg_TreeReviveTrig = CreateTrigger()
set udg_TRhash = InitHashtable()
//* Actions required for IsDestructibleTree function
set udg_dummyh = CreateUnit(Player(15), 'uloc', 0., 0., 0.)
call ShowUnit(udg_dummyh, false)
call UnitAddAbility(udg_dummyh, 'Ahrl')
call UnitRemoveAbility(udg_dummyh, 'Amov')
//* Revival setup
call EnumDestructablesInRect(bj_mapInitialPlayableArea, null, function CallAddTree)
call TriggerAddCondition(udg_TreeReviveTrig, Condition(function CallTreeRevive))
endfunction
function RegisterDestDeathInRegionEnum takes nothing returns nothing
set bj_destInRegionDiesCount = bj_destInRegionDiesCount + 1
if (bj_destInRegionDiesCount <= bj_MAX_DEST_IN_REGION_EVENTS) then
call TriggerRegisterDeathEvent(bj_destInRegionDiesTrig, GetEnumDestructable())
endif
endfunction
function TriggerRegisterDestDeathInRegionEvent takes trigger trig, rect r returns event
set bj_destInRegionDiesTrig = trig
set bj_destInRegionDiesCount = 0
call EnumDestructablesInRect(r, null, function RegisterDestDeathInRegionEnum)
return trig
endfunction
EnumDestructablesInRect works for more than 64.
OneSec Elapsed GT

Evénements


Temps - Elapsed game time is 1.00 seconds

Conditions

Actions


Destructible - Pick every destructible in (Entire map) and do (Actions)



Boucle - Actions




Déclencheur - Add to Respawn Tree <gen> the event (Destructible - (Picked destructible) dies)
Respawn Tree

Evénements

Conditions


(Destructible-type of (Dying destructible)) Egal à Mur d'arbres d'été

Actions


Wait 60.00 seconds


Destructible - Resurrect (Dying destructible) with (Max life of (Dying destructible)) life and Montrer birth animation
Bribe, everything what you say is fine although 64 limitation happens only if you register destructible death event while refering to given region.Well the issue with enumerating these destructables is that it only
counts 64 destructables. You'd want to divide the map into various
regions so that each region contains less than or equal to 64 trees.
@Vladadamm
Every single second you register a new event? Nice!
Only at the first second of game-time, not every seconds.