I'm making an RPG and i want an option where when a player hero attacks, the damage amount will be shown with TextTags above the hero. However, I can't figure out how to make the game register the amount of damage that the hero actually did. The function GetEventDamage() only works with the "specific unit takes damage" event, which wouldn't be practical to use, and every other event i've tried always fires the trigger AFTER the damage is done, so there is no way to use arithmetic to figure out the damage. If somebody could help me with this i would really appreciate it.
there is a way without using jass and have it perfectly timed, but it uses a normal ability slot. make a critical strike based spell and set damage multiplier to 1.00.
That will not work as "damage taken" is linked to "takes damage" which he does not want to use.
Let us see...
You want the text to show up over the hero instead over the damaged unit...
This is a short solution. It may be enhanced:
trigger "aquireTarget":
function Trig_showText_Actions takes nothing returns nothing
local texttag tempText = CreateTextTag()
call SetTextTagText(tempText,R2S(GetEventDamage()),0.023)
call SetTextTagColor(tempText,255,127,127,0)
call SetTextTagPosUnit(tempText, - Here your Hero must be put in - ,10)
call DestroyTextTag(tempText)
set tempText = null
endfunction
function Trig_aquireTarget_Actions takes nothing returns nothing
local unit tempUnit = GetEventTargetUnit()
local trigger trg_showText = CreateTrigger()
call TriggerRegisterUnitEvent(trg_showText,tempUnit,EVENT_UNIT_DAMAGED)
call TriggerAddAction(trg_showText,function Trig_showText_Actions)
loop
exitwhen(GetUnitState(tempUnit,UNIT_STATE_LIFE) <= 0 or tempUnit != GetEventTargetUnit())
call TriggerSleepAction(0.05)
endloop
call DestroyTrigger(trg_showText)
set trg_showText = null
endfunction
function InitTrig_aquireTarget takes nothing returns nothing
set gg_trg_aquireTarget = CreateTrigger()
call TriggerRegisterUnitEvent(gg_trg_aquireTarget, - Here your Hero must be put in - ,EVENT_UNIT_ACQUIRED_TARGET)
call TriggerAddAction(gg_trg_aquireTarget,function Trig_aquireTarget_Actions)
endfunction
If the trigger does not work as appropriated or causes trouble otherways, report to me and I will try to solve the problem.