- Joined
- Oct 5, 2012
- Messages
- 67
So... I made an aos map, and thought it would be kinda funny if the trees would regrow at a random time spawn each (for example 1 to 8 seconds). Is this possible?
// In case you have JNGP uncomment this:
// globals
// hashtable udg_hashrev = InitHashtable()
// endglobals
function trigger2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local destructable dest = LoadDestructableHandle(udg_hashrev, GetHandleId(t), 0)
call DestructableRestoreLife(dest, 9999, true)
set dest = null
call DestroyTimer(t)
set t = null
endfunction
function trigger1 takes nothing returns boolean
local timer t = CreateTimer()
call SaveDestructableHandle(udg_hashrev, GetHandleId(t), 0, GetTriggerDestructable())
call TimerStart(t, GetRandomReal(4., 8.), false, function trigger2)
set t = null
return false
endfunction
//===========================================================================
function InitTrig_randomdest takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterDestDeathInRegionEvent(t, GetWorldBounds() )
call TriggerAddCondition( t, Condition(function trigger1))
endfunction