Inventory

From The DarkMod Wiki
Jump to navigationJump to search

Overview

This article describes how to set up inventory items and how they can be given to an entity. The purpose of the inventory is, to keep track of all items that are in an entities possessions. I delibaretly use "entity" here because, in principle, all entities can have an inventory, even though it may only make sense for AI and the player to actuall have one. For future improvements it might be usefull for other purposes as well though. Also included is a script interface, so that a mapper can interact with the inventory in a more sophisticated way, if the default implementation is not sufficient.

Definitions

The spawnargs can be either set in the def file as a default, or in the map file to override settings for specific entities. Naturaly this also means that they can be manipulated by scripts as well, since they are the standard way of configuring objects in Doom 3.

There are several terms and types of items that can be used in the inventory:

  • anonymous items An anonymous object means that it will not show up as a seperate item in the inventory. An example would be normal loot like coins or golden dishes. Since they should not be stored in the inventory as seperate items, they don't need to be displayed either. In this case they only count for the total of loot and are discarded afterwards. Anonymous items also can not be dropped after they went into the inventory because they essentially no longer exist. For the loot count it obviously doesn't matter wether an item is anonymous or not, as all are added up into the loot categories. Examples are gold coins and all the other (mostly loot) items that are collected but not being used individually.
  • stackable items These are items that can be stacked in the inventory. This means that the player can acquire multiple instances of such items, but only one entry is shown in the inventory with a counter of how many currently are available. An example would be a health potion. The player can posses more than one health potion at a time and this would be indicated by the counter. Stackable items are identified by setting the stackable property. They also must always use the same name and category. If this doesn't match, they are considered to be of different types. This also allows for dealing out i.e. fake health potions which have no effect or deal damage instead (as an example).
  • Category is a classification of items, to visually group them together. This allows the player to faster scroll through the inventory because he doesn't have to cycle through all the individual items. For example a category would be 'Readables' where books and scrolls are stored, and another Category would be 'Tools' where lockpicks and other items can be stored. Note that this category is entirely up to the mapper to decide and also is option. it doesn't has any consequence as to the playabillity and is only a convenience for the player. Categories can switched of on the HUD, so that the player can use the inventory also in the Thief style (which is the default).

Spawnargs

  inv_category : string
  Specifies the cagtegory that the object should be filed under. This 
  allows for player convenience and also is needed for stackable items.
  example: "inv_name" "Health Potion"
  inv_name : string
  Specifies the name the object should display when it is activated in the inventory.
  example: "inv_name" "Health Potion"
  inv_icon : D3 path to icon
  Points to an icon that is to be displayed when the object is selected in the inventory.
  This entry also determines wether an object is to be considered anonymous or not. 
  inv_droppable : [0/1]
  If set to 1 the item can be dropped into the map by the player. This will not
  work for anonymous items, since they will have no representation after they
  were put into the inventory.
  inv_delete : [0/1]
  Determines if an anonymous object can be deleted, after it was put into the inventory.
  This is advisable, because the entity will stay in memory and a mapper could still
  access it via scripting. If the mapper decides that an item will no longer be accessed
  after it
  has been acquired, this key should be set to 1. This can affect loading time of saved
  games, as entities, that are no longer needed, don't need to be saved and restored. If
  the mapper also creates entities on the fly, with the help of scripts, it might better
  to set this flag on appropriate objects tofree up the limited number of entities a map
  can hold. The usuals candidates for this flag are all the regular loot items, because
  they wont be used anymore after they have been found (lik coins, purses, etc.). Also
  note that, if dropappable is set to 1, then this key will be ignored, since dropabale
  items must be turned into entities again to be placed in the map.