function Trig_Igloult_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function IgloUltFilt takes nothing returns boolean
return IsUnitType(GetFilterUnit(),UNIT_TYPE_DEAD) == false and IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(LoadUnitHandle(udg_H,GetHandleId(GetExpiredTimer()),0))) == true and IsUnitType(GetFilterUnit(),UNIT_TYPE_STRUCTURE) == false
endfunction
function IgloUltGroup takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = LoadUnitHandle(udg_H,GetHandleId(t),0)
local integer lvl = GetUnitAbilityLevel(caster,'A000')
local unit iu = LoadUnitHandle(udg_H,GetHandleId(t),1001)
local real ir = LoadReal(udg_H,GetHandleId(t),1002)
call UnitDamageTarget(caster,GetEnumUnit(),10.,true,true,ATTACK_TYPE_NORMAL,DAMAGE_TYPE_NORMAL,WEAPON_TYPE_WHOKNOWS)
call SaveReal(udg_H,GetHandleId(t),1002,ir - 5. * lvl)
set t = null
set caster = null
set iu = null
endfunction
function IgloUltMove takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = LoadUnitHandle(udg_H,GetHandleId(t),0)
local integer lvl = GetUnitAbilityLevel(caster,'A000')
local integer i = 1
local real x = GetWidgetX(caster)
local real y = GetWidgetY(caster)
local real d
local unit iu
local real x2
local real y2
local group g = CreateGroup()
local real a = LoadReal(udg_H,GetHandleId(t),1000) + 5.
if IsUnitType(caster,UNIT_TYPE_DEAD) == true then
loop
exitwhen i > lvl * 4 + 5
call RemoveUnit(LoadUnitHandle(udg_H,GetHandleId(t),100 + i))
call PauseTimer(t)
call DestroyTimer(t)
endloop
endif
call SaveReal(udg_H,GetHandleId(t),1000,a)
loop
exitwhen i > lvl * 4 + 5
set d = LoadReal(udg_H,GetHandleId(t),50 + i)
set iu = LoadUnitHandle(udg_H,GetHandleId(t),100 + i)
set x2 = x + d * Cos((360. / (lvl * 4. + 5.) * i + a) * .0174532)
set y2 = y + d * Sin((360. / (lvl * 4. + 5.) * i + a) * .0174532)
call SetUnitFacing(iu,57.295827 * Atan2(y2 - GetWidgetY(iu),x2 - GetWidgetX(iu)))
call SetUnitX(iu,x2)
call SetUnitY(iu,y2)
call SaveUnitHandle(udg_H,GetHandleId(t),1001,iu)
call SaveReal(udg_H,GetHandleId(t),1002,LoadReal(udg_H,GetHandleId(t),i))
call GroupEnumUnitsInRange(g,x2,y2,120.,Filter(function IgloUltFilt))
call ForGroup(g,function IgloUltGroup)
call SaveReal(udg_H,GetHandleId(t),i,LoadReal(udg_H,GetHandleId(t),1002))
if LoadReal(udg_H,GetHandleId(t),i) < 20. then
call RemoveUnit(iu)
endif
call GroupClear(g)
set i = i + 1
endloop
call DestroyGroup(g)
set iu = null
set caster = null
set t = null
set g = null
endfunction
function Trig_Igloult_SpellEndTimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local timer t2 = LoadTimerHandle(udg_H,GetHandleId(t),0)
local unit caster = LoadUnitHandle(udg_H,GetHandleId(t2),0)
local integer lvl = GetUnitAbilityLevel(caster,'A000')
local integer i = 0
local unit u
loop
exitwhen i > lvl * 4 + 5
set u = LoadUnitHandle(udg_H,GetHandleId(t2),100 + i)
call RemoveUnit(u)
set i = i + 1
endloop
call PauseTimer(t2)
call DestroyTimer(t2)
call FlushChildHashtable(udg_H,GetHandleId(t))
call FlushChildHashtable(udg_H,GetHandleId(t2))
call DestroyTimer(t)
set caster = null
set t = null
set t2 = null
endfunction
function Trig_Igloult_Actions takes nothing returns nothing
local integer i = 1
local integer a
local timer t = CreateTimer()
local timer t2 = CreateTimer()
local real array d
local real array h
local unit caster = GetTriggerUnit()
local integer lvl = GetUnitAbilityLevel(caster,'A000')
local unit u
loop
exitwhen i > 4 * lvl + 5
if i <= 3 then
set d[i] = -240. * i * i + 1040. * i - 640.
set h[i] = 70. * i - 30.
else
set a = 3
loop
exitwhen a > 18
if i > a and i <= 3 + a then
set d[i] = -240. * (i - a) * (i - a) + 1040. * (i - a) - 640.
set h[i] = 70. * (i - a) - 30.
endif
set a = a + 3
endloop
endif
set i = i + 1
endloop
set i = 1
loop
exitwhen i > lvl * 4 + 5
call SaveReal(udg_H,GetHandleId(t),i,30. * lvl + 50.)
call SaveReal(udg_H,GetHandleId(t),50 + i,d[i])
set u = CreateUnit(GetOwningPlayer(caster),'h000',GetWidgetX(caster) + 350. * Cos(360. / (lvl * 4. + 5.) * i * .0174532),GetWidgetY(caster) + 350. * Sin(360. / (lvl * 4. + 5.) * i * .0174532),360. / (lvl * 4. + 5.) * i)
call SetUnitFlyHeight(u,h[i],200.)
call SaveUnitHandle(udg_H,GetHandleId(t),100 + i,u)
set i = i + 1
endloop
call SaveUnitHandle(udg_H,GetHandleId(t),0,caster)
call SaveReal(udg_H,GetHandleId(t),1000,0.)
call TimerStart(t,.04,true,function IgloUltMove)
call SaveTimerHandle(udg_H,GetHandleId(t2),0,t)
call TimerStart(t2,25.,false,function Trig_Igloult_SpellEndTimer)
set t = null
set t2 = null
set caster = null
set u = null
endfunction
//===========================================================================
function InitTrig_Igloult takes nothing returns nothing
set gg_trg_Igloult = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(gg_trg_Igloult,EVENT_PLAYER_UNIT_SPELL_EFFECT)
call TriggerAddCondition(gg_trg_Igloult,Condition(function Trig_Igloult_Conditions))
call TriggerAddAction(gg_trg_Igloult,function Trig_Igloult_Actions)
endfunction