I'm working on a Movent system in which units start at slow movespeed and increase gradually to their max movement speed. After reaching their top speed, units gain fatigue constantly until their fatigue reaches 100%. While stopped for any reason, units' fatigue wears off.
If a unit stops moving and then resumes moving while below 50% fatigue, it will move without gaining fatigue until it reachs max speed. If a unit stops and then resumes moving while above 50% fatigue, it will continue to gain fatigue. If a unit's fatigue reaches 100%, the unit will be paused until it's fatigue reaches 0%.
The functions are written by me (mostly) with some help from zeroXD, Moyack (the last two functions were entirely Moyack's design), and Rising_Dusk; however, I am hoping to get some feedback as to what doesn't seem right/what could be improved. The system is not complete, but it is fully functional as is. I've attached a map to test it out.

JASS:
function Is_Unit_Moving takes nothing returns nothing
local unit Moving_Unit = GetEnumUnit()
local real Moving_Point_X = GetUnitX( Moving_Unit )
local real Moving_Point_Y = GetUnitY( Moving_Unit )
local real Moving_Point_X2
local real Moving_Point_Y2
local real Moving_Distance
call TriggerSleepAction( 0.00 )
set Moving_Point_X2 = GetUnitX( Moving_Unit )
set Moving_Point_Y2 = GetUnitY( Moving_Unit )
set Moving_Distance = SquareRoot( (Moving_Point_X2-Moving_Point_X)*(Moving_Point_X2-Moving_Point_X)+(Moving_Point_Y2-Moving_Point_Y)*(Moving_Point_Y2-Moving_Point_Y) )
if Moving_Distance > 0 then
call SetUnitMoveSpeed( Moving_Unit, (GetUnitMoveSpeed(Moving_Unit)+5.00) )
if GetUnitMoveSpeed( Moving_Unit ) >= GetUnitDefaultMoveSpeed( Moving_Unit ) then
call GroupAddUnit( udg_Fatigue_Group, Moving_Unit )
call SetUnitMoveSpeed( Moving_Unit, GetUnitDefaultMoveSpeed(Moving_Unit) )
else
endif
if IsUnitInGroup( Moving_Unit, udg_Fatigue_Group ) == true then
call SetUnitUserData( Moving_Unit, (GetUnitUserData(Moving_Unit)+1) )
else
endif
if GetUnitUserData(Moving_Unit) >= 200 then
call PauseUnit( Moving_Unit, true )
call DisplayTextToPlayer( GetOwningPlayer(Moving_Unit), 0.00, 0.00, "Your unit is too fatigued to run any more. Wait a bit while he or she rests." )
call GroupAddUnit( udg_Pause_Group, Moving_Unit )
else
endif
else
call SetUnitMoveSpeed( Moving_Unit, 5 )
if GetUnitUserData(Moving_Unit) > 0 then
call SetUnitUserData( Moving_Unit, (GetUnitUserData(Moving_Unit)-1) )
else
endif
if GetUnitUserData(Moving_Unit) <= 100 and IsUnitInGroup(Moving_Unit, udg_Fatigue_Group) == true then
call GroupRemoveUnit( udg_Fatigue_Group, Moving_Unit )
else
endif
if IsUnitInGroup( Moving_Unit, udg_Pause_Group ) == true and GetUnitUserData( Moving_Unit ) == 0 then
call PauseUnit( Moving_Unit, false )
else
endif
endif
set Moving_Unit = null
endfunction

Moyack's Functions:
function ForGroupUnitMoving takes nothing returns nothing
call ExecuteFunc("Is_Unit_Moving")
endfunction
function Main_Function_Moving takes nothing returns nothing
local group Moving_Units = GetUnitsInRectAll( GetWorldBounds() )
call ForGroup( Moving_Units, function ForGroupUnitMoving )
call DestroyGroup( Moving_Units )
set Moving_Units = null
endfunction
Trigger:
Initilization MS Set

Events

Conditions

Actions


Set All_Units = (Units in (Entire map))


Unit Group - Pick every unit in All_Units and do (Unit - Set (Picked unit) movement speed to 5.00)


Custom script: call DestroyGroup( udg_All_Units )


Floating Text - Create floating text that reads (Fatigue: + ((String((Custom value of Knight 0002 <gen>))) + %)) above Knight 0002 <gen> with Z offset 0.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency


Set Knight_Value = (Last created floating text)


Floating Text - Create floating text that reads (Movement Speed: + (String((Current movement speed of Knight 0002 <gen>)))) above Knight 0002 <gen> with Z offset 50.00, using font size 10.00, color (100.00%, 100.00%, 100.00%), and 0.00% transparency


Set Knight_Speed = (Last created floating text)