LPMuds.net
February 09, 2010, 02:37:21 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News: This is the forum page. For the main LPMuds page, visit http://lpmuds.net
 
   Home   SITE FAQ INTERMUD DOWNLOADS LINKS Help Search Login Register  
Pages: [1]   Go Down
  Print  
Author Topic: Wandering NPC's  (Read 614 times)
shigs
Acquaintance
*
Offline Offline

Posts: 37



View Profile
« on: August 21, 2008, 01:58:59 PM »

Does DS has functionality for wandering NPC's built in?
Logged

Raudhrskal
BFF
***
Offline Offline

Posts: 189


The MUD community needs YOUR help!


View Profile
« Reply #1 on: August 21, 2008, 02:08:47 PM »

Yes, if you use LIB_SENTIENT in place of LIB_NPC.

Read /lib/sentient.c and look for the functions with Wander in name.

SetWander(speed_as_intger);

Optionally SetPermitLoad(1); if you want the npc to be able to load rooms (if not it won't move at all until some player will load adjacent room).
Logged

I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...
Atomic
BFF
***
Offline Offline

Posts: 108


To infinity and beyond!


View Profile
« Reply #2 on: August 21, 2008, 02:38:06 PM »

In this light: is it possible for NPC's to walk specific given routes? 2nd, if it is possible to just make them wander, but restrict them to specific area types/attributes (_desert, _arctic, or _town, _forest) ?

Logged

Always remember that the early bird gets the worm first, but the fi...*SNAP*...second mouse gets the cheese.
Raudhrskal
BFF
***
Offline Offline

Posts: 189


The MUD community needs YOUR help!


View Profile
« Reply #3 on: August 21, 2008, 02:51:15 PM »

Look into sentient.c . If I understand the code correctly, you can set wanderpath (as a second arg to SetWander or by SetWanderPath). It's an array which can contain strings ("go west", "open door", "go east", "press button") or (: function_pointers Smiley which are called. The function can examine the environment or sth, and return a command string.

Elements of the array are called in sequence, looping from last to first.

If you want to restrict to one terrain type, make a one-element array linking to a function, which checks terrain type of adjacent rooms, and randomly chooses one of the correct type.
« Last Edit: August 21, 2008, 02:57:16 PM by Raudhrskal » Logged

I think, therefore i may be wrong.
Please note that if you met a Raudhrskal in a place that's not related to muds, it wasn't me. *sigh*... back when I started there was zero hits on google for that name...
Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.11 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!