function Parabula takes real H, real T, real x returns real
return ((4*H)/-(T*T))*(x*x) + ((4*H)/T)*x
endfunction
function Jump_High takes nothing returns real
return 500.0
endfunction
function Jump_Conditions takes nothing returns boolean
return GetSpellAbilityId() == 'A000'
endfunction
function Jump_Move_Up takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit caster = GetHandleUnit(t, "caster")
local integer loopindex = GetHandleInt(t, "highindex") + 1
local real cz = GetUnitZ(caster)
local real z = Parabula(Jump_High(), 0.98, I2R(loopindex)/28.0)
call SetUnitZ(caster, z)
if (loopindex >= 28) then
call PauseTimer(t)
call FlushHandleLocals(t)
call DestroyTimer(t)
set t = null
else
call SetHandleInt(t, "highindex", loopindex)
endif
endfunction
function Jump_Move_Forward takes nothing returns nothing
local timer tforward = GetExpiredTimer()
local unit caster = GetHandleUnit(tforward, "caster")
local real range = GetHandleReal(tforward, "range")
local real angle = GetHandleReal(tforward, "angle")
local real cx = GetUnitX(caster)
local real cy = GetUnitY(caster)
local real xforward = cx + (range / 28) * Cos(angle * bj_DEGTORAD)
local real yforward = cy + (range / 28) * Sin(angle * bj_DEGTORAD)
local integer loopindex = GetHandleInt(tforward, "forwardindex")
call SetUnitX(caster, xforward)
call SetUnitY(caster, yforward)
set loopindex = loopindex + 1
if (loopindex >= 28) then
call PauseTimer(tforward)
call FlushHandleLocals(tforward)
call DestroyTimer(tforward)
set tforward = null
else
call SetHandleInt(tforward, "forwardindex", loopindex)
endif
endfunction
function Jump_Actions takes nothing returns nothing
local timer tup = CreateTimer()
local timer tforward = CreateTimer()
local unit caster = GetSpellAbilityUnit()
local unit target = GetSpellTargetUnit()
local real cx = GetUnitX(caster)
local real cy = GetUnitY(caster)
local real tx = GetUnitX(target)
local real ty = GetUnitY(target)
local real dx = tx - cx
local real dy = ty - cy
local real range = SquareRoot(dx*dx + dy*dy)
local real angle = Atan2(dy,dx) * bj_DEGTORAD * 3600
call SetHandleHandle(tup, "caster", caster)
call TimerStart(tup, 0.035, true, function Jump_Move_Up)
call SetHandleHandle(tforward, "caster", caster)
call SetHandleReal(tforward, "range", range)
call SetHandleReal(tforward, "angle", angle)
call TimerStart(tforward, 0.035, true, function Jump_Move_Forward)
endfunction
// ==================================================
function InitTrig_Jump takes nothing returns nothing
set gg_trg_Jump = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Jump, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddCondition( gg_trg_Jump, Condition( function Jump_Conditions ) )
call TriggerAddAction( gg_trg_Jump, function Jump_Actions )
endfunction