- Joined
- Feb 6, 2014
- Messages
- 2,466
I have a spell here that will damage the target unit after the delay. What is the equivalent code if I were to use Bribe's New Table
Furthermore, what do you recommend the TimerUtils to used? Should I used Vexorian's or Magtheridon's. Or should I use TimerTools?
Furthermore, what do you recommend the TimerUtils to used? Should I used Vexorian's or Magtheridon's. Or should I use TimerTools?
JASS:
scope DelayDamage initializer OnInit
globals
hashtable ht = InitHashtable()
endglobals
private function damageTarget takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit tgt = LoadUnitHandle(ht, GetHandleId(t), 0)
local unit u = LoadUnitHandle(ht, GetHandleId(t), 1)
call BJDebugMsg(GetUnitName(u) + " has delay damaged " + GetUnitName(tgt))
call UnitDamageTarget(u, tgt, 9000, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_MAGIC, WEAPON_TYPE_WHOKNOWS)
call FlushChildHashtable(ht, GetHandleId(t))
call ReleaseTimer(t)
set t = null
set u = null
set tgt = null
endfunction
private function Casted takes nothing returns boolean
local unit u
local unit tgt
local timer t
if (GetSpellAbilityId() == 'AHtb') then
set u = GetTriggerUnit()
set tgt = GetSpellTargetUnit()
set t = NewTimer()
call BJDebugMsg(GetUnitName(u) + " has casted storm bolt on " + GetUnitName(tgt))
call SaveUnitHandle(ht, GetHandleId(t), 0, tgt)
call SaveUnitHandle(ht, GetHandleId(t), 1, u)
call TimerStart(t, 2., false, function damageTarget)
set u = null
set tgt = null
endif
return false
endfunction
//===========================================================================
private function OnInit takes nothing returns nothing
local trigger t = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition(t, Condition( function Casted ) )
set t = null
endfunction
endscope