Man item

From LSWiki

Jump to: navigation, search

Contents

Files

/def/descriptor/item.c
/lib/descriptor/item.h
/daemon/items.c
/lib/items.h

Description

Item descriptors are used by the random item generation system. Items which are suitable for use as randomly generated content are registered with the items daemon using item descriptors, and the descriptors are used in the selection process.

The standard support module for control daemons includes functions for registering items for use by the random item system, which is referred to as "publishing" them. Example of items being registered 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_item(Project_Weapon("sword"), Rarity_Common);
       add_published_item(([
           Item_File       : Project_Misc("boom_gem"),
           Item_Rarity     : Rarity_Very_Rare,
           Item_Dangers    : Item_Danger_Injure_Anyone,
       ]));
       add_published_item(Project_Weapon("weird_ball"), Rarity_Exotic,
           Item_Category_Strange, Item_Danger_Force_Transport);
   }

Public Fields

Item_File: Typically the string object name of the item blueprint. Required. This may also be specified as an array or mapping random distribution list of string blueprint names, but it is not encouraged to use this form; it is intended mainly for keeping large classes of similar objects in lib content from flooding the distribution lists.

Item_Rarity: The general rarity with which the object is expected to appear. This is an integer rarity value from rarity.h. Required.

Item_Categories: A bitmask field indicating which of various general categories the item belongs to. These categories are not exhaustive, since there can only be 32 of them (as we have 32-bit integer values). Often, this field does not need to be specified, since normally the item will be automatically analyzed to determine which categories it belongs to. Some of the categories cannot be automatically assigned, however, and others can only be assigned in some of the appropriate cases; these will be noted in their individual descriptions. Any item categories which are automatically assigned are added to ones specified manually. The item categories are as follows, with indentation showing categories which are normally part of one another (though this is not automatically enforced -- if you specify Item_Category_Hand_Weapon, Item_Category_Weapon is not automatically added, though automatic analysis will add it if the item appears to be a weapon).

   Item_Category_Weapon: All weapons except shields.
       Item_Category_Hand_Weapon: Ordinary close combat weapons; in
       automatic analysis, applied if no other weapon subcategories
       apply.
       Item_Category_Throwing_Weapon: Weapon intended for use by being
       thrown, meaning its ranged performance is better than its close
       combat performance and it does not belong to any of the other
       ranged weapon categories below.
       Item_Category_Launcher_Weapon: Weapon used to launch ammunition;
       bows, crossbows, slings, and so on.
       Item_Category_Ammunition_Weapon: Weapon launched by a launcher;
       arrows, bolts, and so on.
       Item_Category_Discharger_Weapon: Weapon which emits a ranged
       attack from a stationary position; e.g. wands and staves which
       discharge ranged attacks.
   Item_Category_Shield: Shields.
   Item_Category_Armour: All worn items, including accessories (that
   is, overarmour; rings, anklets, and so on).
       Item_Category_Head_Armour: Armour which covers the head only.
       Item_Category_Chest_Armour: Armour which covers the chest only.
       Item_Category_Full_Body_Armour: Armour which covers at least the
       ten limbs normally present in an anthropoid anatomy.
       Item_Category_Upper_Body_Armour: Armour which covers the chest,
       right arm, and left arm.
       Item_Category_Other_Armour: Locational armour (not overarmour)
       not in one of the previous categories.
       Item_Category_Hand_Accessory: Overarmour worn on a hand (such as
       rings and bracelets).
       Item_Category_Foot_Accessory: Overarmour worn on a foot.
       Item_Category_Head_Accessory: Overarmour worn on the head (such
       as amulets and necklaces).
       Item_Category_Other_Accessory: Other overarmour (such as cloaks,
       robes, and belts).
   Item_Category_Comestible: Comestible items.
       Item_Category_Food: Food items.
       Item_Category_Drink: Drink items.
   Item_Category_Literature: Items of literature.
       Item_Category_Scroll: Scrolls.
       Item_Category_Books: Books.
   Item_Category_Tool: Items whose primary intended purposes is as tools.
   Usually these items are also weapons, but not always.  This category is
   automatically set for weapons whose types are configured as tools.
   Item_Category_Container: Items intended for use as containers.  This
   category is automatically set for items which respond true to the
   function is_transactional_container().
   Item_Category_Miscellaneous: Items not belonging to the Weapon,
   Shield, Armour, Comestible, or Literature categories.
   Item_Category_Ordinary: Assigned to items that are not in the Magical,
   Psychic, Significant, or Strange categories.
   Item_Category_Magical: Assigned to items with Prop_Magical.
   Item_Category_Psychic: Assigned to items with Prop_Psychic.
   Item_Category_Enhancer: Items which are used to enhance the performance
   of of other items, usually specific classes of other items.  Examples
   are flux capacitors (which enhance flux weapons), lanmorathic (which
   enhances paraxoro), and ezithric (which enhances tarixai).  This
   category is not assigned automatically.
   Item_Category_Strange: An arbitrary category which should be given
   to particularly unusual and bizarre items.  This category is not
   assigned automatically.
   Item_Category_Significant: Items which are particularly important
   or sought-after.  Examples include black skulls and coruscars.
   The main purpose of the category is so that these items can be
   excluded from more trivial random item generation instances.  This
   category is assigned automatically to unique items, items which
   respond true to query_indestructible() or which have the NR special
   ID, but it is best to assign it manually whenever applicable.

