Code:
function Trig_strength_aura_Actions takes nothing returns nothing
local group g = CreateGroup()
local group n
local unit u
local boolexpr b = Condition(function unit_filter )
local rect r = GetPlayableMapRect()
call GroupEnumUnitsInRect(g, r, b)
set n = US_copy_group(g)
loop
set u = FirstOfGroup(n)
exitwhen u == null
if UnitHasBuffBJ(u, buffcode1()) == true or UnitHasBuffBJ(u, buffcode2()) == true or UnitHasBuffBJ(u, buffcode3()) == true or UnitHasBuffBJ(u, buffcode4()) == true and GetUnitAbilityLevel(u, secabilcode()) < 1 then
call UnitAddAbility(u, secabilcode())
if UnitHasBuffBJ(u, buffcode1()) == true then
call SetUnitAbilityLevel(u, secabilcode(), 1)
elseif UnitHasBuffBJ(u, buffcode2()) == true then
call SetUnitAbilityLevel(u, secabilcode(), 2)
elseif UnitHasBuffBJ(u, buffcode3()) == true then
call SetUnitAbilityLevel(u, secabilcode(), 3)
else
call SetUnitAbilityLevel(u, secabilcode(), 4)
endif
elseif UnitHasBuffBJ(u, buffcode1()) == true or UnitHasBuffBJ(u, buffcode2()) == true or UnitHasBuffBJ(u, buffcode3()) == true or UnitHasBuffBJ(u, buffcode4()) == true and GetUnitAbilityLevel(u, secabilcode()) >= 1 then
if UnitHasBuffBJ(u, buffcode1()) == true and GetUnitAbilityLevel(u, secabilcode()) != 1 then
call SetUnitAbilityLevel(u, secabilcode(), 1)
elseif UnitHasBuffBJ(u, buffcode2()) == true and GetUnitAbilityLevel(u, secabilcode()) != 2 then
call UnitRemoveAbility(u, buffcode1())
call SetUnitAbilityLevel(u, secabilcode(), 2)
elseif UnitHasBuffBJ(u, buffcode3()) == true and GetUnitAbilityLevel(u, secabilcode()) != 3 then
call UnitRemoveAbility(u, buffcode2())
call SetUnitAbilityLevel(u, secabilcode(), 3)
elseif UnitHasBuffBJ(u, buffcode4()) == true and GetUnitAbilityLevel(u, secabilcode()) != 4 then
call UnitRemoveAbility(u, buffcode3())
call SetUnitAbilityLevel(u, secabilcode(), 4)
endif
else
call UnitRemoveAbility(u, secabilcode())
endif
call GroupRemoveUnit(n, u)
endloop
//remove mem leaks
call DestroyGroup(g)
call DestroyGroup(n)
call DestroyBoolExpr(b)
call RemoveRect(r)
set r = null
set g = null
set b = null
set u = null
endfunction
gw rada2x lupa kl bagian itu leak apa ngga ... tapi pake aja biar aman
Share This Thread