- Joined
- Nov 6, 2009
- Messages
- 279
Ok can somebody check if the code is ok (leaks, BJs, etc)? I think my GroupRemoveUnit is crap.
JASS:
function LOOP takes nothing returns nothing
local unit creep = GetTriggerUnit()
local integer creeplvl = GetUnitLevel(creep)
local integer xpbase = 25
local integer totalxp = ( creeplvl * xpbase )
local integer goldbase = 2
local integer totalgold = ( creeplvl * goldbase )
local texttag xptag
local texttag goldtag
if ( IsUnitType(GetEnumUnit(), UNIT_TYPE_HERO) == true ) then
call AddHeroXP( GetEnumUnit(), totalxp, true )
set xptag = CreateTextTag()
call SetTextTagPosUnit(xptag, GetEnumUnit(), 0)
call SetTextTagText( xptag, ( "+" + I2S(totalxp) ), 0.018 )
call SetTextTagColor(xptag, 175, 75, 255, 255)
call SetTextTagVelocity( xptag, (TextTagSpeed2Velocity(60) * Cos(75 * bj_DEGTORAD)), (TextTagSpeed2Velocity(60) * Sin(75 * bj_DEGTORAD)) )
call SetTextTagLifespan( xptag, 2.00 )
call SetTextTagFadepoint( xptag, 1.50 )
call SetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(GetOwningPlayer(GetEnumUnit()), PLAYER_STATE_RESOURCE_GOLD) + totalgold)
set goldtag = CreateTextTag()
call SetTextTagPosUnit(goldtag, GetEnumUnit(), 0)
call SetTextTagText( goldtag, ( "+" + I2S(totalgold) ), 0.015 )
call SetTextTagColor(goldtag, 175, 255, 75, 255)
call SetTextTagVelocity( goldtag, (TextTagSpeed2Velocity(74) * Cos(90 * bj_DEGTORAD)), (TextTagSpeed2Velocity(74) * Sin(90 * bj_DEGTORAD)) )
call SetTextTagPermanent( goldtag, false )
call SetTextTagLifespan( goldtag, 2.00 )
call SetTextTagFadepoint( xptag, 1.50 )
endif
set creep = null
endfunction
function INITACTIONS takes nothing returns nothing
local real range = 1200.00
local unit creep = GetTriggerUnit()
local group g = GetUnitsInRangeOfLocAll(range, GetUnitLoc(creep))
call ForGroup( g, function LOOP )
set creep = null
set g = null
call GroupRemoveUnit(g, GetEnumUnit())
endfunction
//===========================================================================
function InitTrig_XP_AND_GOLD_SYSTEM takes nothing returns nothing
local trigger TRG = CreateTrigger( )
call TriggerRegisterPlayerUnitEventSimple( TRG, Player(PLAYER_NEUTRAL_AGGRESSIVE), EVENT_PLAYER_UNIT_DEATH )
call TriggerAddAction( TRG, function INITACTIONS )
endfunction
Last edited: