- Joined
- Jun 17, 2007
- Messages
- 1,433
A simple tree revival system.
Requirements:
TimerUtils, by Vexorian.
IsDestructableTree by PitzerMike
Code:
Requirements:
TimerUtils, by Vexorian.
IsDestructableTree by PitzerMike
Code:
JASS:
library TreeRevival initializer Init requires TimerUtils, DestructableLib
globals
//**Configuration***********************
private constant boolean BIRTH_ANIMATION = true
private constant real REVIVAL_TIME = 30.
endglobals
private function Conditions takes nothing returns boolean
return true
endfunction
//**************************************
globals
public trigger Trigger = CreateTrigger()
endglobals
private struct Data
destructable d
endstruct
private function Enum takes nothing returns nothing
call TriggerRegisterDeathEvent(Trigger, GetEnumDestructable())
endfunction
private function TreeFilter takes nothing returns boolean
return IsDestructableTree(GetFilterDestructable())
endfunction
private function ReviveTree takes nothing returns nothing
local timer t = GetExpiredTimer()
local Data d = GetTimerData(t)
call DestructableRestoreLife(d.d, GetDestructableMaxLife(d.d), BIRTH_ANIMATION)
call ReleaseTimer(t)
call d.destroy()
set t = null
endfunction
private function Actions takes nothing returns nothing
local timer t = NewTimer()
local Data d = Data.create()
set d.d = GetDyingDestructable()
call TimerStart(t, REVIVAL_TIME, false, function ReviveTree)
call SetTimerData(t, d)
set t = null
endfunction
private function Init takes nothing returns nothing
call EnumDestructablesInRect(bj_mapInitialPlayableArea, Filter(function TreeFilter), function Enum)
call TriggerAddAction(Trigger, function Actions)
call TriggerAddCondition(Trigger, Condition(function Conditions))
endfunction
endlibrary
Last edited: