- Joined
- Feb 3, 2007
- Messages
- 58
Im currently developing a realistic arc system, basically it moves a unit from point a to point b in an arc. I need to use timers to do the loop thought but I have no idea how to use timers. So I need lots o help, heres the script:
JASS:
function PolarProjectionX takes real x, real dist, real angle returns real
return x+dist*Cos(angle*bj_DEGTORAD)
endfunction
function PolarProjectionY takes real y, real dist, real angle returns real
return y+dist*Sin(angle*bj_DEGTORAD)
endfunction
function ArcUnit takes unit u, real xA, real yA, real xB, real yB, real maxheight returns nothing
local real steps
local real halfpoint
local real PointAx
local real PointAy
local real dist
local real height = GetUnitFlyHeight(u)
local real angle = GetUnitFacing(u)
set PointAx = xA
set PointAy = yB
set dist = SquareRoot( (xB-PointAx)*(xB-PointAx)+(yB-PointAy)*(yB-PointAy))
set steps = dist/30
set halfpoint = dist/2
call SetUnitFacing(u, bj_RADTODEG * Atan2(yB - yA, xB - xA))
loop
exitwhen GetUnitX(u) == xB
exitwhen GetUnitY(u) == yB
set PointAx = PolarProjectionX( PointAx, steps, GetUnitFacing(u))
set PointAy = PolarProjectionY( PointAy, steps, GetUnitFacing(u))
if steps < halfpoint then
set height = height+20
call SetUnitFlyHeight(u,height,0)
set steps = steps-1
call SetUnitX(u, PointAx)
call SetUnitY(u, PointAy)
else
set height = height-20
call SetUnitFlyHeight(u,height,0)
call SetUnitX(u, PointAx)
call SetUnitY(u, PointAy)
set steps = steps-1
endif
endloop
endfunction