//TESH.scrollpos=20
//TESH.alwaysfold=0
function Trig_X_Banner_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A002'
endfunction
function Trig_X_Banner_Actions2 takes nothing returns nothing
local timer t = GetExpiredTimer()
local integer id = GetHandleId(t)
local unit u = LoadUnitHandle(udg_Hash,id,0)
local unit d1 = LoadUnitHandle(udg_Hash,id,1)
local unit d2 = LoadUnitHandle(udg_Hash,id,11)
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real x1 = LoadReal(udg_Hash,id,5)
local real y1 = LoadReal(udg_Hash,id,6)
local real i = LoadReal(udg_Hash,id,7)
local real f = GetUnitFacing(u)
local boolean b = LoadBoolean(udg_Hash,id,10)
local group g = CreateGroup()
local unit e
local real a
local real r = 0
local real x2
local real y2
local player p = GetOwningPlayer(u)
if x==x1 and y==y1 and OrderId2String(GetUnitCurrentOrder(u)) == "channel" and GetUnitState(u,UNIT_STATE_MANA) > 1 then
if b == true then
call SetUnitState(u,UNIT_STATE_MANA,GetUnitState(u,UNIT_STATE_MANA)-1)
loop
exitwhen r == 6
call UnitApplyTimedLife(CreateUnit(p,'h002',x+r*300*Cos(f*bj_DEGTORAD),y+r*300*Sin(f*bj_DEGTORAD),f),'BTLF',0.1)
call GroupEnumUnitsInRange(g,x+r*300*Cos(f*bj_DEGTORAD),y+r*300*Sin(f*bj_DEGTORAD),300,null)
set r = r+1
loop
set e = FirstOfGroup(g)
if IsUnitEnemy(e,GetOwningPlayer(u)) then
call UnitDamageTarget(u,e,5,true,false,null,null,null)
set x2 = GetUnitX(e)
set y2 = GetUnitY(e)
set a = Atan2(y-y2,x-x2)
call SetUnitX(e,x2-1*Cos(a))
call SetUnitY(e,y2-1*Sin(a))
endif
call GroupRemoveUnit(g,e)
exitwhen e == null
endloop
endloop
endif
else
call DestroyTimer(t)
call RemoveUnit(d1)
call RemoveUnit(d2)
call FlushChildHashtable(udg_Hash,id)
endif
if i < 40 then
call SaveReal(udg_Hash,id,7,i+1)
else
if b == false then
set d2 = CreateUnit(GetOwningPlayer(u),'h003',x+25*Cos((f)*bj_DEGTORAD),y+25*Sin((f)*bj_DEGTORAD),f)
call SaveUnitHandle(udg_Hash,id,11,d2)
call SetUnitVertexColor(d2,255,50,50,255)
call SaveBoolean(udg_Hash,id,10,true)
endif
endif
call DestroyGroup(g)
set e = null
set d1 = null
set d2 = null
set p = null
set u = null
set t = null
endfunction
function Trig_X_Banner_Actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local real x1 = GetSpellTargetX()
local real y1 = GetSpellTargetY()
local real f = GetUnitFacing(u)
local unit d1
local boolean b = true
local timer t = CreateTimer()
local integer id = GetHandleId(t)
set d1 = CreateUnit(GetOwningPlayer(u),'h003',x+50*Cos((f+180)*bj_DEGTORAD),y+50*Sin((f+180)*bj_DEGTORAD),f+180)
call UnitAddAbility(d1,'A003')
call SaveUnitHandle(udg_Hash,id,0,u)
call SaveUnitHandle(udg_Hash,id,1,d1)
call SaveReal(udg_Hash,id,2,x1)
call SaveReal(udg_Hash,id,3,y1)
call SaveReal(udg_Hash,id,5,x)
call SaveReal(udg_Hash,id,6,y)
call SaveBoolean(udg_Hash,id,4,b)
call TimerStart(t,0.025,true,function Trig_X_Banner_Actions2)
set u = null
set d1 = null
set t = null
endfunction
//===========================================================================
function InitTrig_X_Banner takes nothing returns nothing
set gg_trg_X_Banner = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_X_Banner, EVENT_PLAYER_UNIT_SPELL_CAST )
call TriggerAddCondition( gg_trg_X_Banner, Condition( function Trig_X_Banner_Conditions ) )
call TriggerAddAction( gg_trg_X_Banner, function Trig_X_Banner_Actions )
endfunction