RangerX
I am justice!
- Reaction score
- 69
i need an local group variable that exist only in one trigger
local group myGroup
function Trig_PA_GetG_II_Func003002002 takes nothing returns boolean
return ( UnitHasBuffBJ(GetFilterUnit(), 039;B007039;) == true )
endfunction
function Actions takes nothing returns nothing
local group g
local unit tu = GetEnumUnit()
local location pos
local location offpos
set g = udg_Pulse_A
set pos = GetUnitLoc(GetEnumUnit())
set offpos = PolarProjectionBJ(pos, 150.00, ( 180.00 + GetUnitFacing(tu) ))
call SetUnitPositionLoc( GetEnumUnit(), offpos )
call RemoveLocation(pos)
call RemoveLocation(offpos)
call UnitRemoveAbility( tu, 039;B007039; )
call GroupRemoveUnit( g,tu)
call DestroyGroup (udg_Pulse_A)
endfunction
function Trig_PA_GetG_II_Actions takes nothing returns nothing
local group g
call TriggerSleepAction( 0.50 )
set g = GetUnitsInRectMatching(GetPlayableMapRect(), Condition(function Trig_PA_GetG_II_Func003002002))
call ForGroup( g, function Actions )
call TriggerSleepAction( 0.10 )
call DestroyGroup (g)
set udg_Pulse_A = g
endfunction
//===========================================================================
function InitTrig_PA_GetG_II takes nothing returns nothing
set gg_trg_PA_GetG_II = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_PA_GetG_II, 0.03 )
call TriggerAddAction( gg_trg_PA_GetG_II, function Trig_PA_GetG_II_Actions )
endfunction
//filter func
function filter takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(),039;B007039;)>0
endfunction
//in the actions func
local group g = CreateGroup()
local boolexpr be = Condition(function filter)
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea,be)
call DestroyBoolExpr(be)
Despite what many coders think, boolexpr variables created through Condition or Filter do not leak any more than a string would, as they are recycled. When a boolexpr is first created, it is placed in the memory.
function filter takes nothing returns boolean
return GetUnitAbilityLevel(GetFilterUnit(),039;B007039;)>0
endfunction
function Main_Actions takes nothing returns nothing
local unit tu = GetEnumUnit()
local location pos
local location offpos
local real angle
if GetUnitAbilityLevel(tu,039;B007039;)>0 then
set pos = GetUnitLoc(GetEnumUnit())
set angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(tu))
set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
call SetUnitPositionLoc( GetEnumUnit(), offpos )
call RemoveLocation(pos)
call RemoveLocation(offpos)
call UnitRemoveAbility( tu, 039;B007039; )
endif
endfunction
function Actions takes nothing returns nothing
local group g = CreateGroup()
local boolexpr be = Condition(function filter)
call GroupEnumUnitsInRect(g, bj_mapInitialPlayableArea,be)
call DestroyBoolExpr(be)
call TriggerSleepAction(0.05)
call ForGroup( g, function Main_Actions )
call DestroyGroup (g)
endfunction
//===========================================================================
function InitTrig_PA_GetG_II takes nothing returns nothing
set gg_trg_PA_GetG_II = CreateTrigger( )
call TriggerRegisterTimerEventPeriodic( gg_trg_PA_GetG_II, 0.03 )
call TriggerAddAction( gg_trg_PA_GetG_II, function Actions )
endfunction
//warning: untested
library Periodic initializer OnInit
globals
group GROUP=CreateGroup()
endglobals
private function filter takes nothing returns boolean
local unit e = GetEnumUnit()
local location pos
local location offpos
local real angle
if GetUnitAbilityLevel(tu,039;B007039;)>0 then
set pos = GetUnitLoc(GetEnumUnit())
set angle = AngleBetweenPoints(GetUnitLoc(GetTriggerUnit()), GetUnitLoc(tu))
set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
call SetUnitPositionLoc( GetEnumUnit(), offpos )
call UnitRemoveAbility( tu, 039;B007039; )
endif
call RemoveLocation(pos)
call RemoveLocation(offpos)
set pos=null
set offpos=null
set e=null
return false
endfunction
private function Actions takes nothing returns boolean
call GroupEnumUnitsInRect(GROUP,bj_mapInitialPlayableArea,Filter(function filter))
return false
endfunction
private function OnInit takes nothing returns nothing
call TimerStart(CreateTimer(),0.05,true,function Actions)
endfunction
endlibrary
//warning: untested
library Periodic initializer OnInit
globals
group GROUP=CreateGroup()
endglobals
private function filter takes nothing returns boolean
local unit e = GetEnumUnit()
local location pos
local location offpos
local real angle
if GetUnitAbilityLevel(tu,039;B007039;)>0 then
set pos = GetUnitLoc(e)
set angle = GetUnitFacing(e)+180
set offpos = PolarProjectionBJ(pos, 150.00, ( angle ) )
call SetUnitPositionLoc( GetEnumUnit(), offpos )
call UnitRemoveAbility( tu, 039;B007039; )
endif
call RemoveLocation(pos)
call RemoveLocation(offpos)
set pos=null
set offpos=null
set e=null
return false
endfunction
private function Actions takes nothing returns boolean
call GroupEnumUnitsInRect(GROUP,bj_mapInitialPlayableArea,Filter(function filter))
return false
endfunction
private function OnInit takes nothing returns nothing
call TimerStart(CreateTimer(),0.05,true,function Actions)
endfunction
endlibrary