Hello everyone, this time im trying to make a system that could give a unit ability if it's close to a tree. The main part of the code is:
where's a mistake?
JASS:
function CheckNGo takes nothing returns nothing
local integer i=0
if GetDestructableLife(GetEnumDestructable())>0 then
call UnitAddAbilityBJ( 'AEev', udg_T )
call SetUnitAbilityLevel( udg_T, 'AEev', 1 )
call DisableTrigger( gg_trg_check )
endif
endfunction
function FilterThis takes nothing returns boolean
local location destLoc = GetDestructableLoc(GetFilterDestructable())
local boolean result
set result = DistanceBetweenPoints(destLoc, bj_enumDestructableCenter) <= bj_enumDestructableRadius
call RemoveLocation(destLoc)
set destLoc=null
return result
endfunction
function Trig_check_Actions takes nothing returns nothing
local rect r
local location q
set q = GetUnitLoc(udg_T)
set bj_enumDestructableCenter = q
set bj_enumDestructableRadius = 200
set bj_wantDestroyGroup = true
set r = GetRectFromCircleBJ(q, 200)
call EnumDestructablesInRect(r, filterEnumDestructablesInCircleBJ, function CheckNGo)
//if FilterThis()==true then
//call UnitRemoveAbility(udg_T,'AEev')
//endif
call RemoveRect(r)
call RemoveLocation(q)
set bj_enumDestructableCenter = null
set r=null
set q=null
endfunction
//===========================================================================
function InitTrig_check takes nothing returns nothing
set gg_trg_check = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_check, 0.1 )
call TriggerAddAction( gg_trg_check, function Trig_check_Actions )
endfunction
Last edited: