function Trig_Firebolt_Split_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Fire takes nothing returns nothing
local timer t=GetExpiredTimer()
local unit c=GetAttachedUnit(t,"c")
local unit b=GetAttachedUnit(t,"b")
local real a=AngleBetweenPoints(GetUnitLoc(c),GetUnitLoc(b))
call SetUnitPositionLocFacingBJ(c,PolarProjectionBJ(GetUnitLoc(c),8,a),a)
set b=null
set c=null
endfunction
function killC takes nothing returns nothing
local timer k=GetExpiredTimer()
local unit c=GetAttachedUnit(k,"c")
call KillUnit(c)
set c=null
call CleanAttachedVars(k)
call DestroyTimer(k)
endfunction
function Trig_Firebolt_Split_Actions takes nothing returns nothing
local unit u=GetSpellAbilityUnit()
local unit b=GetSpellTargetUnit()
local unit c=CreateUnitAtLoc(GetOwningPlayer(u),'h002',PolarProjectionBJ(GetUnitLoc(u),40,GetUnitFacing(u)),GetUnitFacing(u))
local real d=70+(GetUnitAbilityLevelSwapped('A000',u)*50)
local real sd=40+(GetUnitAbilityLevelSwapped('A000',u)*50)
local timer t=CreateTimer()
local group g=CreateGroup()
local unit n
local unit re
local timer k=CreateTimer()
call AttachObject(t,"c",c)
call AttachObject(t,"b",b)
call TimerStart(t,0.02,true,function Fire)
loop
exitwhen IsUnitInRange(c,b,20)
call TriggerSleepAction(0)
endloop
call AttachObject(k,"c",c)
call TimerStart(k,0.4,false,function killC)
call DestroyTimer(t)
call CleanAttachedVars(t)
call UnitDamageTargetBJ(u,b,d,ATTACK_TYPE_MAGIC,DAMAGE_TYPE_FIRE)
set g=GetUnitsInRangeOfLocAll(700,GetUnitLoc(b))
loop
set n=FirstOfGroup(g)
exitwhen n==null
if IsUnitAliveBJ(n) and IsUnitEnemy(n,GetOwningPlayer(u)) and n!=b then
set re=CreateUnitAtLoc(GetOwningPlayer(u),'h001',GetUnitLoc(b),bj_UNIT_FACING)
call SetUnitAbilityLevelSwapped('A001',re,GetUnitAbilityLevelSwapped('A000',u))
call IssueTargetOrderBJ(re,"firebolt",n)
call UnitApplyTimedLifeBJ(0.5,'BTLF',re)
endif
call GroupRemoveUnit(g,n)
endloop
call DestroyGroup(g)
set n=null
set u=null
set c=null
set g=null
set re=null
set t=null
endfunction
//===========================================================================
function InitTrig_Firebolt_Split takes nothing returns nothing
set gg_trg_Firebolt_Split = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Firebolt_Split, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Firebolt_Split, Condition( function Trig_Firebolt_Split_Conditions ) )
call TriggerAddAction( gg_trg_Firebolt_Split, function Trig_Firebolt_Split_Actions )
endfunction