crazyfanatic
New Member
- Reaction score
- 20
I have made a system, that shows the damage dealt when a unit strikes. But it doesnt work when you hit a creep, only on buildings. Can you help me fix it?
JASS:
function KDDS_GetTextSize takes nothing returns real
return 10.0 // The text size of the floating text.
endfunction
function KDDS_GetZOffset takes nothing returns real
return 0.0 // The z offset if the floating text.
endfunction
function KDDS_GetLifeSpan takes nothing returns real
return 1.5 // The life span of the floating text.
endfunction
function KDDS_GetFadeTime takes nothing returns real
return 0.0 // The fade time of the floating text.
endfunction
function KDDS_GetVelocity takes nothing returns real
return 92.0 // The velocity of the floating text.
endfunction
function KDDS_GetVelocityAngle takes nothing returns real
return 90.0// The velocity angle of the floating text.
endfunction
function KDDS_GetPlayerColourString takes integer i returns string
local playercolor pc = GetPlayerColor(Player(i))
local string s
if pc == PLAYER_COLOR_RED then
set s = "|cffFF0000"
elseif pc == PLAYER_COLOR_BLUE then
set s = "|cff0000FF"
elseif pc == PLAYER_COLOR_CYAN then
set s = "|cff00FFFF"
elseif pc == PLAYER_COLOR_PURPLE then
set s = "|cff800080"
elseif pc == PLAYER_COLOR_YELLOW then
set s = "|cffFFFF00"
elseif pc == PLAYER_COLOR_ORANGE then
set s = "|cffFF8000"
elseif pc == PLAYER_COLOR_GREEN then
set s = "|cff00FF00"
elseif pc == PLAYER_COLOR_PINK then
set s = "|cffFF80C0"
elseif pc == PLAYER_COLOR_LIGHT_GRAY then
set s = "|cffC0C0C0"
elseif pc == PLAYER_COLOR_LIGHT_BLUE then
set s = "|cff8080FF"
elseif pc == PLAYER_COLOR_AQUA then
set s = "|cff008040"
elseif pc == PLAYER_COLOR_LIGHT_BLUE then
set s = "|cff804000"
else
set s = "|cff808080"
endif
set pc = null
return s
endfunction
function KDDS_Display takes nothing returns nothing
local unit u = GetTriggerUnit()
local real d = GetEventDamage()
local integer p = GetPlayerId(GetOwningPlayer(GetEventDamageSource()))
local string c = KDDS_GetPlayerColourString(p)
local texttag t
call CreateTextTagUnitBJ(c+I2S(R2I(d))+"|r",u, KDDS_GetZOffset(),KDDS_GetTextSize(), 100, 100, 100, 0 )
set t = GetLastCreatedTextTag()
call SetTextTagPermanentBJ( t, false )
call SetTextTagLifespanBJ( t, KDDS_GetLifeSpan() )
call SetTextTagFadepointBJ( t, KDDS_GetFadeTime() )
call SetTextTagVelocityBJ( t, KDDS_GetVelocity(), KDDS_GetVelocityAngle() )
set u = null
set d = 0
set p = 0
set c = ""
set t = null
endfunction
function KDDS_RegisterUnit takes unit u returns nothing
call TriggerRegisterUnitEvent( gg_trg_Display_Damage_System, u, EVENT_UNIT_DAMAGED )
endfunction
function KDDS_SetUp takes nothing returns nothing
local group g = CreateGroup()
local unit u
set g = GetUnitsInRectAll(GetPlayableMapRect())
loop
set u = FirstOfGroup(g)
exitwhen u == null
call KDDS_RegisterUnit(u)
call GroupRemoveUnit(g, u)
endloop
set g = null
endfunction
//===========================================================================
function InitTrig_Display_Damage_System takes nothing returns nothing
set gg_trg_Display_Damage_System = CreateTrigger( )
call TriggerAddAction( gg_trg_Display_Damage_System, function KDDS_Display )
call KDDS_SetUp()
endfunction