cleeezzz
The Undead Ranger.
- Reaction score
- 268
JASS:
library Jump initializer Init requires KT
globals
private constant integer FLY_ID = 039;Amrf039;
private location tp
endglobals
private struct JS
unit ju
real a
real b
real c
real cx
real lz
real lx
real ly
real ex
real ey
real arch
real angle
real s
method onDestroy takes nothing returns nothing
call PauseUnit(.ju,false)
call SetUnitPathing(.ju,true)
call SetUnitFlyHeight(.ju,0.,0.)
set .ju = null
endmethod
endstruct
private function GetUnitZ takes unit u returns real
call MoveLocation(tp, GetUnitX(u),GetUnitY(u))
return GetUnitFlyHeight(u) + GetLocationZ(tp)
endfunction
private function GetZ takes real x, real y returns real
call MoveLocation(tp, x,y)
return GetLocationZ(tp)
endfunction
private function SetUnitZ takes unit u, real z returns nothing
local real rz
call MoveLocation(tp,GetUnitX(u),GetUnitY(u))
set rz = z-GetLocationZ(tp)
call SetUnitFlyHeight(u,rz,0.)
endfunction
private function Motion takes nothing returns boolean
local JS d = KT_GetData()
local real x
local real y
local real z
local real speed
local real dist
if UnitAlive(d.ju) == false then
call d.destroy()
return true
endif
set x = GetUnitX(d.ju)
set y = GetUnitY(d.ju)
set z = GetUnitZ(d.ju)
set dist = SquareRoot((d.lx-x)*(d.lx-x) + (d.ly-y)*(d.ly-y))
set d.cx = d.cx + dist
set d.lx = x
set d.ly = y
set d.lz = z
set speed = (d.s*Sin((90.-(Atan((d.a*2)*d.cx+d.b))*bj_RADTODEG)*bj_DEGTORAD))/Sin(90.*bj_DEGTORAD)
set x = x+speed*Cos(d.angle)
set y = y+speed*Sin(d.angle)
call SetUnitX(d.ju,x)
call SetUnitY(d.ju,y)
set z = d.a*(Pow(d.cx,2)) + d.b*d.cx + d.c
call SetUnitZ(d.ju,z)
if z <= 0 then
call d.destroy()
return true
endif
return false
endfunction
function UnitJump takes unit u, real tarx, real tary, real arcZ, real speed returns nothing
local JS d = JS.create()
local real ux = GetUnitX(u)
local real uy = GetUnitY(u)
local real dist = SquareRoot((ux-tarx)*(ux-tarx)+(uy-tary)*(uy-tary))
call UnitAddAbility(u,FLY_ID)
call UnitRemoveAbility(u,FLY_ID)
set d.ju = u
set d.lx = ux
set d.ly = uy
set d.ex = tarx
set d.ey = tary
set d.cx = 0.
set d.lz = GetUnitZ(u)
set d.s = speed
set d.arch = arcZ
set d.angle = Atan2((tary-d.ly),(tarx-d.lx))
call SetUnitFacing(u,d.angle*bj_RADTODEG)
set d.c = d.lz
set d.b = (-dist-SquareRoot(Pow(dist,2)+(-4*((-Pow(dist,2))/((d.arch-d.c)*4))*d.c)))/(2*((-Pow(dist,2))/((d.arch-d.c)*4)))
set d.a = (-d.c-(dist*d.b))/Pow(dist,2)
call SetUnitPathing(d.ju,false)
call PauseUnit(d.ju,true)
call KT_Add(function Motion, d, 0.03)
endfunction
private function Init takes nothing returns nothing
set tp = Location(0.,0.)
endfunction
endlibrary
Does not work correctly when jumping to a cliff thats higher than original point. See video.
http://www.youtube.com/watch?v=aXqUeyptkyE
(Note: vid may still be processing)
As you can see, the unit slides to the edge of the cliff before jumping.. why?