Item_Dangers: A set of bitmasks flags indicating ways in which the item

   is dangerous to its user or bearer.  As with categories, the system
   will attempt to fill in this field by automatic analysis, though it
   is limited in its ability to do so.  The danger flags are:
   Item_Danger_Force_Combat: The item may force users or bearers to
   initiate combat.  This danger flag is not set automatically.
   Item_Danger_Force_Transport: The item may move users or bearers to
   other locations.  This danger flag is not set automatically.
   Item_Danger_Impair_Anyone: The item may cause impairments, such as
   attribute, speed, or resistance penalties.  Injuries are considered
   separately.  This danger flag is only automatically set for comestibles
   which define negative attribute modifiers.
   Item_Danger_Impair_Misuser: The item may cause impairments to those
   who use it improperly.  This danger flag is not set automatically.
   Item_Danger_Impair_Some: The item may cause impairments to specific
   classes of individuals bearing or using it.  An example is those of a
   given alignment range.  This danger flag is not set automatically.
   Item_Danger_Injure_Anyone: The item may cause injuries to its user or
   bearer.  This danger flag is not automatically set.
   Item_Danger_Injure_Misuser: The item may cause injuries to those who
   use it improperly.  An example is the breath weapon potions, which are
   only dangerous if misused.  This danger flag is not set automatically.
   Item_Danger_Injure_Some: The item may cause injuries to specific
   classes of individuals.  An example is those of a given alignment
   range.  This danger flag is not set automatically.
   Item_Danger_Prevent_Drop: The item may prevent itself from being
   dropped.  This danger flag is set automatically if the object has
   a Can_Move hook or defines the function drop().
   Item_Danger_Prevent_Equip: The item may prevent itself from being
   equipped.  This danger flag is set automatically if the object has
   a Can_Equip_Item hook.
   Item_Danger_Prevent_Unequip: The item may prevent itself from being
   unequipped.  This danger flag is set automatically if the object has
   a Can_Unequip_Item hook.
   Item_Danger_Severe_Effect: Designates that the dangers otherwise
   described are especially severe.  Examples include warpstones, which
   use the flags Item_Danger_Impair_Some and Item_Danger_Severe_Effect,
   and breath weapon potions, which use Item_Danger_Injure_Misuser and
   Item_Danger_Severe_Effect.

Item_Flags: A set of bitmask flags for the item. These are:

   Item_Flag_Defined_Categories: If set, the normal analysis of the
   item to determine categories that should be applied to it is not
   performed, meaning the categories specified manually are relied on
   exclusively (and so should be specified carefully).
   Item_Flag_Defined_Dangers: If set, the normal analysis of the
   item to determine danger flags that should be applied to it is not
   performed, meaning the dangers specified manually are relied on
   exclusively (and so should be specified carefully).
   Item_Flag_Suppress_Adjustments: If set, known methods of items
   adjusting themselves to target users are suppressed.  Currently,
   this amounts to turning off autonomon_adapt in armour items.

Internal Fields

Item_Object: Query this field in order to request a pointer to the item blueprint object (or a sample blueprint object, in the case of descriptors that point to group of objects). The object will be loaded if it is not already. Do not set this field.

Item_Source: The string object name of the object that created the descriptor.

Item_Tag: The tag for the descriptor system.

Support Functions

object Item_Resolve(descriptor dxr)

Returns the final object suitable for use as randomly generated content. For non-unique objects, this will be a clone of the blueprint; for unique objects, it will be the blueprint itself. Groups of objects will be resolved to a selected object.

See Also

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

Personal tools