globals
constant hashtable h = InitHashtable()
endglobals
function Loop takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit u = LoadUnitHandle(h, GetHandleId(t), 1)
local real x = GetUnitX(u) + 4.
local real y = GetUnitY(u) + 4.
local location l = Location(x, y)
local real z = LoadReal(h, GetHandleId(t), 2)-GetLocationZ(l)
call SetUnitPosition(u, x, y)
call SetUnitFlyHeight(u, z, 0.)
set z = z + GetLocationZ(l)
call SaveReal(h, GetHandleId(t), 2, z)
set t = null
set u = null
endfunction
function Example takes unit u returns nothing
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local location l = Location(x, y)
local real z = GetUnitFlyHeight(u)+GetLocationZ(l)
local timer t = CreateTimer()
call UnitAddAbility(u, 'Amrf')
call UnitRemoveAbility(u, 'Amrf')
call SaveUnitHandle(h, GetHandleId(t), 1, u)
call SaveReal(h, GetHandleId(t), 2, z)
call TimerStart(t, 0.03, true, function Loop)
call RemoveLocation(l)
set l = null
set t = null
endfunction