I need to improve this.You will realize there is a few leaks.
Any ideas will be appreciated.
JASS:
scope Barbedbristleback initializer Init
globals
private constant integer ABIL_ID = 'A00C'
private constant string ORDER = "fanofknives"
endglobals
private function Barbedbristleback_Conditions takes nothing returns boolean
return GetUnitTypeId(GetAttacker()) =='n000'
endfunction
private function Actions takes nothing returns nothing
local integer abilityint = 0
local unit bristle = GetAttacker()
local unit target = GetTriggerUnit()
local real mana = GetUnitState(bristle,UNIT_STATE_MANA)
if mana >= 20 then
call UnitAddAbility(bristle,ABIL_ID)
call SetUnitAbilityLevel(bristle,ABIL_ID,1)
call IssueTargetOrder(bristle,ORDER,target)
endif
endfunction
//===========================================================================
private function Init takes nothing returns nothing
local trigger BarbedbristlebackTrg = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( BarbedbristlebackTrg, EVENT_PLAYER_UNIT_ATTACKED )
call TriggerAddCondition( BarbedbristlebackTrg, Condition( function Barbedbristleback_Conditions ) )
call TriggerAddAction( BarbedbristlebackTrg, function Actions )
endfunction
endscope
Any ideas will be appreciated.