function Trig_CtD_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A00N'
endfunction
function Trig_CtD_Func1 takes nothing returns boolean
return GetBooleanAnd((UnitHasBuffBJ(GetFilterUnit(), 'B002') == true), (IsUnitAliveBJ(udg_Caster_Unit) == true))
endfunction
function Trig_CtD_Func2 takes nothing returns nothing
local unit tmp = GetEnumUnit()
local unit q = GetSpellAbilityUnit()
local lightning A
call AddLightning("AFOD", True, GetX(q), GetY(a), GetX(tmp), GetY(tmp)
set A = GetLastCreatedLightningBJ()
call UnitDamageTargetBJ( q, tmp, 350.00, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_DEATH )
call DestroyLightning(A)
endfunction
function Trig_CtD_Actions takes nothing returns nothing
local unit a = GetSpellAbilityUnit()
local integer loopv = 0
local group temp
set udg_Caster_Unit = GetSpellAbilityUnit()
if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then
set loopv = 1
loop
exitwhen loopv > 10
if ( IsUnitAliveBJ(a) == false ) then
set loopv = 10
else
set temp = GetRandomSubGroup(1, GetUnitsInRangeOfLocMatching(800.00, GetUnitLoc(a), Condition(function Trig_CtD_Func1) ) )
call ForGroup( temp, function Trig_CtD_Func2 )
set loopv = loopv + 1
endif
endloop
else
if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then
set loopv = 1
loop
exitwhen loopv > 20
if ( IsUnitAliveBJ(a) == false ) then
set loopv = 10
else
set temp = GetRandomSubGroup(1, GetUnitsInRangeOfLocMatching(800.00, GetUnitLoc(a), Condition(function Trig_CtD_Func1) ) )
call ForGroup( temp, function Trig_CtD_Func2 )
set loopv = loopv + 1
endif
endloop
else
if ( GetUnitAbilityLevel( a, 'A00N') == 1 ) then
set loopv = 1
loop
exitwhen loopv > 30
if ( IsUnitAliveBJ(a) == false ) then
set loopv = 10
else
set temp = GetRandomSubGroup(1, GetUnitsInRangeOfLocMatching(800.00, GetUnitLoc(a), Condition(function Trig_CtD_Func1) ) )
call ForGroup( temp, function Trig_CtD_Func2 )
set loopv = loopv + 1
endif
endloop
endif
endif
endif
endfunction
//===========================================================================
function InitTrig_CtD takes nothing returns nothing
set gg_trg_CtD = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_CtD, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_CtD, Condition( function Trig_CtD_Conditions ) )
call TriggerAddAction( gg_trg_CtD, function Trig_CtD_Actions )
endfunction