ID:1442444
 
(See the best response by Ter13.)


how do i make npcs move slower or faster?:

Best response
Are you using the walk() command? Look up the lag property of that command.

If you are using a loop with step(), just sleep between steps.

NPCs can't move any faster than 1 time per tick, so consider making their movement more than one tile in distance per tick.
New()
src.health=src.maxhealth
src.mana=src.maxmana
spawn()
src.Wander()
return ..()
proc/Wander()
while(src)
if(src.Frozen == 1)
break
else
if(src.Target)
if(get_dist(src,src.Target)>1 && !step_to(src,src.Target,1))
src.Target=null;continue
src.dir=get_dir(src,src.Target)
src.Fight()
if(!ListCheck(src.Target,oview(5)))
src.Target=null
sleep(rand(1,2))
else
sleep(rand(10,15))

if(!src.Target)
for(var/mob/M in oview(4))
if(M.key)
if(step_to(src,M,1))
src.Target=M
sleep(5)
break

this is the code,i try to change the lag but i cant figure out where
Like I said above. sleep() makes instructions wait to process.
New()
src.health=src.maxhealth
src.mana=src.maxmana
spawn()
src.Wander()
return ..()
proc/Wander()
while(src)
if(src.Frozen == 1)
break
else
if(src.Target)
if(get_dist(src,src.Target)>1 && !step_to(src,src.Target,1))
src.Target=null;continue
src.dir=get_dir(src,src.Target);sleep(5)
src.Fight()
if(!ListCheck(src.Target,oview(5)))
src.Target=null
sleep(rand(1,2))
else
sleep(rand(10,15))

if(!src.Target)
for(var/mob/M in oview(4))
if(M.key)
if(step_to(src,M,1))
src.Target=M
sleep(5)
break

i altered it but it still wont slow down the npc
Alter the existing sleep instructions. Don't add new ones all willy-nilly. That's just crazy.
i tryed to change them all still no use
In response to Tiago7727
Tiago7727 wrote:
i tryed to change them all still no use

I wasn't guessing.
Format:
step_to(Ref,Trg,Min=0,Speed=0)
Returns:
1 on success; 0 otherwise.
Args:
Ref: A mob or obj.
Trg: An object on the map.
Min: The minimum distance between Ref and Trg before movement halts.
Speed: Speed to move, in pixels. 0 uses Ref.step_size.


I'm assuming you can alter the "speed" there and set it lower. Other than that, Ter was pretty correct on the sleeps. They usually work.
sorry but im kind of a noobie, can you say it in a more simple way?