library DDSys
globals
private constant hashtable HASH = InitHashtable()
private constant trigger TRIG = CreateTrigger()
endglobals
function DamageRegister takes nothing returns nothing
local unit u = GetTriggerUnit()
local real damtaken = GetEventDamage()
local texttag tag = CreateTextTag()
call SetTextTagPos(tag, GetUnitX(u), GetUnitY(u), 90)
call SetTextTagText(tag, I2S(R2I(damtaken)), 0.025)
call SetTextTagPermanent(tag, false)
call SetTextTagVelocity(tag, 0.04, 0.04)
call SetTextTagLifespan(tag, 3)
call SetTextTagFadepoint(tag, 0.01)
set u = null
set tag = null
endfunction
function TakesDamage takes unit u returns nothing
local integer ID = GetHandleId(u)
if not HaveSavedBoolean(HASH, ID, 1) then
//this is used only ONE TIME per unit
call SaveBoolean(HASH, ID, 1, true)
call TriggerRegisterUnitEvent(TRIG, u, EVENT_UNIT_DAMAGED)
call TriggerAddAction(TRIG, function DamageRegister)
//===========================
endif
endfunction
endlibrary