ID:161858
 
Anyone have a simple wander proc they can share, and show how to apply to a mob?

I know the step_rand(src) thing, but its not working, heres what i have

mob
proc
Wander()
step_rand(src)
sleep(10)
return
mob
npc
rat
Wander()
icon='Enemy.dmi'
name="{NPC} Rat"
npc=1
hp=100
def=23
 
mob
proc
Wander()
step_rand(src)
spawn(10)
while(src) // this cheaks to see if there is still a src
src.Wander() //This way once it has waited it calls the proc again
return
mob
npc
rat
Wander()
icon='Enemy.dmi'
name="{NPC} Rat"
npc=1
hp=100
def=23

In response to Lt. Pain
Wow, that's wrong on many, many levels. Please figure out what you're doing yourself before you try to help others.
Okay, first, you're going to have to make Wander() into a loop, so that it step_rand()s more than once. That's easy:

mob/proc/Wander()
while(src)
step_rand(src)
sleep(10)


Obviously, there are some things you can change here, I prefer using while(!client) instead of while(src). Both should generally be true, but if a mob has a client, then somebody is controlling them, in which case you don't want to force them to wander around. A rare case, but one that you don't want.

Now, you're going to have to call the Wander() proc. What you did yourself was simply redefine Wander() to do nothing for mob/npc/rat. What you need to do is called Wander() from the New() proc:

mob/npc/rat
New()
..() //perform any other default initialization
spawn() Wander() //call Wander() in a new thread