function SpdX takes real Spd, real Angle returns real
return (Spd * Cos(Angle) )
endfunction
function SpdY takes real Spd, real Angle returns real
return (Spd * Sin(Angle) )
endfunction
function KBUnit takes unit Vic, real Speed, real Angle returns nothing
SetUnitX( Vic, (GetUnitX( Vic ) + SpdX( Speed, Angle )) )//Syntax error, prolly up one line.
SetUnitY( Vic, (GetUnitY( Vic ) + SpdY( Speed, Angle )) )
endfunction
function Nint takes nothing returns real
return 0.035
endfunction
function Collision takes unit Vic, unit Agr, real Friction returns nothing
local timer Tim = CreateTimer()
local real Speed = GetUnitMoveSpeed( Agr )
local real Angle = GetUnitFacing( Agr )
loop
exitwhen (Speed == 0)
call TimerStart( Tim, Nint(), true, function KBUnit( Vic, Speed, Angle ) )//Syntax error, prolly up one line.
set Speed = Speed - Friction
endloop
call DestroyTimer( Tim )
set Tim = null
endfunction
function Movement takes unit Cast, location Target returns nothing
local timer Tim = CreateTimer()
local location Casloc = GetUnitLoc( Cast )
local real Speed = GetUnitMoveSpeed( Cast )
local real Dist = DistanceBetweenPoints( Casloc, Target )
local real Angle = AngleBetweenPoints( Casloc, Target )
loop
exitwhen (Dist == 0)
if (Speed > Dist) then
call TimerStart( Tim, Nint(), true, function KBUnit( Cast, Dist, Angle ) )//Syntax error, prolly up one line.
else
call TimerStart( Tim, Nint(), true, function KBUnit( Cast, Speed, Angle ) )//Syntax error, prolly up one line.
endif
set Casloc = GetUnitLoc( Cast )
set Dist = DistanceBetweenPoints( Casloc, Target )
set Angle = AngleBetweenPoints( Casloc, Target )
endloop
set Casloc = null
endfunction