This should be a simple way to show the damage as floating text numbers. Made it for an RPG-Map with only one hero each player.
Auto-attacks will displayed as white and all other attacks will displayed as yellow numbers. Every damage has a chance to deal critical damage. Crit damage will displayed bigger then normal hits.
You will need two more variables:
stats_critchance = XX (actual crit chance for all your units)
stats_critdamage = X.X (for 50% more damage use 1.5, double damage on crit 2.0, ...and so on)
what do you guys think?
Auto-attacks will displayed as white and all other attacks will displayed as yellow numbers. Every damage has a chance to deal critical damage. Crit damage will displayed bigger then normal hits.
You will need two more variables:
stats_critchance = XX (actual crit chance for all your units)
stats_critdamage = X.X (for 50% more damage use 1.5, double damage on crit 2.0, ...and so on)
what do you guys think?
Lua:
function show_textdamage()
local trigger = CreateTrigger()
TriggerRegisterAnyUnitEventBJ(trigger, EVENT_PLAYER_UNIT_DAMAGED)
TriggerAddAction(trigger, function()
local unit = BlzGetEventDamageTarget()
local source = GetEventDamageSource()
local damage = GetEventDamage()
local textpaint_g = nil
local textpaint_b = nil
local textsize = nil
local player = bj_FORCE_PLAYER[GetPlayerId(GetOwningPlayer(source))]
local random_int = GetRandomInt(1, 100)
local random_facing = GetRandomInt(-15, 15)
if BlzGetEventIsAttack() == true then
textpaint_g = 255
textpaint_b = 255
else
textpaint_g = 215
textpaint_b = 0
end
if random_int >= stats_critchance then
textsize = 12
BlzSetEventDamage(damage)
else
textsize = 20
BlzSetEventDamage(damage * stats_critdamage)
damage = damage * stats_critdamage
end
local tag = CreateTextTagUnitBJ(math.floor( damage ), unit, 5.00, textsize, 255, textpaint_g, textpaint_b, 0)
SetTextTagVelocityBJ(tag, 270, GetUnitFacing(source) + random_facing )
SetTextTagPermanentBJ(tag, false)
SetTextTagLifespanBJ(tag, 1)
SetTextTagFadepointBJ(tag, 0)
ShowTextTagForceBJ(false, tag, GetPlayersAll())
ShowTextTagForceBJ(true, tag, player)
end)
end
Last edited: