AI Wander

by Dark Hollow Games
Ever wanted NPCs to wander around like zombies?
ID:239348
 
Ever wanted NPCs to wander around like zombies? Well, that can't really happen in this library, they don't chase you! But, they do wander, and it quite gives them more of a human-like way of thinking. Ha! Enjoy.
Can it do anything that step_rand() can't do, besides the random sleep() calls?
I typed this up in about 10 seconds, so I believe not. But if no random sleep() calls, then it wouldn't succeed in it's purpose, now would it? ^^
`-`
mob //Declaring it's going to be a mob
NPC //Better Specification of what kind of mob (Can be anything, but in this case, it's named NPC.)
Guy //NPC Clarification of which (Name)
icon='NPCs.dmi' //the npc's icon file
icon_state="Guy" //specification of the name of the icon in the icon file.
New() //Creating a new proc
..() //declaring the new proc
while(src) //Explaining when to run the process
if(prob(rand(80,90)))//Rolling a dice (Giving the illusion it is running on ticks.)
step_rand(src) //Making the src(mob/NPC/Guy) step randomly
sleep(rand(40,120)) //Resetting the Proc

mob //Declaring it's going to be a mob
NPC //Better Specification of what kind of mob (Can be anything, but in this case, it's named NPC.)
Guy //NPC Clarification of which (Name)
icon='NPCs.dmi' //the npc's icon file
icon_state="Guy" //specification of the name of the icon in the icon file.
New() //Creating a new proc
..() //declaring the new proc
while(src) //Explaining when to run the process
walk_rand(src,rand(40,120))


What you did was define an already built in proc, when you could have made it alot shorter, and more helpful to new programmers.

/*
Format:
walk_rand(Ref,Lag=0,Speed=0)
Args:
Ref: A mob or obj.
Lag: Delay in world ticks between movement.
Speed: Speed to move, in pixels. 0 uses Ref.step_size. */
If you are interested in knowing how it works.
Cheers.
In response to Avainer1
Avainer1 wrote:
What you did was define an already built in proc

walk_rand() does not vary the time between each movement
In response to Falacy
Lag: Delay in world ticks between movement.

huh
That delay is the same between each movement. Even if you pass it a rand() value, it is only configured once.
why is this allowed to be a library