AI Wander

by Dark Hollow Games
Ever wanted NPCs to wander around like zombies? [More]
To download this library for your Linux/Mac installation, enter this on your command line:

DreamDownload byond://DarkHollowGames.AIWander##version=0

Emulator users, in the BYOND pager go to File | Open Location and enter this URL:

byond://DarkHollowGames.AIWander##version=0

242 downloads
Version 1
Date added: Feb 1 2012
Last updated: Feb 11 2012
1 fan
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.

Comments

Bumblemore: (Feb 5 2013, 11:39 am)
why is this allowed to be a library
Falacy: (Feb 8 2012, 12:13 am)
That delay is the same between each movement. Even if you pass it a rand() value, it is only configured once.
Avainer1: (Feb 7 2012, 11:36 pm)
Lag: Delay in world ticks between movement. 

huh
Falacy: (Feb 7 2012, 11:09 pm)
Avainer1 wrote:
What you did was define an already built in proc

walk_rand() does not vary the time between each movement
Avainer1: (Feb 7 2012, 10:44 pm)
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.