function DHOTAction takes nothing returns nothing
// Required Locals
local timer t = GetExpiredTimer()
local integer i = GetHandleId(t)
local unit caster = LoadUnitHandle(udg_Hash, i, 0)
local unit target = LoadUnitHandle(udg_Hash, i, 1)
local integer times = LoadInteger(udg_Hash, i, 2)
local real amount = LoadReal(udg_Hash, i, 3)
local integer count = LoadInteger(udg_Hash, i, 4)+1
local real life = GetUnitState(caster, UNIT_STATE_LIFE)
local real maxlife = GetUnitState(caster, UNIT_STATE_MAX_LIFE)
local texttag ctt = CreateTextTag()
local texttag ttt = CreateTextTag()
local real dir = 90*bj_DEGTORAD
// If Target is Alive
if GetUnitState(target, UNIT_STATE_LIFE) > 0 then
call BJDebugMsg("Target is Alive")
// Deal Damage
call UnitDamageTarget(caster, target, amount, true, false, ATTACK_TYPE_MAGIC, DAMAGE_TYPE_NORMAL, WEAPON_TYPE_WHOKNOWS)
call BJDebugMsg("Damage Dealt")
// The Floating Text
call SetTextTagPermanent(ttt, false)
call SetTextTagText(ttt, "-" + SubString(R2S(udg_GDD_Damage), 0, StringLength(R2S(udg_GDD_Damage))-4), 0.028)
call SetTextTagPos(ttt, GetUnitX(target), GetUnitY(target), 0)
call SetTextTagColor(ttt, 255, 0, 0, 255)
call SetTextTagVelocity(ttt, 0.035*Cos(dir), 0.035*Sin(dir))
call SetTextTagLifespan(ttt, 2)
call SetTextTagFadepoint(ttt, 1)
// Do the Heal
if life >= maxlife then
set life = maxlife
endif
// The Floating Text
call SetUnitState(caster, UNIT_STATE_LIFE, life+amount)
call BJDebugMsg("Caster Healed")
call SetTextTagPermanent(ctt, false)
call SetTextTagText(ctt, "+" + SubString(R2S(amount), 0, StringLength(R2S(amount))-4), 0.028)
call SetTextTagPos(ctt, GetUnitX(caster), GetUnitY(caster), 0)
call SetTextTagColor(ctt, 0, 255, 0, 255)
call SetTextTagVelocity(ctt, 0.035*Cos(dir), 0.035*Sin(dir))
call SetTextTagLifespan(ctt, 2)
call SetTextTagFadepoint(ctt, 1)
// Save increased Count
call SaveInteger(udg_Hash, i, 4, count)
call BJDebugMsg("Count is: " + I2S(count))
else
// This stops the effect if the target is dead
set count = times
endif
// The actual Effect Stop
if count >= times then
call BJDebugMsg("Timer Stopped and Destroyed")
call PauseTimer(t)
call FlushChildHashtable(udg_Hash, i)
call DestroyTimer(t)
endif
// Clean Leaks
set t = null
set caster = null
set target = null
set ctt = null
set ttt = null
endfunction
function DHOTSet takes unit caster, unit target, integer count, real time, real amount returns nothing
local timer t = CreateTimer()
local integer i = GetHandleId(t)
call TimerStart(t, time, true, function DHOTAction)
call SaveUnitHandle(udg_Hash, i, 0, caster)
call SaveUnitHandle(udg_Hash, i, 1, target)
call SaveInteger(udg_Hash, i, 2, count)
call SaveReal(udg_Hash, i, 3, amount)
set t = null
endfunction