function SlideUnit_Action takes nothing returns nothing
local trigger t = GetTriggeringTrigger()
local unit u = GetHandleUnit(t,"u")
local real a = GetHandleReal(t,"a")
local real d = GetHandleReal(t,"d")
local real l = GetHandleReal(t,"l")
local real r = GetHandleReal(t,"r")
local real s = GetHandleReal(t,"s")
local real x = GetUnitX(u)
local real y = GetUnitY(u)
local rect e = bj_mapInitialPlayableArea
set s = s + l
if s >= r then
call DestroyTrigger(t)
call FlushHandleLocals(t)
set t = null
else
if (GetRectMinX(e) <= x) and (x <= GetRectMaxY(e)) and (GetRectMinY(e) <= y) and (y <= GetRectMaxY(e)) == true then
call SetUnitX(u,x + (d/r*l) * Cos(a * 0.017))
call SetUnitY(u,y + (d/r*l) * Sin(a * 0.017))
endif
call SetHandleReal(t,"s",s)
endif
set t = null
set u = null
set a = 0
set d = 0
set l = 0
set s = 0
set x = 0
set y = 0
endfunction
function SlideUnit takes unit u,real a,real d,real r,real l returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterTimerEvent(t,l,true)
call TriggerAddAction(t,function SlideUnit_Action)
call SetHandleHandle(t,"u",u)
call SetHandleReal(t,"a",a)
call SetHandleReal(t,"d",d)
call SetHandleReal(t,"l",l)
call SetHandleReal(t,"r",r)
set u = null
set a = 0
set d = 0
set l = 0
endfunction