[Package Index | Mudlib Index | Effect Index]
File /obj/handlers/gathering.c
Handler to handle the gathering of implicitly existing
objects that require some skill to find, such as herbs.
Recognition (ie, knowing what it is once you've found it) may be
added later.
The data used for gathering comes from two places: the handler's
database of gatherable items, and the room's local information.
The handler's database contains a class entry for each gatherable:
- skill (string)
- The skill needed to find the item.
- difficulty (int)
- The taskmaster difficulty.
- upper (int)
- The taskmaster "upper" parameter.
- extra (mixed)
- The taskmaster "extra" parameter.
- season (string *)
- The seasons during which the gatherable is available (eg, plants).
If this is unset, the default is all seasons.
Note that, currently, it is the same season everywhere on the Disc.
- quant (int or function pointer returning an int)
- The quantity that will be gathered. The function pointer is
passed three parameters: the room, the player, and the name of the
gathered item. This allows, for example, a function to be called
on the room to calculate the quantity, such as:
(: $1->room_func($2, $3) :)
- ob (string)
- The pathname of the object to be created. If the object is
continuous, the amount of ob is set to quant; otherwise,
quant copies of the object are cloned.
The room's local information is set when the gatherable is added
via add_item(), and consists of:
- item name (string or function pointer returning a string)
- The name that will be used to look up the gatherable in the
handler's database. The function pointer is passed two parameters
when evaluated: the room, and the player.
- scarcity (int or function pointer returning an int)
- The percent chance of finding any quantity of the gatherable.
This is an additional
constraint on finding the gatherable, in addition to any skill
requirements and quantity calculations. A scarcity of 100 (the default)
indicates no scarcity constraint. A scarcity of 0 means that the
gatherable will never be found.
Written by Jeremy
Includes
This class includes the following files /include/tasks.h and /include/weather.hClass Index
Method index
- add_item(string, string, int, string *, mixed, mixed, mixed)
This method adds an item into the current list of gatherable items.
- fetch_object(mixed)
Produces an object in the gather handler - strings are cloned, functions
evaluated, and arrays call_other'd.
- gather_item(string, object)
This method attempts to gather some items in the environment of
the specified player.
- gather_mess(string, object)
This method looks in the environment of the specified player for any
items matching the specified string which have had a gather message set
on them.
- query_item(string)
This method will return an array of the information associated with
the item.
- query_items()
This method returns all of the current gatherable items.
Public Functions
These are functions that everyone can access.
-
add_item
void add_item(string name,
string skill,
int diff,
string * season,
mixed quant,
mixed ob,
mixed init)
This method adds an item into the current list of gatherable items.
- Parameters:
name - the name of the item to add
skill - skill needed to find this item
diff - taskmaster difficulty
season - available season(s)
quant - quantity (int or function pointer returning an int)
ob - filename of object to be created
init - function to be called at creation
- See also:
query_item() and gather_item()
-
fetch_object
object fetch_object(mixed ob)
Produces an object in the gather handler - strings are cloned, functions
evaluated, and arrays call_other'd.
- Parameters:
ob - The data to produce
- Returns:
The finished object
-
gather_item
object * gather_item(string word,
object player)
This method attempts to gather some items in the environment of
the specified player.
- Parameters:
word - the item to try and gather
player - the player doing the gathering
- Returns:
an array of gathered objects
- See also:
gather_mess(), query_item() and add_item()
-
gather_mess
int gather_mess(string word,
object player)
This method looks in the environment of the specified player for any
items matching the specified string which have had a gather message set
on them. If such an item is found then the gather message(s) are added
with add_succeeded_mess() and the method returns 1. If no such item is
found then no messages are added, and the method returns 0.
- Parameters:
word - the item to look for gather messages on
player - the player doing the gathering
- Returns:
1 if gather messages found, 0 if no gather messages found.
- See also:
gather_item(), query_item() and add_item()
-
query_item
mixed query_item(string name)
This method will return an array of the information associated with
the item. The array consists of:
({
skill, // skill needed to find this item (string)
difficulty, // taskmaster difficulty (int)
season, // available season(s) (string *)
quant, // quantity (int or (int)(:\:)) (mixed)
ob, // object to be created (mixed)
init // function to be called at creation (mixed)
})
- Parameters:
name - the name of the item to query
- Returns:
the item array as detailed above.
- See also:
add_item()
-
query_items
mapping query_items()
This method returns all of the current gatherable items. It returns
this as a mapping of a class, so probably not overly useful except
for debugging.
- Returns:
mapping of a locally defined class
- See also:
query_item() and add_item()
Classes
These are nice data types for dealing with... Data!