Man location

From LSWiki

Revision as of 16:44, 11 June 2007; Laine (Talk | contribs)
(diff) ←Older revision | Current revision | Newer revision→ (diff)
Jump to: navigation, search

Contents

Files

/def/descriptor/location.c
/lib/descriptor/location.h
/daemon/locations.c
/lib/locations.h

Description

Location descriptors are used by the random location selection system. Locations which are suitable for random selection are registered with the locations daemon using location descriptors, and the descriptors are used in the selection process.

The standard support module for control daemons includes functions for registering locations for use by the random location system, which is referred to as "publishing" them. Example of items being published from a project control daemon:

   #include <Project.h>
   inherit "/std/daemon";
   inherit "/mod/daemon/control";
   #include <daemon.h>
   void configure() {
       ::configure();
       // set_creator(), set_area(), extensions, and so on here...
       add_published_location(Project_Room("entrance"), Rarity_Unusual,
           Location_Danger_Safe);
       add_published_location(([
           Location_File   : ({
               Project_Room("hall1"),
               Project_Room("hall2"),
               Project_Room("hall3"),
           }),
           Location_Rarity : Rarity_Very_Rare,
           Location_Danger : Location_Danger_Moderate,
       ]));
       add_published_location(([
           Location_File   : (:
               if(Project_Daemon("control")->query_trap_sprung())
                   return Project_Room("pit");
               else
                   return Project_Room("trap");
           :),
           Location_Rarity : Rarity_Exotic,
           Location_Danger : Location_Danger_Extreme,
           Location_Egress : Location_Egress_Restricted,
       ]));
   }

Public Fields

Location_File: Designates the file name of the location. Required. A set of rooms, rather than a single one, may be designated; this is done to avoid flooding the random locations list with many similar rooms. Note that when this is done, the rooms in the list should be as similar in configuration as possible, so that any given one can be examined as representative of the group. Can be any of the following:

   A string object name
   An array of string object names (which will be passed through
       random_element() to find the final object to use)
   A mapping of string object names to integer weights (which will
       be passed through random_element() as with an array)
   A closure, which may return any of the above or an object

Location_Rarity: The general rarity with which the location is to be selected. This is an integer rarity value from rarity.h. Required.

Location_Danger: A general indication of how dangerous the location is. Required. Factors to take into account when selecting this value include any environmental dangers and hostile characters present or nearby. The values that can be used are:

   Location_Danger_Sanctuary: The location protects those in it, as
       with the Losthaven cathedral.
   Location_Danger_Safe: The location is generally safe.
   Location_Danger_Low: The location has a low level of danger.
   Location_Danger_Moderate: The location is moderately dangerous.
   Location_Danger_High: The location is highly dangerous.
   Location_Danger_Extreme: The location is extremely dangerous.

Location_Egress: A general indication of how difficult it is to leave the location or its general area. The values that can be used are:

   Location_Egress_Ordinary: There are no unusual obstacles to
       leaving the location.  (This is the default.)
   Location_Egress_Difficult: There are some obstacles to leaving the
       location, though the location is not designed to be difficult
       to leave (or if it is, the measures are not very effective).
   Location_Egress_Restricted: The location is designed specifically,
       and effectively, to prevent departure, as with a jail cell or
       trap room.

Internal Fields

Location_Object: Query this field to retrieve a sample room object for the location. The room will be loaded if it has not yet been. Do not set this field.

Location_Tag: The tag for the descriptor system.

Support Functions

object Location_Resolve(descriptor dxr)

Used to obtain the final room object from a descriptor, evaluating any closure targets and selecting from among any random distribution lists, loading the room, and returning it.

See Also

descriptors(mechanisms), rarity(mechanisms), selection(mechanisms), item(descriptors), character(descriptors)

Personal tools