Charapanga
New Member
- Reaction score
- 46
Hi, well i made my first trigger, it is supposed to display a text to all players when a hero dies and reduce owning player's gold by 250 But...It doesn't even go off...and there might be Leaks cuz it kinnda lags when a hero dies...
JASS:
globals
unit u = GetTriggerUnit() // Dying unit
location ul = GetUnitLoc(u) // position of dying unit
player uo = GetOwningPlayer(u) // Owner of Dying unit
force ap = GetPlayersAll() // all players
string pn = GetPlayerName(uo) // Player name
integer gold = -250 // Gold lost
texttag ft = CreateTextTagLocBJ("Died", ul, 0, 10, 0, 100, 100, 0) // Floating Text
endglobals
function PlayerDeath_Conditions takes nothing returns boolean
return ( IsUnitType(GetTriggerUnit( ), UNIT_TYPE_HERO) == true ) // if dying unit is a hero
endfunction
function PlayerDeath_Actions takes nothing returns nothing
call DisplayTextToForce(ap, pn+" has died, he will lose "+I2S(gold)+" gold!") // Displays the text to all players
call AdjustPlayerStateBJ( gold, uo, PLAYER_STATE_RESOURCE_GOLD ) // Reduces the gold...
call SetTextTagLifespanBJ( ft, 5 )
call SetTextTagVelocityBJ( ft, 64, 90 )
call SetTextTagFadepointBJ( ft, 3 )
call ShowTextTagForceBJ( true, ft, ap )
endfunction
//===========================================================================
function InitTrig_PlayerDeath takes nothing returns nothing
local trigger gg_trg_PlayerDeath = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ(gg_trg_PlayerDeath, EVENT_PLAYER_UNIT_DEATH)
call TriggerAddCondition(gg_trg_PlayerDeath, Condition(function PlayerDeath_Conditions))
call TriggerAddAction( gg_trg_PlayerDeath, function PlayerDeath_Actions )
endfunction