<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/css" href="http://wiki.lostsouls.org/w/skins/common/feed.css"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>http://wiki.lostsouls.org/w/index.php?action=history&amp;feed=atom&amp;title=Man_populace</id>
		<title>Man populace - Revision history</title>
		<link rel="self" type="application/atom+xml" href="http://wiki.lostsouls.org/w/index.php?action=history&amp;feed=atom&amp;title=Man_populace"/>
		<link rel="alternate" type="text/html" href="http://wiki.lostsouls.org/w/index.php?title=Man_populace&amp;action=history"/>
		<updated>2026-05-01T11:15:34Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.8.2</generator>

	<entry>
		<id>http://wiki.lostsouls.org/w/index.php?title=Man_populace&amp;diff=4013&amp;oldid=prev</id>
		<title>Laine at 23:06, 11 June 2007</title>
		<link rel="alternate" type="text/html" href="http://wiki.lostsouls.org/w/index.php?title=Man_populace&amp;diff=4013&amp;oldid=prev"/>
				<updated>2007-06-11T23:06:20Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Description==&lt;br /&gt;
&lt;br /&gt;
We will detail here how to use the generic populace control daemon,&lt;br /&gt;
/mod/daemon/populace, to set up a daemon which will manage an area's&lt;br /&gt;
populace independently of monsters loaded in individual rooms.  This daemon&lt;br /&gt;
is designed to work well in conjunction with the generic guardian control&lt;br /&gt;
daemon (see /txt/doc/build/guardian), and has special functionality to&lt;br /&gt;
achieve this.&lt;br /&gt;
&lt;br /&gt;
The daemon creates and maintains a population for the area, distributing&lt;br /&gt;
it randomly amidst specified files.  Each reset() it creates new populace&lt;br /&gt;
to replace any killed during the intervening time.  Because it carries out&lt;br /&gt;
this population relatively slowly, to reduce processor load, it is probably&lt;br /&gt;
a good idea to have your populace daemon preloaded from your domain's&lt;br /&gt;
preload list.&lt;br /&gt;
&lt;br /&gt;
To set up the daemon requires only the use of a few configuration functions.&lt;br /&gt;
&lt;br /&gt;
===Configuration===&lt;br /&gt;
&lt;br /&gt;
void set_guardian(string daemon);&lt;br /&gt;
Sets the filename of the area's guardian daemon.  If not specified, the&lt;br /&gt;
populace daemon assumes that it is also the guardian daemon.  This is only&lt;br /&gt;
relevant if you will be defining elements of the populace as guardians.&lt;br /&gt;
&lt;br /&gt;
void set_pathfinder(string daemon);&lt;br /&gt;
Sets the filename of the area's pathfinder daemon.  If not specified, the&lt;br /&gt;
populace daemon assumes that it is also the pathfinder daemon.  This is only&lt;br /&gt;
relevant if you will be defining homes for NPCs.&lt;br /&gt;
&lt;br /&gt;
void set_weather(string daemon);&lt;br /&gt;
Sets the filename of the weather daemon to use.  If not specified, the&lt;br /&gt;
central MUD weather daemon is assumed.  This is only relevant if you will&lt;br /&gt;
be defining NPC homes which vary between day and night.&lt;br /&gt;
&lt;br /&gt;
void add_file_selector(string sel);&lt;br /&gt;
Defines a pattern for retrieving files which the area's populace will be&lt;br /&gt;
randomly distributed within.  The easiest way to do this is to simply use&lt;br /&gt;
the area's room macro with wildcards.  For instance, if you wanted to have&lt;br /&gt;
the populace defined spread among all rooms in the area whose filenames&lt;br /&gt;
began with the word &amp;quot;street&amp;quot;, you could do:&lt;br /&gt;
&lt;br /&gt;
	add_file_selector(Area_Room(&amp;quot;street*&amp;quot;));&lt;br /&gt;
