- Joined
- Jul 26, 2008
- Messages
- 1,009
My last post title was a little vague and yielded results with no definite explanation for me to apply the answers to.
I'm doin this for a timer that detects when a unit is in battle by placing them in a group when they deal damage and then removes the unit from the group when it is no longer in battle.
Anyways, what I'm trying to do now is get the timer I create to be reset, instead of creating a new timer :X I don't know how to access the timer once it's created though, so I can't pause it.
Any tips, help or suggestions is appreciated.
A note I'm using a damage detection system that's custom. Don't mind it, I doubt it's impacting the timer and it's actions in a way that would solve this issue.
Here is the inBattle detection system:
I'm doin this for a timer that detects when a unit is in battle by placing them in a group when they deal damage and then removes the unit from the group when it is no longer in battle.
Anyways, what I'm trying to do now is get the timer I create to be reset, instead of creating a new timer :X I don't know how to access the timer once it's created though, so I can't pause it.
Any tips, help or suggestions is appreciated.
A note I'm using a damage detection system that's custom. Don't mind it, I doubt it's impacting the timer and it's actions in a way that would solve this issue.
Here is the inBattle detection system:
JASS:
scope InBattleDetector initializer Init
globals
group inBattle
endglobals
private struct Data
unit c
unit d
static method create takes unit battler, unit hurtingbattler returns Data
local Data D = Data.allocate()
set D.c = battler
set D.d = hurtingbattler
return D
endmethod
endstruct
private function Timer takes nothing returns nothing
local timer tim = GetExpiredTimer()
local Data D = Data(GetTimerData(tim))
call GroupRemoveUnit(inBattle, D.c)
call GroupRemoveUnit(inBattle, D.d)
call ReleaseTimer(tim)
call D.destroy()
endfunction
private function Conditions takes nothing returns boolean
local timer tim = NewTimer()
local real d = GetEventDamage()
local Data D = Data.create(GetTriggerUnit(), GetEventDamageSource())
set inBattle = CreateGroup()
if d > 0 then
call GroupAddUnit(inBattle, D.c)
call GroupAddUnit(inBattle, D.d)
call SetTimerData(tim,D)
call TimerStart(tim, 3.0, false, function Timer)
endif
return false
endfunction
private function Init takes nothing returns nothing
call AddDamageCondition(Condition(function Conditions))
endfunction
endscope