function Dash_onLoop takes nothing returns nothing
local integer i=1
local integer j=udg_D_Inst
local unit caster
local unit target
local real x
local real y
local real a
local real newX
local real newY
local boolean b1
local boolean b2
loop
set caster=udg_D_Caster[i]
set target=udg_D_Target[i]
set b1=IsUnitInRange(caster,target,60.00)
set b2=GetUnitCurrentOrder(caster)!=OrderId("absorb")
if (b1 or b2) then
call UnitRemoveAbility(caster,DASH_ONDASH_ID())
//call UnitAddAbility(caster,DASH_ONHIT_ID())
//call IssueImmediateOrder(caster,DASH_ORDER_STR())
call DestroyEffect(udg_D_KBdust[i])
if b1 then
call SetUnitAnimation(caster,"attack slam")
call SetUnitTimeScale(caster,1.0)
endif
set udg_D_Caster[i] =udg_D_Caster[j]
set udg_D_Target[i] =udg_D_Target[j]
set udg_D_KBdust[i] =udg_D_KBdust[j]
set i=i-1
set j=j-1
if (j==0) then
call PauseTimer(udg_D_Timer)
endif
else
set target=udg_D_Target[i]
set x=GetUnitX(caster)
set y=GetUnitY(caster)
set a=Atan2(GetUnitY(target)-y,GetUnitX(target)-x)
set newX=x+DASH_DPP()*Cos(a)
set newY=y+DASH_DPP()*Sin(a)
call SetUnitX(caster,newX)
call SetUnitY(caster,newY)
//call SetUnitPosition(caster,newX,newY)
endif
//call DisplayTextToPlayer(GetLocalPlayer(),0,0,"Distance left, @instance "+I2S(i)+" is "+R2S(udg_D_Dist[i]))
exitwhen i==j
set i=i+1
endloop
set udg_D_Inst=j
set caster=null
set target=null
endfunction
//===========================================================================
function Dash_onCastFilter takes nothing returns boolean
return GetSpellAbilityId()==DASH_SPELL_ID()
endfunction
function Dash_onCastAction takes nothing returns nothing
local unit kb_u=GetTriggerUnit()
local unit kb_t=GetSpellTargetUnit()
local real x=GetUnitX(kb_t)-GetUnitX(kb_u)
local real y=GetUnitY(kb_t)-GetUnitY(kb_u)
local real angle=Atan2(y,x)
local integer i=udg_D_Inst+1
set udg_D_Caster[i] =kb_u
set udg_D_Target[i] =kb_t
set udg_D_KBdust[i] =AddSpecialEffectTarget("Models\\KBdust.mdx",kb_u,"origin")
call UnitAddAbility(kb_u,DASH_ONDASH_ID())
call IssueImmediateOrder(kb_u,DASH_ORDER_STR())
call SetUnitAnimationByIndex(kb_u,6)
call SetUnitTimeScale(kb_u,2.0)
if udg_D_Inst==0 then
call TimerStart(udg_D_Timer,0.03125,true,function Dash_onLoop)
endif
set udg_D_Inst=i
//call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60.00,"Index"+I2S(i))
set kb_u=null
endfunction