&lt;br /&gt;
If multiple file selectors are used, any rooms consistent with more than&lt;br /&gt;
one will behave as if &amp;quot;weighted&amp;quot;; i.e. a room which is returned by two file&lt;br /&gt;
selectors will be twice as likely to show up as a room which is returned by&lt;br /&gt;
only one.&lt;br /&gt;
&lt;br /&gt;
void set_file_selectors(string *sels);&lt;br /&gt;
Sets the array of all file selectors used by the daemon.&lt;br /&gt;
&lt;br /&gt;
void add_file_target(string targ);&lt;br /&gt;
Sets an explicit filename to be used in addition to any files retrieved&lt;br /&gt;
by file selectors.  As with selectors, weighting behavior results if a file&lt;br /&gt;
ends up being specified more than once.&lt;br /&gt;
&lt;br /&gt;
void set_file_targets(string *targ);&lt;br /&gt;
Sets the array of all file targets used by the daemon.&lt;br /&gt;
&lt;br /&gt;
varargs void add_population(string file, int number, status guard);&lt;br /&gt;
Defines a population of monsters to distribute within the area.  The&lt;br /&gt;
first argument is the filename from which to clone the monsters.  The second&lt;br /&gt;
argument is the number which should exist within the area.  The third,&lt;br /&gt;
optional, argument is a flag which should be set to true if the monsters&lt;br /&gt;
being specified should function as area guardians.&lt;br /&gt;
&lt;br /&gt;
void set_populations(mapping map);&lt;br /&gt;
Sets the mapping of all populations used by the daemon.  This is a&lt;br /&gt;
two-value mapping containing the settings delineated by add_population().&lt;br /&gt;
It is recommended that you use add_population() rather than this function&lt;br /&gt;
for ease of configuration.&lt;br /&gt;
&lt;br /&gt;
varargs void add_person(string file, mixed home, status guard);&lt;br /&gt;
Adds an individual (a non-cloned NPC) to the area's population.  The&lt;br /&gt;
first argument is the NPC's filename.  The second, optional, argument&lt;br /&gt;
designates the filename of the NPC's home; if this is specified the NPC&lt;br /&gt;
will be placed at this location when created and will attempt to return&lt;br /&gt;
to it periodically if it has moved.  You may also specify a two-element&lt;br /&gt;
string array; the first element is the NPC's home during the day and the&lt;br /&gt;
second is its home at night.  If the home value or either element of a&lt;br /&gt;
home array are closures, they will be resolved, being passed an argument&lt;br /&gt;
of the NPC in question.  If nothing is specified the NPC will be&lt;br /&gt;
distributed randomly amidst the locations defined by the daemon's file&lt;br /&gt;
selectors just like the rest of the population.  The third argument, also&lt;br /&gt;
optional, should be set to true if the NPC should function as an area&lt;br /&gt;
guardian.&lt;br /&gt;
&lt;br /&gt;
void set_people(mapping map);&lt;br /&gt;
Sets the mapping of all people managed by the daemon.  This is a two-&lt;br /&gt;
value mapping containing the settings delineated by add_person().  It is&lt;br /&gt;
recommended that you use add_person() rather than this function for ease&lt;br /&gt;
of configuration.&lt;br /&gt;
&lt;br /&gt;
status set_populate_func(mixed func);&lt;br /&gt;
Modifies the behavior associated with creating a new element of the&lt;br /&gt;
populace.  The functions specified are passed the character in question&lt;br /&gt;
and the room to which the character is to be moved upon creation.  If any&lt;br /&gt;
of them return true, or the character is destructed, the character will not&lt;br /&gt;
be moved to that location.&lt;br /&gt;
&lt;br /&gt;
status set_travel_func(mixed func);&lt;br /&gt;
Modifies the behavior associated with a person about to return to its&lt;br /&gt;
home.  The functions specified are passed the person in question, the&lt;br /&gt;
person's current environment, and the room the person wishes to return to.&lt;br /&gt;
If any of them return true, the person does not return.&lt;br /&gt;
&lt;br /&gt;
status remove_travel_func(mixed func);&lt;br /&gt;
Removes a previously set travel_func.&lt;br /&gt;
&lt;br /&gt;
status set_traveling_func(mixed func);&lt;br /&gt;
Modifies the behavior associated with a person about to move one step on&lt;br /&gt;
the way back to its home.  The functions specified are passed arguments of&lt;br /&gt;
the person, its environment, the room it is returning to, and an array&lt;br /&gt;
containing the string directions which it currently needs to move through&lt;br /&gt;
to reach its home.  If any of them return true, the person does not take&lt;br /&gt;
this step in its traveling.&lt;br /&gt;
&lt;br /&gt;
status remove_traveling_func(mixed func);&lt;br /&gt;
Removes a previously set traveling_func.&lt;br /&gt;
&lt;br /&gt;
status set_traveled_func(mixed func);&lt;br /&gt;
Called when a person has just finished traveling to its home.  The&lt;br /&gt;
functions specified are passed arguments of the person, its home, and the&lt;br /&gt;
direction it just moved.  Their return values are ignored.&lt;br /&gt;
&lt;br /&gt;
status remove_traveled_func(mixed func);&lt;br /&gt;
Removes a previously set traveled_func.&lt;br /&gt;
&lt;br /&gt;
===Operational Use===&lt;br /&gt;
&lt;br /&gt;
mapping query_populace_active();&lt;br /&gt;
You may use this function to retrieve the data which the daemon uses to&lt;br /&gt;
track existing monsters in its population base.  This mapping's indices are&lt;br /&gt;
the filenames of population elements; its values are arrays of monsters.&lt;br /&gt;
These arrays may contain zero-value elements when monsters have been killed.&lt;br /&gt;
Note that this mapping only tracks &amp;quot;populace&amp;quot;, not &amp;quot;people&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
status query_populace_managed(object obj);&lt;br /&gt;
This function returns true if the object sent is managed by the populace&lt;br /&gt;
daemon, whether as a 'populace' or 'people' object.  Cloned objects will be&lt;br /&gt;
examined for whether they are part of 'populace', non-clones will be examined&lt;br /&gt;
for whether they are part of 'people'.&lt;/div&gt;</summary>
		<author><name>Laine</name></author>	</entry>

	</feed>