struct SWdata
unit SWCast
group SWgroup
real SWangle
integer SWticktruct
function SWStart takes nothing returns nothing
local timer SW = GetExpiredTimer()
local SWdata data = GetTimerData( SW )
local group SWgroup2
local unit SWpick
local location SWloc1
local location SWloc2
set SWgroup2 = CreateGroup()
set SWgroup2 = data.SWgroup
loop
set SWpick = FirstOfGroup( SWgroup2 )
exitwhen SWpick==null
call GroupRemoveUnit( SWgroup2, SWpick )
if not UnitHasBuffBJ(SWpick, 'Avul') and not IsUnitType( SWpick, UNIT_TYPE_DEAD ) and IsUnitEnemy(SWpick, GetOwningPlayer(data.SWCast) ) and not IsUnitType( SWpick, UNIT_TYPE_STRUCTURE ) and ( GetUnitAbilityLevelSwapped('A006', SWpick) >= 1 )then
set SWloc1 = GetUnitLoc( SWpick )
set SWloc2 = PolarProjectionBJ( SWloc1, 40, data.SWangle )
call SetUnitPositionLocFacingBJ( SWpick, SWloc2, data.SWangle )
call RemoveLocation( SWloc1 )
call RemoveLocation( SWloc2 )
set SWloc1 = null
set SWloc2 = null
endif
endloop
call DestroyGroup( SWgroup2 )
set SWgroup2 = null
set SWpick = null
set data.SWtick = data.SWtick - 1
if data.SWtick < 1 then
call DestroyGroup( data.SWgroup )
set data.SWgroup = null
call ReleaseTimer( SW )
call data.destroy()
endif
set SW = null
endfunction
function SWAct takes nothing returns nothing
local SWdata data = SWdata.create()
local timer SW = NewTimer()
local unit SWCast = GetTriggerUnit()
local location SWloc1 = GetUnitLoc(SWCast)
local location SWloc2 = GetSpellTargetLoc()
local group SWgroup = GetUnitsInRangeOfLocAll( 80, SWloc2 )
set data.SWangle = AngleBetweenPoints( SWloc2, SWloc1 )
set data.SWgroup = SWgroup
set data.SWtick = 30
set data.SWCast = SWCast
call SetTimerData( SW, data )
call TimerStart( SW, 0.04, true, function SWStart )
call RemoveLocation( SWloc1 )
call RemoveLocation( SWloc2 )
set SWloc1 = null
set SWloc2 = null
set SWCast = null
set SW = null
endfunction
function SWConds takes nothing returns boolean
return GetSpellAbilityId() == 'A003'
endfunction
function Trig_Swallow_Actions takes nothing returns nothing
endfunction
//===========================================================================
function InitTrig_Swallow takes nothing returns nothing
set gg_trg_Swallow = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Swallow, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Swallow, Condition( function SWConds ) )
call TriggerAddAction( gg_trg_Swallow, function SWAct )
endfunction