ID:168506
 
I want to create NPC's that roam about the world freely. So far I use a infinit proc for each of them(Not a good idea) Which is why im posting here. I want help to figure out how to make the NPC's roam the world without that being called. Any ideas Enthusiastic Foruming HackzOrz?
In response to Sinoflife
That would make him walk once. I would need to call a proc that goes over and over and over again that makes him step every time. And plus stepping randomly doesnt realy look that smart does it. Even though until I feel like creating better. I am stuck using the step_rand() proc currently; Sucks to be me huh? well... sucks to be my lazyness anyway. Im going to have to break that.
In response to Lifehunter
while(1) is a way to loop.
mob/AI/proc/Walk()
while(1)
step_rand(src)
sleep(50)

Other than that, if you don't want a looping proc, not sure.
If you do not want an infinite loop for each of them, you could just one and make use of spawn. Such as:

proc
Walking()
while(1)
for(var/obj/NPC/M)
if(istype(M,/obj/NPC/Oldguy)&&M.move)
M.move=0
spawn(50)
step_rand(M)
M.move=1
if(istype(M,/obj/NPC/Child)&&M.move)
M.move=0
spawn(10)
step_rand(M)
M.move=1
sleep(10)

This is probably not the best way to do it, but it should work, besides you not wanting to use step_rand().
In response to Kija
Yeah I figured I should use one proc. Thanks
In response to Lifehunter
proc
Walking()
var/x
while(1)
for(var/obj/NPC/M)
if(M.move)
M.move=0
switch(M.type)
if("/obj/NPC/Oldguy")
x=rand(30,60)
if("/obj/NPC/Child")
x=rand(10,20)
spawn(x)
step_rand(M)
M.move=1
sleep(10)

This would be a bit better way to do it, since it is better set up. Also, for the delay before walking, it can better to have it slightly random so that it is not so predictable and wierd looking to see several NPCs all walk at the exact same time. Or:
    Wander()
while(1)
for(var/obj/M)
if(M.move)
M.move=0
spawn(rand(M.rand[1],M.rand[2]))
step_rand(M)
M.move=1
sleep(10)