function knockbacktimer takes nothing returns nothing
local timer t = GetExpiredTimer()
local unit whichUnit = GetHandleUnit(t, "whichUnit")
local real knockback = GetHandleReal(t, "knockback")
local real angle = GetHandleReal(t, "angle")
local real a = angle * bj_DEGTORAD
local real x = GetUnitX(whichUnit) + knockback * Cos(a)
local real y = GetUnitY(whichUnit) + knockback * Sin(a)
call SetUnitPosition(whichUnit, x, y)
set knockback = knockback-0.5
call SetHandleReal(t, "knockback", knockback)
if knockback <= 0 then
call FlushHandleLocals(t)
call DestroyTimer(t)
endif
set t = null
set whichUnit = null
endfunction
function Knockback takes unit whichUnit, real knockback, real angle returns nothing
local timer t = CreateTimer())
call SetHandleHandle(t, "whichUnit", whichUnit)
call SetHandleReal(t, "knockback", knockback)
call SetHandleReal(t, "angle", angle)
call TimerStart(t, 0.02, true, function knockbacktimer)
set t = null
endfunction