scope Sprenger initializer in_Sprenger
globals
private group array sgroup[10]
private integer array dmg[10]
private real array sx[10]
private real array sy[10]
private player tplayer
private unit sunit
endglobals
//===========================================================================
private function Sprenger_Conditions takes nothing returns boolean
return (GetSpellAbilityId() == 'A043')
endfunction
//===========================================================================
private function Sprenger_Group_Cond takes nothing returns boolean
return ( (IsUnitEnemy(GetFilterUnit(), tplayer)) and GetUnitState(GetFilterUnit(), UNIT_STATE_LIFE) > 0.449 )
endfunction
//===========================================================================
function Sprenger_Destroy_Group takes integer i returns nothing
local unit u
loop
set u = FirstOfGroup(sgroup[i])
call GroupRemoveUnit(sgroup[i], u)
call RemoveUnit(u)
exitwhen u == null
endloop
call DestroyGroup(sgroup[i])
set sgroup[i] = null
set dmg[i] = 0
set sx[i] = 0
set sy[i] = 0
endfunction
//===========================================================================
function Sprenger_Effects takes nothing returns nothing
local unit trap = GetEnumUnit()
local real x = GetUnitX(trap)
local real y = GetUnitY(trap)
call UnitApplyTimedLife(CreateUnit(GetOwningPlayer(trap), 'h014', x, y, 0), 'BTLF', 2.00)
call UnitAddAbility(trap, 'A04F')
call IssueTargetOrderById(trap, 852487, sunit)
call UnitAddAbility(trap, 'Aloc')
endfunction
//===========================================================================
function Sprenger_Working takes integer i returns nothing
local group targetgroup = CreateGroup()
local unit dummy
local unit target
local player tp
set tplayer = GetOwningPlayer(FirstOfGroup(sgroup[i]))
set tp = tplayer
call GroupEnumUnitsInRange(targetgroup, sx[i], sy[i], 100, Condition(function Sprenger_Group_Cond))
set sunit = GroupPickRandomUnit(targetgroup)
set target = sunit
call GroupClear(targetgroup)
call ForGroup(sgroup[i], function Sprenger_Effects)
call SetUnitX(target, sx[i])
call SetUnitY(target, sy[i])
call PauseUnit(target, true)
set dummy = CreateUnit(tplayer, 'h00E', sx[i], sy[i], 0)
call UnitApplyTimedLife(dummy, 'BTLF', 5.00)
call UnitAddAbility(dummy, 'A04E')
call SetUnitAbilityLevel(dummy, 'A04E', dmg[i])
call DestroyGroup(targetgroup)
set targetgroup = null
set sunit = null
call PolledWait2(2)
call IssuePointOrder(dummy, "blizzard", sx[i], sy[i])
call PolledWait2(1)
call UnitApplyTimedLife(CreateUnit(tp, 'h015', sx[i], sy[i], 0), 'BTLF', 3.00)
call UnitApplyTimedLife(CreateUnit(tp, 'h016', sx[i], sy[i], 0), 'BTLF', 2.00)
call PauseUnit(target, false)
set tp = null
set target = null
set dummy = null
call Sprenger_Destroy_Group(i)
endfunction
//===========================================================================
private function Sprenger_Group takes nothing returns integer
local integer i = 0
loop
if sgroup[i] == null then
set sgroup[i] = CreateGroup()
return i
set i = 9
endif
set i = i + 1
exitwhen i >= 9
endloop
return -1
endfunction
//===========================================================================
private function Sprenger_Actions takes nothing returns nothing
local unit u
local unit caster = GetTriggerUnit()
local location temppoint = GetUnitLoc(caster)
local location array sp[5]
local integer a = 0
local integer i
local player p = GetOwningPlayer(caster)
local integer ts = GetPlayerId(p)+1
set i = Sprenger_Group()
if i >= 0 then
set dmg[i] = GetUnitAbilityLevel(caster, 'A043')
set sx[i] = GetUnitX(caster)
set sy[i] = GetUnitY(caster)
loop
exitwhen a > 4
set sp[a] = PolarProjectionBJ(temppoint, 250.00, ( 90.00 + ( I2R(a) * 72.00 ) ))
set u = CreateUnitAtLoc(p, 'h012', sp[a], 0 )
call SetUnitUserData(u, i)
call GroupAddUnit(sgroup[i], u)
set a = a + 1
call RemoveLocation(sp[a])
set sp[a] = null
endloop
endif
set u = null
set p = null
call RemoveLocation(temppoint)
set temppoint = null
endfunction
//===========================================================================
private function in_Sprenger takes nothing returns nothing
local trigger t_Sprenger = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ( t_Sprenger, EVENT_PLAYER_UNIT_SPELL_FINISH )
call TriggerAddCondition( t_Sprenger, Condition( function Sprenger_Conditions ) )
call TriggerAddAction( t_Sprenger, function Sprenger_Actions )
set t_Sprenger = null
endfunction
endscope