//****************************************************************************************
// Arc movement
// Usage: call arcmovement(whichUnit,speed,heightspeed,distance)
//
// Example: "Custom script: call arcmovement(MyUnit,10,10,5)"
//
// PUT ME IN YOUR MAP HEADER !
//
function arc takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit whichUnit = GetHandleUnit(t, "whichUnit")
local real speed = GetHandleReal(t, "speed")
local real heightspeed = GetHandleReal(t, "heightspeed")
local real startspeed = GetHandleReal(t, "startspeed")
local real distance = GetHandleReal(t, "distance")
local integer i = GetHandleInt(t, "i")
local real a = GetUnitFacing(whichUnit) * bj_DEGTORAD
local real x = GetUnitX(whichUnit) + speed * Cos(a)
local real y = GetUnitY(whichUnit) + speed * Sin(a)
local real z
local location l = GetUnitLoc(whichUnit)
local real lz = GetLocationZ(l)
local location nextl = Location(x,y)
local real nextlz = GetLocationZ(nextl)
if lz != nextlz then
set lz = lz-nextlz
call SetUnitFlyHeight(whichUnit, lz, 1000000)
endif
set heightspeed = startspeed-i*distance
set z = GetUnitFlyHeight(whichUnit) + heightspeed
if startspeed+heightspeed == 0 then
call FlushHandleLocals(t)
call DestroyTimer(t)
else
call SetHandleInt(t, "i", i + 1)
call SetHandleReal(t, "hieghtspeed", heightspeed)
call SetUnitPosition(whichUnit, x, y)
call SetUnitFlyHeight(whichUnit, z, 1000000)
endif
set whichUnit = null
set t = null
call RemoveLocation(l)
set l = null
endfunction
function arcmovement takes unit whichUnit, real speed, real heightspeed, real distance returns nothing
local timer t = CreateTimer()
local integer i = 0
local real startspeed = speed
call SetHandleReal(t, "distance", distance)
call SetHandleReal(t, "startspeed", startspeed)
call SetHandleInt(t, "i", i)
call SetHandleHandle(t, "whichUnit", whichUnit)
call SetHandleReal(t, "speed", speed)
call SetHandleReal(t, "heightspeed", heightspeed)
call TimerStart(t, 0.02, true, function arc)
set t = null
endfunction