mob/proc/
DO_MOVEMENT()
set background=1
if(Moving)return;Moving=1
var/FirstStep=1
if(super_speed)FirstStep = 0
while(MN || ME || MW || MS || QueN || QueS || QueE || QueW)
if(!speed_run)
if(run) icon_state="Run"
if(MN || QueN)
if(ME || QueE) if(!step(src,NORTHEAST) && !step(src,NORTH)) step(src,EAST)
else if(MW || QueW) if(!step(src,NORTHWEST) && !step(src,NORTH)) step(src,WEST)
else step(src,NORTH)
else if(MS || QueS)
if(ME || QueE) if(!step(src,SOUTHEAST) && !step(src,SOUTH)) step(src,EAST)
else if(MW || QueW) if(!step(src,SOUTHWEST) && !step(src,SOUTH)) step(src,WEST)
else step(src,SOUTH)
else if(ME || QueE) step(src,EAST)
else if(MW || QueW) step(src,WEST)
QueN=0;QueS=0;QueE=0;QueW=0
if(FirstStep) {sleep(1);FirstStep=0}
sleep(GetMovementSpeed())
Moving=0
icon_state = ""
mob/verb
MoveNorth()
set hidden=1;set instant=1;set background = 1
src.SprintCheck("North")
src.MN=1;src.MS=0;QueN=1;src.MovementLoop()
Problem description:
Any ideas of how I can reduce cpu usage for this movement loop?
TL;DR: Don't use 8 variables to keep track of movement controls. There's no need for more than two variables to keep track of the key state and movement direction.
Also, you are using a lot of booleans where arithmetic operators would work to prevent lookups and if-statements.
You also shouldn't be setting any of these things to the background. That's a symptom of some pretty serious problems in the rest of your code.