Difference between revisions of "Modding:Item"

From DoomRL Wiki

Jump to: navigation, search
m (fixed stupid wiki formatting conflict)
 
(7 intermediate revisions by 4 users not shown)
Line 2: Line 2:
  
 
== Prototype ==
 
== Prototype ==
 +
New items are created from item prototypes. Think of an item prototype as a recipe for creating new items. There can be multiple pistols, but they all came from the same prototype. Prototypes are declared by passing a table with the desired properties to the Items function. The available properties depend on the item type. [[#Engine Hooks|Engine hooks]] may also be included in the prototype. Mostly, the prototype's properties just describe items' initial properties (occasionally with different names). Items' properties can also mostly be changed after they are instantiated. Required fields are underlined. Sometimes required fields can safely be omitted, but this will generate a message in the log file. All item prototypes are stored in a global table called items. This table can be indexed by id or nid.
 +
 +
{{drltable|Item Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>name</u>|This is the item's name.
 +
  |{{modarg|string}}|id|This is the item's sid. It must be distinct from other string ids. (The numeric id is automatically generated and stored in the nid field of the prototype.) It defaults to the first word of the name in all lowercase.
 +
  |{{modarg|value list}}|overlay|This describes of color transformation of the item's sprite. It is only used in the graphical version. This will create overlay_red, overlay_blue, overlay_green, and overlay_alpha attributes for the prototype.
 +
  |{{modarg|Color}}|color|This is the item's color. The default is LIGHTGRAY.
 +
  |{{modarg|string}}|color_id|For the purpose of custom color bindings, this id will be used for the item. Multiple items (like levers) can have the same color_id to prevent them from being distinguished.
 +
  |{{modarg|integer}}|level|This is an [[Item Generation|item generation]] parameter. The default is 0.
 +
  |{{modarg|integer}}|<u>weight</u>|This is an [[Item Generation|item generation]] parameter.
 +
  |{{modarg|integer}}|<u>sprite</u>|This is the item's sprite. This field is only relevant to the graphical version; use 0 for no sprite.
 +
  |{{modarg|value list}}|coscolor|Some sprites (such as armor and boots) are color-neutral to begin: ''coscolor'' determines the color of the sprite in these cases. The list must be written in this form: {red,green,blue,alpha}, where all of these values range from 0.0 to 1.0.
 +
  |{{modarg|value list}}|glow|Creates a customized "glow" effect around the sprite. See ''coscolor'' for table specifications.
 +
  |{{modarg|Item Flag List}}|flags|The flags in this list will automatically be included in the item's flag set. The default is an empty list. Some flags may be added automatically. The prototype will automatically be given a flagSet property containing the flags in set format.
 +
  |{{modarg|ItemSet ID}}|set|If included, this item will belong to the given item set. This will modify the item's OnEquip and OnRemove hooks.
 +
  |{{modarg|string}}|firstmsg|If included, this message will be displayed when the an item with this prototype is picked up for the first time. This will modify the item's OnFirstPickup hook.
 +
  |{{modarg|integer}}|res_bullet|This is the item's res_bullet. The default is 0.
 +
  |{{modarg|integer}}|res_melee|This is the item's res_melee. The default is 0.
 +
  |{{modarg|integer}}|res_shrapnel|This is the item's res_shrapnel. The default is 0.
 +
  |{{modarg|integer}}|res_acid|This is the item's res_acid. The default is 0.
 +
  |{{modarg|integer}}|res_fire|This is the item's res_fire. The default is 0.
 +
  |{{modarg|integer}}|res_plasma|This is the item's res_plasma. The default is 0.
 +
  |{{modarg|ItemType}}|<u>type</u>|This is the item's itype. It also determines which other properties can be used in the prototype.
 +
  |}}
 +
}}
  
New items are created from item prototypes. Think of an item prototype as a recipe for creating new items. There can be multiple pistols, but they all came from the same prototype. Prototypes are declared by passing a table with the desired properties to the Items function. The available properties depend on the item type. [[#Engine Hooks|Engine hooks]] may also be included in the prototype. Mostly, the prototype's properties just describe items' initial properties (occasionally with different names). Items' properties can also mostly be changed after they are instantiated. Required fields are underlined. Sometimes required fields can safely be omitted, but this will generate a message in the log file. All item prototypes are stored in a global table called items. This table can be indexed by id or nid.
 
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Item Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">name</span>
 
|This is the item's name.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|id
 
|This is the item's sid. It must be distinct from other string ids. (The numeric id is automatically generated and stored in the nid field of the prototype.) It defaults to the first word of the name in all lowercase.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer''' '''list'''
 
|style="vertical-align:top; padding-right: 2ex;"|overlay
 
|This describes of color transformation of the item's sprite. It is only used in the graphical version. This will create overlay_red, overlay_blue, overlay_green, and overlay_alpha attributes for the prototype.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#Colors|Color]]
 
|style="vertical-align:top; padding-right: 2ex;"|color
 
|This is the item's color. The default is LIGHTGRAY.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|level
 
|This is an [[Item Generation|item generation]] parameter. The default is 0.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">weight</span>
 
|This is an [[Item Generation|item generation]] parameter.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">sprite</span>
 
|This is the item's sprite. This field is only relevant to the graphical version; use 0 for no sprite.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#Item Flags|Item Flag]] '''list'''
 
|style="vertical-align:top; padding-right: 2ex;"|flags
 
|The flags in this list will automatically be included in the item's flag set. The default is an empty list. Some flags may be added automatically. The prototype will automatically be given a flagSet property containing the flags in set format.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:ItemSet|ItemSet ID]]
 
|style="vertical-align:top; padding-right: 2ex;"|set
 
|If included, this item will belong to the given item set. This will modify the item's OnEquip and OnRemove hooks.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|firstmsg
 
|If included, this message will be displayed when the an item with this prototype is picked up for the first time. This will modify the item's OnFirstPickup hook.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|slevel
 
|This property is unused.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|color_id
 
|For the purpose of custom color bindings, this id will be used for the item. Multiple items (like levers) can have the same color_id to prevent them from being distinguished.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|res_bullet
 
|This is the item's res_bullet. The default is 0.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|res_melee
 
|This is the item's res_melee. The default is 0.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|res_shrapnel
 
|This is the item's res_shrapnel. The default is 0.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|res_acid
 
|This is the item's res_acid. The default is 0.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|res_fire
 
|This is the item's res_fire. The default is 0.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|res_plasma
 
|This is the item's res_plasma. The default is 0.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#ItemType|ItemType]]
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">type</span>
 
|This is the item's itype. It also determines which other properties can be used in the prototype.
 
|}
 
 
=== Armor or Boots ===
 
=== Armor or Boots ===
 +
These are the fields used by ITEMTYPE_ARMOR and ITEMTYPE_BOOTS.
 +
 +
{{drltable|Armor or Boots Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>desc</u>|This is the armor's description that is displayed in the inventory screen.
 +
  |{{modarg|integer}}|<u>armor</u>|This is the armor's armor property.
 +
  |{{modarg|integer}}|durability|This is the armor's maxdurability as well as its initial durability. The default is 100. (This should still be 100 for armors with no durability, as no durability is achieved by a flag.)
 +
  |{{modarg|integer}}|knockmod|This is the armor's knockmod. The default is 0.
 +
  |{{modarg|integer}}|movemod|This is the armor's movemod. The default is 0.
 +
  |{{modarg|string}}|ascii|This is the armor's picture. It should be a length one string. The default is "[" for body armor and ";" for boots.
 +
  |}}
 +
}}
  
These are the fields used by ITEMTYPE_ARMOR and ITEMTYPE_BOOTS.
 
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Armor or Boots Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
 
|This is the armor's description that is displayed in the inventory screen.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">armor</span>
 
|This is the armor's armor property.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|durability
 
|This is the armor's maxdurability as well as its initial durability. The default is 100. (This should still be 100 for armors with no durability, as no durability is achieved by a flag.)
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|knockmod
 
|This is the armor's knockmod. The default is 0.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|movemod
 
|This is the armor's movemod. The default is 0.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the armor's picture. It should be a length one string. The default is "[" for body armor and ";" for boots.
 
|}
 
 
=== Consumable ===
 
=== Consumable ===
 
 
These are the fields used by ITEMTYPE_PACK. This includes mods and relics.
 
These are the fields used by ITEMTYPE_PACK. This includes mods and relics.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Consumable Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
 
|This is the pack's description that is displayed in the inventory screen.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''function'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">OnUse</span>
 
|Packs must provide an OnUse hook.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the pack's picture. It should be a length one string. The default is "+".
 
|}
 
=== Powerups ===
 
  
 +
{{drltable|Consumable Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>desc</u>|This is the pack's description that is displayed in the inventory screen.
 +
  |{{modarg|string}}|mod_letter|This is the shorthand letter by which the pack will be recognized as a mod. Do not fill this value unless this item is meant to be a mod pack.
 +
  |{{modarg|function}}|<u>OnUse</u>|Packs must provide an OnUse hook.
 +
  |{{modarg|string}}|ascii|This is the pack's picture. It should be a length one string. The default is "+".
 +
  |}}
 +
}}
 +
 +
=== Powerup ===
 
These are the fields used by ITEMTYPE_POWER.
 
These are the fields used by ITEMTYPE_POWER.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Powerups Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''function'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">OnPickup</span>
 
|Powerups must provide an OnPickup hook.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the powerup's picture. It should be a length one string. The default is "^".
 
|}
 
=== Ammo ===
 
  
 +
{{drltable|Powerup Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|function}}|<u>OnPickup</u>|Powerups must provide an OnPickup hook.
 +
  |{{modarg|string}}|ascii|This is the powerup's picture. It should be a length one string. The default is "^".
 +
  |}}
 +
}}
 +
 +
=== Ammo ===
 
These are the fields used by ITEMTYPE_AMMO.
 
These are the fields used by ITEMTYPE_AMMO.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Ammo Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
 
|This is the ammo's description that is displayed in the inventory screen.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammo</span>
 
|This is the ammo's initial ammo property.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammomax</span>
 
|This is the ammo's ammomax property.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the ammo's picture. It should be a length one string. The default is "&#124;".
 
|}
 
=== Ammo Pack ===
 
  
 +
{{drltable|Ammo Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>desc</u>|This is the ammo's description that is displayed in the inventory screen.
 +
  |{{modarg|integer}}|<u>ammo</u>|This is the ammo's initial ammo property.
 +
  |{{modarg|integer}}|<u>ammomax</u>|This is the ammo's ammomax property.
 +
  |{{modarg|string}}|ascii|This is the ammo's picture. It should be a length one string. The default is "&#124;".
 +
  |}}
 +
}}
 +
 +
=== Ammo Pack ===
 
These are the fields used by ITEMTYPE_AMMOPACK.
 
These are the fields used by ITEMTYPE_AMMOPACK.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Ammo Pack Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
 
|This is the ammo pack's description that is displayed in the inventory screen.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammo</span>
 
|This is the ammo pack's initial ammo property.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammomax</span>
 
|This is the ammo pack's ammomax property.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammoID</span>
 
|This is the ammo pack's ammoid property.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the ammo pack's picture. It should be a length one string. The default is "!".
 
|}
 
=== Ranged Weapon ===
 
  
 +
{{drltable|Ammo Pack Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>desc</u>|This is the ammo pack's description that is displayed in the inventory screen.
 +
  |{{modarg|integer}}|<u>ammo</u>|This is the ammo pack's initial ammo property.
 +
  |{{modarg|integer}}|<u>ammomax</u>|This is the ammo pack's ammomax property.
 +
  |{{modarg|string}}|<u>ammo_id</u>|This is the ammo pack's ammoid property.
 +
  |{{modarg|string}}|ascii|This is the ammo pack's picture. It should be a length one string. The default is "!".
 +
  |}}
 +
}}
 +
 +
=== Ranged Weapon ===
 
These fields are used by ITEMTYPE_RANGED.
 
These fields are used by ITEMTYPE_RANGED.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Ranged Weapon Prototype'''
+
{{drltable|Ranged Weapon Prototype|3|{{Table3Col
|-
+
  |es=background: #333;
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
+
  |c2=vertical-align:top; padding:0px 2px;
|This is the weapon's description that is displayed in the inventory screen.
+
  |c3=padding:0px 2px;
|-style="background: #333;"
+
  |{{modarg|string}}|<u>desc</u>|This is the weapon's description that is displayed in the inventory screen.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
  |{{modarg|string}}|<u>damage</u>|This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">damage</span>
+
  |{{modarg|DamageType}}|<u>damagetype</u>|This is the weapon's damagetype.
|This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
+
  |{{modarg|string}}|<u>psprite</u>|This is the sprite used to represent the player when this weapon is equipped. It is only relevant in the graphical version.
|-
+
  |{{modarg|string}}|<u>group</u>|This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#DamageType|DamageType]]
+
  |{{modarg|string}}|<u>ammo_id</u>|This is the weapon's ammoID.
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">damagetype</span>
+
  |{{modarg|integer}}|fire|This is the weapon's usetime. The default is 10.
|This is the weapon's damagetype.
+
  |{{modarg|integer}}|acc|This is the weapon's acc. The default is 0.
|-style="background: #333;"
+
  |{{modarg|integer}}|<u>ammomax</u>|This is the weapon's ammomax and the weapon's initial ammo.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
  |{{modarg|integer}}|radius|This is the weapon's blastradius. The default is 0.
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">group</span>
+
  |{{modarg|integer}}|shots|This is the weapon's shots. The default is 0 (which will still give one shot).
|This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
+
  |{{modarg|integer}}|shotcost|This is the weapon's shotcost. The default is 0 (which will still require one ammo).
|-
+
  |{{modarg|AltFire}}|altfire|This is the weapon's altfire. The default is ALT_NONE.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
  |{{modarg|AltReload}}|altreload|This is the weapon's altreload. The default is RELOAD_NONE.
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammoID</span>
+
  |{{modarg|string}}|altfirename|This is the name the game uses for the weapon's alternate fire mode. Most of the AltFire constants provide defaults.
|This is the weapon's ammoID.
+
  |{{modarg|string}}|altreloadname|This is the name the game uses for the weapon's alternate reload mode. Most of the AltReload constants provide defaults.
|-style="background: #333;"
+
  |{{modarg|string}}|sound_id|The sound_id will be used to look up sounds if there are no sounds defined for the weapon's actual id. By convention, this is set as the usual wielder's id when applicable.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
  |{{modarg|Missile ID}}|overcharge|This field is currently unused.
|style="vertical-align:top; padding-right: 2ex;"|fire
+
  |{{modarg|Missile ID}} or {{modarg|Missile Prototype}}|<u>missile</u>|This is the weapon's missile. (It will be translated into an nid. To use a shotgun missile, the weapon must have the IF_SHOTGUN flag.) If this property is a table, it will be used to declare a new missile with the same id as the weapon.
|This is the weapon's usetime. The default is 10.
+
  |{{modarg|string}}|ascii|This is the weapon's picture. It should be a length one string. The default is "}".
|-
+
  |}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
}}
|style="vertical-align:top; padding-right: 2ex;"|acc
+
 
|This is the weapon's acc. The default is 0.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">ammomax</span>
+
|This is the weapon's ammomax and the weapon's initial ammo.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|radius
+
|This is the weapon's blastradius. The default is 0.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|shots
+
|This is the weapon's shots. The default is 0 (which will still give one shot).
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|shotcost
+
|This is the weapon's shotcost. The default is 0 (which will still require one ammo).
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#AltFire|AltFire]]
+
|style="vertical-align:top; padding-right: 2ex;"|altfire
+
|This is the weapon's altfire. The default is ALT_NONE.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#AltReload|AltReload]]
+
|style="vertical-align:top; padding-right: 2ex;"|altreload
+
|This is the weapon's altreload. The default is RELOAD_NONE.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
|style="vertical-align:top; padding-right: 2ex;"|altfirename
+
|This is the name the game uses for the weapon's alternate fire mode. Most of the AltFire constants provide defaults.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
|style="vertical-align:top; padding-right: 2ex;"|altreloadname
+
|This is the name the game uses for the weapon's alternate reload mode. Most of the AltReload constants provide defaults.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Missile|Missile ID]]
+
|style="vertical-align:top; padding-right: 2ex;"|overcharge
+
|This field is currently unused.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Missile|Missile ID]] or [[Modding:Missile|Missile Prototype]]
+
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">missile</span>
+
|This is the weapon's missile. (It will be translated into an nid. To use a shotgun missile, the weapon must have the IF_SHOTGUN flag.) If this property is a table, it will be used to declare a new missile with the same id as the weapon.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
|style="vertical-align:top; padding-right: 2ex;"|ascii
+
|This is the weapon's picture. It should be a length one string. The default is "}".
+
|}
+
 
=== Natural Ranged Weapon ===
 
=== Natural Ranged Weapon ===
 +
These fields are used by ITEMTYPE_NRANGED. Natural ranged weapons are usually defined inline in a {{modarg|Being}} definition.
  
These fields are used by ITEMTYPE_NRANGED. Natural ranged weapons are usually defined inline in a [[Modding:Being|being]] definition.
+
{{drltable|Natural Ranged Weapon Prototype|3|{{Table3Col
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
  |es=background: #333;
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Natural Ranged Weapon Prototype'''
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
|-
+
  |c2=vertical-align:top; padding:0px 2px;
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
  |c3=padding:0px 2px;
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">damage</span>
+
  |{{modarg|string}}|<u>damage</u>|This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
|This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
+
  |{{modarg|DamageType}}|<u>damagetype</u>|This is the weapon's damagetype.
|-style="background: #333;"
+
  |{{modarg|string}}|<u>group</u>|This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#DamageType|DamageType]]
+
  |{{modarg|integer}}|fire|This is the weapon's usetime. The default is 10.
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">damagetype</span>
+
  |{{modarg|integer}}|acc|This is the weapon's acc. The default is 0.
|This is the weapon's damagetype.
+
  |{{modarg|integer}}|radius|This is the weapon's blastradius. The default is 0.
|-
+
  |{{modarg|integer}}|shots|This is the weapon's shots. The default is 0 (which will still give one shot).
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
  |{{modarg|string}}|sound_id|The sound_id will be used to look up sounds if there are no sounds defined for the weapon's actual id. By convention, a natural weapon's soundID is the usual wielder's id.
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">group</span>
+
  |{{modarg|Missile ID}} or {{modarg|Missile Prototype}}|<u>missile</u>|This is the weapon's missile. (It will be translated into an nid. To use a shotgun missile, the weapon must have the IF_SHOTGUN flag.) If this property is a table, it will be used to declare a new missile with the same id as the weapon.
|This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
+
  |{{modarg|string}}|ascii|This is the weapon's picture. It should be a length one string. The default is "?".
|-style="background: #333;"
+
  |}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
}}
|style="vertical-align:top; padding-right: 2ex;"|fire
+
|This is the weapon's usetime. The default is 10.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|acc
+
|This is the weapon's acc. The default is 0.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|radius
+
|This is the weapon's blastradius. The default is 0.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|shots
+
|This is the weapon's shots. The default is 0 (which will still give one shot).
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
|style="vertical-align:top; padding-right: 2ex;"|soundID
+
|The soundID will be used to look up sounds if there are no sounds defined for the weapon's actual id. By convention, a natural weapon's soundID is the usual wielder's id.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Missile|Missile ID]] or [[Modding:Missile|Missile Prototype]]
+
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">missile</span>
+
|This is the weapon's missile. (It will be translated into an nid. To use a shotgun missile, the weapon must have the IF_SHOTGUN flag.) If this property is a table, it will be used to declare a new missile with the same id as the weapon.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
|style="vertical-align:top; padding-right: 2ex;"|ascii
+
|This is the weapon's picture. It should be a length one string. The default is "?".
+
|}
+
=== Melee Weapon ===
+
  
 +
=== Melee Weapon ===
 
These fields are used by ITEMTYPE_MELEE.
 
These fields are used by ITEMTYPE_MELEE.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Melee Weapon Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
 
|This is the weapon's description that is displayed in the inventory screen.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">damage</span>
 
|This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#DamageType|DamageType]]
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">damagetype</span>
 
|This is the weapon's damagetype.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">group</span>
 
|This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|fire
 
|This is the weapon's usetime. The default is 10.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|acc
 
|This is the weapon's acc. The default is 0.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|shotcost
 
|This is the weapon's shotcost. The default is 0 (which will still require one ammo).
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#AltFire|AltFire]]
 
|style="vertical-align:top; padding-right: 2ex;"|altfire
 
|This is the weapon's altfire. The default is ALT_NONE.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|altfirename
 
|This is the name the game uses for the weapon's alternate fire mode. Most of the AltFire constants provide defaults.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Missile|Missile ID]] or [[Modding:Missile|Missile Prototype]]
 
|style="vertical-align:top; padding-right: 2ex;"|missile
 
|This is the missile used if for the throw alternate fire mode.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the weapon's picture. It should be a length one string. The default is "\".
 
|}
 
=== Lever ===
 
  
 +
{{drltable|Melee Weapon Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>desc</u>|This is the weapon's description that is displayed in the inventory screen.
 +
  |{{modarg|string}}|<u>damage</u>|This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
 +
  |{{modarg|DamageType}}|<u>damagetype</u>|This is the weapon's damagetype.
 +
  |{{modarg|string}}|<u>psprite</u>|This is the projectile sprite used with the weapon. It is only relevant in the graphical version.
 +
  |{{modarg|string}}|<u>group</u>|This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
 +
  |{{modarg|integer}}|fire|This is the weapon's usetime. The default is 10.
 +
  |{{modarg|integer}}|acc|This is the weapon's acc. The default is 0.
 +
  |{{modarg|integer}}|shotcost|This is the weapon's shotcost. The default is 0 (which will still require one ammo).
 +
  |{{modarg|AltFire}}|altfire|This is the weapon's altfire. The default is ALT_NONE.
 +
  |{{modarg|string}}|altfirename|This is the name the game uses for the weapon's alternate fire mode. Most of the AltFire constants provide defaults.
 +
  |{{modarg|Missile ID}} or {{modarg|Missile Prototype}}|missile|This is the missile used if for the throw alternate fire mode.
 +
  |{{modarg|Item ID}}|throw_id|In the case where the melee weapon can be thrown, this is the item that appears after the item is thrown. It defaults to the item itself.
 +
  |{{modarg|string}}|ascii|This is the weapon's picture. It should be a length one string. The default is "\".
 +
  |}}
 +
}}
 +
 +
=== Lever ===
 
These fields are used by ITEMTYPE_LEVER. DoomRL levers usually also have a target_area custom property.
 
These fields are used by ITEMTYPE_LEVER. DoomRL levers usually also have a target_area custom property.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Lever Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">desc</span>
 
|This is the full description of the lever used if the player has BF_LEVERSENSE2.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">good</span>
 
|This is the qualitative description of the lever used if the player has BF_LEVERSENSE1. By convention, this should be "beneficial", "neutral", or "dangerous".
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
 
|style="vertical-align:top; padding-right: 2ex;"|fullchance
 
|The level generation code will set the lever's target_area to the full map fullchance percent of the time. The default is 0. (To be fair, the level generation code won't generate custom levers.)
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|warning
 
|This message will be displayed by the level generation code if the fullchance roll succeeds.
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|null
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">color_id</span>
 
|This field is required for levers. By convention, it is set to "lever".
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|null
 
|style="vertical-align:top; padding-right: 2ex;"|soundID
 
|If the particular lever doesn't have sound bindings, the game will use the sound ID to look for sound bindings. By default, this is "lever".
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the lever's picture. It should be a length one string. The default is "&".
 
|}
 
=== Teleporter ===
 
  
 +
{{drltable|Lever Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|string}}|<u>desc</u>|This is the full description of the lever used if the player has BF_LEVERSENSE2.
 +
  |{{modarg|string}}|<u>good</u>|This is the qualitative description of the lever used if the player has BF_LEVERSENSE1. By convention, this should be "beneficial", "neutral", or "dangerous".
 +
  |{{modarg|integer}}|fullchance|The level generation code will set the lever's target_area to the full map fullchance percent of the time. The default is 0. (To be fair, the level generation code won't generate custom levers.)
 +
  |{{modarg|string}}|warning|This message will be displayed by the level generation code if the fullchance roll succeeds.
 +
  |null|<u>color_id</u>|This field is required for levers. By convention, it is set to "lever".
 +
  |null|sound_id|If the particular lever doesn't have sound bindings, the game will use the sound ID to look for sound bindings. By default, this is "lever".
 +
  |{{modarg|string}}|ascii|This is the lever's picture. It should be a length one string. The default is "&".
 +
  |}}
 +
}}
 +
 +
=== Teleporter ===
 
These fields are used by ITEMTYPE_TELE. The built-in teleport item has a custom target property. This can be set to any coord to control the destination.
 
These fields are used by ITEMTYPE_TELE. The built-in teleport item has a custom target property. This can be set to any coord to control the destination.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Teleporter Prototype'''
 
|-
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''function'''
 
|style="vertical-align:top; padding-right: 2ex;"|<span style="text-decoration:underline;">OnEnter</span>
 
|This hook is required for teleporters.
 
|-style="background: #333;"
 
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
 
|style="vertical-align:top; padding-right: 2ex;"|ascii
 
|This is the teleporter's picture. It should be a length one string. The default is "*".
 
|}
 
== Engine Hooks ==
 
  
 +
{{drltable|Teleporter Prototype|3|{{Table3Col
 +
  |es=background: #333;
 +
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
 +
  |c2=vertical-align:top; padding:0px 2px;
 +
  |c3=padding:0px 2px;
 +
  |{{modarg|function}}|<u>OnEnter</u>|This hook is required for teleporters.
 +
  |{{modarg|string}}|ascii|This is the teleporter's picture. It should be a length one string. The default is "*".
 +
  |}}
 +
}}
 +
 +
=== Flags ===
 +
{{Template:Item_Flags}}
 +
 +
== Engine Hooks ==
 
These hooks can give greater flexibility for how items work. For some item types, a hook provides the primary function. Sometimes, the engine will add to explicitly defined hooks, but this shouldn't interfere with a modder's use of the hooks. However, modders should be careful when changing hooks.
 
These hooks can give greater flexibility for how items work. For some item types, a hook provides the primary function. Sometimes, the engine will add to explicitly defined hooks, but this shouldn't interfere with a modder's use of the hooks. However, modders should be careful when changing hooks.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
{|class="wikitable" style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
|colspan=2 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Item Hooks'''
+
! colspan="2" style="background: darkred; color: yellow; font-size: 120%; text-align: center"|Item Hooks
|-
+
{{Table2Col
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
  |es=background: #333;
|[[#item_OnCreate|OnCreate]]([[Modding:Item|Item]] self)  
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
|-style="background: #333;"
+
  |c2=padding:0px 2px;
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
  |{{modarg|boolean}}|[[#item_OnCreate|OnCreate]]({{modarg|Item}} self)  
|[[#item_OnPickup|OnPickup]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] getter)  
+
  |{{modarg|boolean}}|[[#item_OnPickup|OnPickup]]({{modarg|Item}} self, {{modarg|Being}} getter)  
|-
+
  |{{modarg|boolean}}|[[#item_OnFirstPickup|OnFirstPickup]]({{modarg|Item}} self, {{modarg|Being}} getter)  
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
  |{{modarg|boolean}}|[[#item_OnPickupCheck|OnPickupCheck]]({{modarg|Item}} self, {{modarg|Being}} getter)  
|[[#item_OnFirstPickup|OnFirstPickup]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] getter)  
+
  |{{modarg|boolean}}|[[#item_OnUse|OnUse]]({{modarg|Item}} self, {{modarg|Being}} user)  
|-style="background: #333;"
+
  |{{modarg|boolean}}|[[#item_OnUseCheck|OnUseCheck]]({{modarg|Item}} self, {{modarg|Being}} user)  
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |{{modarg|boolean}}|[[#item_OnReload|OnReload]]({{modarg|Item}} self, {{modarg|Being}} reloader)  
|[[#item_OnPickupCheck|OnPickupCheck]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] getter)  
+
  |{{modarg|boolean}}|[[#item_OnAltFire|OnAltFire]]({{modarg|Item}} self, {{modarg|Being}} firer)  
|-
+
  |{{modarg|boolean}}|[[#item_OnAltReload|OnAltReload]]({{modarg|Item}} self, {{modarg|Being}} reloader)  
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |{{modarg|boolean}}|[[#item_OnEquip|OnEquip]]({{modarg|Item}} self, {{modarg|Being}} equipper)  
|[[#item_OnUse|OnUse]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] user)  
+
  |{{modarg|boolean}}|[[#item_OnEquipTick|OnEquipTick]]({{modarg|Item}} self, {{modarg|Being}} wearer)  
|-style="background: #333;"
+
  |{{modarg|boolean}}|[[#item_OnEquipCheck|OnEquipCheck]]({{modarg|Item}} self, {{modarg|Being}} equipper)  
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |{{modarg|boolean}}|[[#item_OnRemove|OnRemove]]({{modarg|Item}} self, {{modarg|Being}} wearer)  
|[[#item_OnUseCheck|OnUseCheck]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] user)  
+
  |{{modarg|boolean}}|[[#item_OnKill|OnKill]]({{modarg|Item}} self, {{modarg|Being}} dier, {{modarg|Being}} wearer)  
|-
+
  |{{modarg|boolean}}|[[#item_OnHitBeing|OnHitBeing]]({{modarg|Item}} self, {{modarg|Being}} attacker, {{modarg|Being}} target)  
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |{{modarg|boolean}}|[[#item_OnEnter|OnEnter]]({{modarg|Item}} self, {{modarg|Being}} enterer)  
|[[#item_OnReload|OnReload]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] reloader)  
+
  |{{modarg|boolean}}|[[#item_OnFire|OnFire]]({{modarg|Item}} self, {{modarg|Being}} firer)  
|-style="background: #333;"
+
  |{{modarg|boolean}}|[[#item_OnFired|OnFired]]({{modarg|Item}} self, {{modarg|Being}} firer)  
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |}}
|[[#item_OnAltFire|OnAltFire]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] firer)  
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnAltReload|OnAltReload]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] reloader)  
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnEquip|OnEquip]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] equipper)  
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnEquipTick|OnEquipTick]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] wearer)  
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[#item_OnEquipCheck|OnEquipCheck]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] equipper)  
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnRemove|OnRemove]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] wearer)  
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnKill|OnKill]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] dier, [[Modding:Being|Being]] wearer)  
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[#item_OnHitBeing|OnHitBeing]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] attacker, [[Modding:Being|Being]] target)  
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnEnter|OnEnter]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] enterer)  
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[#item_OnFire|OnFire]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] firer)  
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
|[[#item_OnFired|OnFired]]([[Modding:Item|Item]] self, [[Modding:Being|Being]] firer)  
+
 
|}
 
|}
  
 
{{Anchor|item_OnCreate}}
 
{{Anchor|item_OnCreate}}
;OnCreate([[Modding:Item|Item]] self)  
+
;OnCreate({{modarg|Item}} self)  
 
:This hook is called when the item is created. For ammo, beware: the game creates and destroys ammo items liberally as a normal part of ammo management.
 
:This hook is called when the item is created. For ammo, beware: the game creates and destroys ammo items liberally as a normal part of ammo management.
 
----
 
----
 
{{Anchor|item_OnPickup}}
 
{{Anchor|item_OnPickup}}
;OnPickup([[Modding:Item|Item]] self, [[Modding:Being|Being]] getter)  
+
;OnPickup({{modarg|Item}} self, {{modarg|Being}} getter)  
 
:When an item is picked up, this hook is called with the being that is picking the item up. This is most commonly used to implement powerups.
 
:When an item is picked up, this hook is called with the being that is picking the item up. This is most commonly used to implement powerups.
 
----
 
----
 
{{Anchor|item_OnFirstPickup}}
 
{{Anchor|item_OnFirstPickup}}
;OnFirstPickup([[Modding:Item|Item]] self, [[Modding:Being|Being]] getter)  
+
;OnFirstPickup({{modarg|Item}} self, {{modarg|Being}} getter)  
 
:When an item with a given id is picked up for the first time, the function is called. This only works for items that go into the inventory.
 
:When an item with a given id is picked up for the first time, the function is called. This only works for items that go into the inventory.
 
----
 
----
 
{{Anchor|item_OnPickupCheck}}
 
{{Anchor|item_OnPickupCheck}}
;OnPickupCheck([[Modding:Item|Item]] self, [[Modding:Being|Being]] getter) &rarr; '''boolean'''
+
;OnPickupCheck({{modarg|Item}} self, {{modarg|Being}} getter) &rarr; '''boolean'''
 
:When a being tries to pick up an item, this function is called with the being that is trying to pick it up. If the return value is true, then the being is allowed to pick the item up, otherwise the being can't. For the player, both cases include the item in the player's previously found items. (This can affect OnFirstPickup.)
 
:When a being tries to pick up an item, this function is called with the being that is trying to pick it up. If the return value is true, then the being is allowed to pick the item up, otherwise the being can't. For the player, both cases include the item in the player's previously found items. (This can affect OnFirstPickup.)
 
----
 
----
 
{{Anchor|item_OnUse}}
 
{{Anchor|item_OnUse}}
;OnUse([[Modding:Item|Item]] self, [[Modding:Being|Being]] user) &rarr; '''boolean'''
+
;OnUse({{modarg|Item}} self, {{modarg|Being}} user) &rarr; '''boolean'''
 
:This hook is called when levers are used and when packs are used with the being that it using the item. For packs, if the return value is true, the item is consumed, otherwise it is left in the inventory. For levers, the return value is ignored and it is safe not to have a return value.
 
:This hook is called when levers are used and when packs are used with the being that it using the item. For packs, if the return value is true, the item is consumed, otherwise it is left in the inventory. For levers, the return value is ignored and it is safe not to have a return value.
 
----
 
----
 
{{Anchor|item_OnUseCheck}}
 
{{Anchor|item_OnUseCheck}}
;OnUseCheck([[Modding:Item|Item]] self, [[Modding:Being|Being]] user) &rarr; '''boolean'''
+
;OnUseCheck({{modarg|Item}} self, {{modarg|Being}} user) &rarr; '''boolean'''
 
:This hook is called called before OnUse for levers and packs. If the return value is false, then the being can't use the item, otherwise it can. For levers, this can control whether the lever statistic is increased.
 
:This hook is called called before OnUse for levers and packs. If the return value is false, then the being can't use the item, otherwise it can. For levers, this can control whether the lever statistic is increased.
 
----
 
----
 
{{Anchor|item_OnReload}}
 
{{Anchor|item_OnReload}}
;OnReload([[Modding:Item|Item]] self, [[Modding:Being|Being]] reloader) &rarr; '''boolean'''
+
;OnReload({{modarg|Item}} self, {{modarg|Being}} reloader) &rarr; '''boolean'''
 
:If it is declared, this hook is called when a weapon is reloaded. If the return value is false, then the normal reload procedure is aborted. This can be used to prevent reloading or to implement a custom reloading mechanism (like for the [[Acid Spitter]]). If true is returned, the weapon is reloaded normally afterwards.
 
:If it is declared, this hook is called when a weapon is reloaded. If the return value is false, then the normal reload procedure is aborted. This can be used to prevent reloading or to implement a custom reloading mechanism (like for the [[Acid Spitter]]). If true is returned, the weapon is reloaded normally afterwards.
 
----
 
----
 
{{Anchor|item_OnAltFire}}
 
{{Anchor|item_OnAltFire}}
;OnAltFire([[Modding:Item|Item]] self, [[Modding:Being|Being]] firer) &rarr; '''boolean'''
+
;OnAltFire({{modarg|Item}} self, {{modarg|Being}} firer) &rarr; '''boolean'''
 
:This hook works exactly like the OnFire hook, except it is called when the weapon's alternate fire mode is used for weapons with ALT_SCRIPT altfire.
 
:This hook works exactly like the OnFire hook, except it is called when the weapon's alternate fire mode is used for weapons with ALT_SCRIPT altfire.
 
----
 
----
 
{{Anchor|item_OnAltReload}}
 
{{Anchor|item_OnAltReload}}
;OnAltReload([[Modding:Item|Item]] self, [[Modding:Being|Being]] reloader)  
+
;OnAltReload({{modarg|Item}} self, {{modarg|Being}} reloader)  
 
:If the weapon's altreload is RELOAD_SCRIPT, then this hook is called with when the weapon's alternate reload mode is used.
 
:If the weapon's altreload is RELOAD_SCRIPT, then this hook is called with when the weapon's alternate reload mode is used.
 
----
 
----
 
{{Anchor|item_OnEquip}}
 
{{Anchor|item_OnEquip}}
;OnEquip([[Modding:Item|Item]] self, [[Modding:Being|Being]] equipper)  
+
;OnEquip({{modarg|Item}} self, {{modarg|Being}} equipper)  
 
:This hook is called when the item is equipped in any equipment slot. Due to a bug, equipper is the active being. This is always correct during normal play, but modders must be careful when manually equipping items with this hook.  
 
:This hook is called when the item is equipped in any equipment slot. Due to a bug, equipper is the active being. This is always correct during normal play, but modders must be careful when manually equipping items with this hook.  
 
----
 
----
 
{{Anchor|item_OnEquipTick}}
 
{{Anchor|item_OnEquipTick}}
;OnEquipTick([[Modding:Item|Item]] self, [[Modding:Being|Being]] wearer)  
+
;OnEquipTick({{modarg|Item}} self, {{modarg|Being}} wearer)  
 
:While this item is equipped in any slot (including the prepared slot), this function is called on each of the being's actions. (Despite the name, it probably won't be called on every tick; it depends on the being's speed.)
 
:While this item is equipped in any slot (including the prepared slot), this function is called on each of the being's actions. (Despite the name, it probably won't be called on every tick; it depends on the being's speed.)
 
----
 
----
 
{{Anchor|item_OnEquipCheck}}
 
{{Anchor|item_OnEquipCheck}}
;OnEquipCheck([[Modding:Item|Item]] self, [[Modding:Being|Being]] equipper) &rarr; '''boolean'''
+
;OnEquipCheck({{modarg|Item}} self, {{modarg|Being}} equipper) &rarr; '''boolean'''
 
:This function is called (before OnEquip) when the player tries to equip an item. If the return value is true, then the player is allowed to equip the item; otherwise the player isn't allowed to equip the item.
 
:This function is called (before OnEquip) when the player tries to equip an item. If the return value is true, then the player is allowed to equip the item; otherwise the player isn't allowed to equip the item.
 
----
 
----
 
{{Anchor|item_OnRemove}}
 
{{Anchor|item_OnRemove}}
;OnRemove([[Modding:Item|Item]] self, [[Modding:Being|Being]] wearer)  
+
;OnRemove({{modarg|Item}} self, {{modarg|Being}} wearer)  
 
:This hook is called when a being unequips the item, or when the item is otherwise removed from the being's equipment. This includes armor being destroyed by damage. Like OnEquip, this is called with the active being which can cause problems especially if this hook is called for armor destruction.   
 
:This hook is called when a being unequips the item, or when the item is otherwise removed from the being's equipment. This includes armor being destroyed by damage. Like OnEquip, this is called with the active being which can cause problems especially if this hook is called for armor destruction.   
 
----
 
----
 
{{Anchor|item_OnKill}}
 
{{Anchor|item_OnKill}}
;OnKill([[Modding:Item|Item]] self, [[Modding:Being|Being]] dier, [[Modding:Being|Being]] wearer)  
+
;OnKill({{modarg|Item}} self, {{modarg|Being}} dier, {{modarg|Being}} wearer)  
 
:When a being dies, this hook is called on all of the active being's equipment. This includes the prepared slot. (Weapons can check what slot they are in inside of this hook.)
 
:When a being dies, this hook is called on all of the active being's equipment. This includes the prepared slot. (Weapons can check what slot they are in inside of this hook.)
 
----
 
----
 
{{Anchor|item_OnHitBeing}}
 
{{Anchor|item_OnHitBeing}}
;OnHitBeing([[Modding:Item|Item]] self, [[Modding:Being|Being]] attacker, [[Modding:Being|Being]] target) &rarr; '''boolean'''
+
;OnHitBeing({{modarg|Item}} self, {{modarg|Being}} attacker, {{modarg|Being}} target) &rarr; '''boolean'''
 
:For weapons with no blastradius, this hook is called whenever a being is hit with the weapon. This hook is called before applying damage. If the return value is true, damage is applied as usual. Otherwise, the damage phase is skipped.
 
:For weapons with no blastradius, this hook is called whenever a being is hit with the weapon. This hook is called before applying damage. If the return value is true, damage is applied as usual. Otherwise, the damage phase is skipped.
 
----
 
----
 
{{Anchor|item_OnEnter}}
 
{{Anchor|item_OnEnter}}
;OnEnter([[Modding:Item|Item]] self, [[Modding:Being|Being]] enterer)  
+
;OnEnter({{modarg|Item}} self, {{modarg|Being}} enterer)  
 
:This function is called whenever a being enters a cell that has the item lying on the floor. For the player, this supresses the usual "There is an item lying here" message. This is used in DoomRL to implement teleports.
 
:This function is called whenever a being enters a cell that has the item lying on the floor. For the player, this supresses the usual "There is an item lying here" message. This is used in DoomRL to implement teleports.
 
----
 
----
 
{{Anchor|item_OnFire}}
 
{{Anchor|item_OnFire}}
;OnFire([[Modding:Item|Item]] self, [[Modding:Being|Being]] firer) &rarr; '''boolean'''
+
;OnFire({{modarg|Item}} self, {{modarg|Being}} firer) &rarr; '''boolean'''
 
:This hook is called when a weapon is fired. This only works for normal firing, not alternative firing (see OnAltFire). This hook is called before a target is selected. If the return value is true, then the rest of the normal firing operation is aborted. If the return value is false, then it continues as usual.  
 
:This hook is called when a weapon is fired. This only works for normal firing, not alternative firing (see OnAltFire). This hook is called before a target is selected. If the return value is true, then the rest of the normal firing operation is aborted. If the return value is false, then it continues as usual.  
 
----
 
----
 
{{Anchor|item_OnFired}}
 
{{Anchor|item_OnFired}}
;OnFired([[Modding:Item|Item]] self, [[Modding:Being|Being]] firer)  
+
;OnFired({{modarg|Item}} self, {{modarg|Being}} firer)  
 
:This hook is called after a weapon is fired. This is after the entire usual firing procedure including damage, etc. Currently, this only works for the player.
 
:This hook is called after a weapon is fired. This is after the entire usual firing procedure including damage, etc. Currently, this only works for the player.
== Properties ==
 
  
 +
== Properties ==
 
Items also have all the [[Modding:Thing|Thing]] properties in addition to those listed below. For items, the meaning of the resistance fields vary depending on the item type. For armor and boots, the resistances are applied only to attacks to the corresponding target. For other equipment, the resistance applies to all attacks. For non-equipment, the resistances aren't used. Also, some properties are only valid for armor, and some are only valid for weapons. For these purposes, armor are items with itype ITEMTYPE_ARMOR and ITEMTYPE_BOOTS and weapons are items with itype ITEMTYPE_AMMO, ITEMTYPE_MELEE, ITEMTYPE_NRANGED, ITEMTYPE_RANGED, and ITEMTYPE_AMMOPACK. Properties of the incorrect type are always indexable, but they may share a memory address with properties of the opposite type, so modders should only use this feature very carefully. The type of such properties is noted. Also, the meaning of many fields is slightly different depending on the itype; these differences are also described.
 
Items also have all the [[Modding:Thing|Thing]] properties in addition to those listed below. For items, the meaning of the resistance fields vary depending on the item type. For armor and boots, the resistances are applied only to attacks to the corresponding target. For other equipment, the resistance applies to all attacks. For non-equipment, the resistances aren't used. Also, some properties are only valid for armor, and some are only valid for weapons. For these purposes, armor are items with itype ITEMTYPE_ARMOR and ITEMTYPE_BOOTS and weapons are items with itype ITEMTYPE_AMMO, ITEMTYPE_MELEE, ITEMTYPE_NRANGED, ITEMTYPE_RANGED, and ITEMTYPE_AMMOPACK. Properties of the incorrect type are always indexable, but they may share a memory address with properties of the opposite type, so modders should only use this feature very carefully. The type of such properties is noted. Also, the meaning of many fields is slightly different depending on the itype; these differences are also described.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
 
|colspan=3 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Item'''
+
{{drltable|Item|3|{{Table3Col
|-
+
  |es=background: #333;
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#ItemType|ItemType]]
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
|style="vertical-align:top; padding-right: 2ex;"|itype
+
  |c2=vertical-align:top; padding:0px 2px;
|This determines the basic features of the item. ITEMTYPE_NONE has no features; it can't be picked up or used. ITEMTYPE_RANGED can be picked up and wielded as a ranged weapon. ITEMTYPE_NRANGED is like ITEMTYPE_RANGED, but it isn't designed to exist on the map. ITEMTYPE_ARMOR can be picked up and equipped as armor. ITEMTYPE_MELEE can be picked up and wielded as a melee weapon. ITEMTYPE_AMMO is always a new ammo type that can be picked up and stacked. ITEMTYPE_PACK items can be picked up and used. ITEMTYPE_POWER items are consumed when they are picked up. ITEMTYPE_BOOTS can be picked up and worn as boots. ITEMTYPE_TELE have no special features, but by convention they interact with OnEnter. ITEMTYPE_LEVER have special description routines, and they can be used while on the floor. ITEMTYPE_AMMOPACK can be picked up and wielded in the prepared slot. They provide reloading benefits. While it is possible to change an item's itype, this should almost never be done. If it is done, care must be taken to account for overlapping weapon and armor properties.
+
  |c3=padding:0px 2px;
|-style="background: #333;"
+
  |{{modarg|ItemType}}|itype|This determines the basic features of the item. ITEMTYPE_NONE has no features; it can't be picked up or used. ITEMTYPE_RANGED can be picked up and wielded as a ranged weapon. ITEMTYPE_NRANGED is like ITEMTYPE_RANGED, but it isn't designed to exist on the map. ITEMTYPE_ARMOR can be picked up and equipped as armor. ITEMTYPE_MELEE can be picked up and wielded as a melee weapon. ITEMTYPE_AMMO is always a new ammo type that can be picked up and stacked. ITEMTYPE_PACK items can be picked up and used. ITEMTYPE_POWER items are consumed when they are picked up. ITEMTYPE_BOOTS can be picked up and worn as boots. ITEMTYPE_TELE have no special features, but by convention they interact with OnEnter. ITEMTYPE_LEVER have special description routines, and they can be used while on the floor. ITEMTYPE_AMMOPACK can be picked up and wielded in the prepared slot. They provide reloading benefits. While it is possible to change an item's itype, this should almost never be done. If it is done, care must be taken to account for overlapping weapon and armor properties.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Byte'''
+
  |{{modarg|byte}}|armor|For armor and boots, this is the amount of [[protection]] provided at full durability. Weapons in the main slot may also provide a (universal) protection bonus with this field.
|style="vertical-align:top; padding-right: 2ex;"|armor
+
  |{{modarg|word}}|durability|For armor and boots, this is the current amount of durability of the item. This property is armor-specific.
|For armor and boots, this is the amount of [[protection]] provided at full durability. Weapons in the main slot may also provide a (universal) protection bonus with this field.
+
  |{{modarg|word}}|maxdurability|For armor and boots, this is the maximum amount of durability. Most effects won't raise the durability above maxdurability. This property is armor-specific.
|-
+
  |{{modarg|integer}}|movemod|For armor and boots, this percentage movement speed modifier is applied while the item is equipped. This property is armor-specific.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
  |{{modarg|integer}}|knockmod|For armor and boots, this percentage [[knockback]] modifier is applied while the item is equipped. This property is armor-specific.
|style="vertical-align:top; padding-right: 2ex;"|durability
+
  |[[Modding:Item|Item ID]]|ammoid|This must always be a number id. For ranged weapons, this is the item id of the kind of ammo the weapon uses. For ammo packs, this is the kind of ammo provided by the pack. This property is weapon-specific.
|For armor and boots, this is the current amount of durability of the item. This property is armor-specific.
+
  |{{modarg|word}}|ammo|For ranged weapons, this is the amount of currently-loaded ammo. For ammo packs and ammo stacks, this is the amount of ammo inside. This property is weapon-specific.  
|-style="background: #333;"
+
  |{{modarg|word}}|ammomax|For ranged weapons, this is the size of the magazine. For ammo stacks, this is the maximum stack size (unaffected by BF_BACKPACK). For ammo packs, this is the initial amount of ammo. This property is weapon-specific.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
  |{{modarg|word}}|acc|For ranged and melee weapons, this is an [[accuracy]] modifier applied to attacks with the weapon. This property is weapon-specific.
|style="vertical-align:top; padding-right: 2ex;"|maxdurability
+
  |{{modarg|word}}|damage_sides|For weapons, this is the number of dice rolled for damage (e.g. the X of XdY). This property is weapon-specific.
|For armor and boots, this is the maximum amount of durability. Most effects won't raise the durability above maxdurability. This property is armor-specific.
+
  |{{modarg|word}}|damage_dice|For weapons, this is the number of sides on each die rolled for damage (e.g. the Y of XdY). This property is weapon-specific.
|-
+
  |{{modarg|integer}}|damage_add|For weapons, this is a flat bonus added to all damage rolls. This property is weapon-specific.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Integer'''
+
  |{{modarg|Missile ID}}|missile|This must always be a number id. For ranged weapons, this is the missile used by the weapon. For melee weapons, this is the missile used by the throw alternate fire mode (if any). This property is weapon-specific.
|style="vertical-align:top; padding-right: 2ex;"|movemod
+
  |{{modarg|byte}}|blastradius|This is the [[Distance|radius]] of the explosion caused by a ranged weapon. This should be 0 for weapons with no explosion. This property is weapon-specific.
|For armor and boots, this percentage movement speed modifier is applied while the item is equipped. This property is armor-specific.
+
  |{{modarg|byte}}|shots|This is the number of shots fired by a rapid-fire ranged weapon. This should be 0 (not 1) for single-shot weapons. This property is weapon-specific.
|-style="background: #333;"
+
  |{{modarg|byte}}|shotcost|This is the amount of ammo consumed by each shot with a ranged weapon. This should be 0 (not 1) for weapons that take only one ammo per shot. This property is weapon-specific.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Integer'''
+
  |{{modarg|byte}}|reloadtime|This is the number of 0.1s intervals it takes (without modifiers) to reload a ranged weapon. This property is weapon-specific.
|style="vertical-align:top; padding-right: 2ex;"|knockback
+
  |{{modarg|byte}}|usetime|This is the number of 0.1s intervals it takes (without modifiers) to fire/use a weapon. This property is weapon-specific.
|For armor and boots, this percentage [[knockback]] modifier is applied while the item is equipped. This property is armor-specific.
+
  |{{modarg|DamageType}}|damagetype|This is the [[Damage type|type]] of the damage caused by a weapon. This property is weapon-specific.
|-
+
  |{{modarg|AltFire}}|altfire|This is the alternate fire mode of a weapon. For ALT_SCRIPT, the details depend on the OnAltFire hook. This property is weapon-specific.
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Item|Item ID]]
+
  |{{modarg|AltReload}}|altreload|This is the alternate reload mode of a ranged weapon. For RELOAD_SCRIPT, the details depend on the OnAltReload hook. This property is weapon-specific.
|style="vertical-align:top; padding-right: 2ex;"|ammoid
+
  |{{modarg|string}}|desc|This is the string used to describe the item in the inventory list. For the description in the inventory sidebar, use .proto.desc. This property is read-only.
|This must always be a number id. For ranged weapons, this is the item id of the kind of ammo the weapon uses. For ammo packs, this is the kind of ammo provided by the pack. This property is weapon-specific.
+
  |{{modarg|Item Prototype}}|__proto|This is the item's prototype. You can access item prototype fields using this (e.g., item.__proto.color).
|-style="background: #333;"
+
  |}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
}}
|style="vertical-align:top; padding-right: 2ex;"|ammo
+
|For ranged weapons, this is the amount of currently-loaded ammo. For ammo packs and ammo stacks, this is the amount of ammo inside. This property is weapon-specific.  
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
|style="vertical-align:top; padding-right: 2ex;"|ammomax
+
|For ranged weapons, this is the size of the magazine. For ammo stacks, this is the maximum stack size (unaffected by BF_BACKPACK). For ammo packs, this is the initial amount of ammo. This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
|style="vertical-align:top; padding-right: 2ex;"|acc
+
|For ranged and melee weapons, this is an [[accuracy]] modifier applied to attacks with the weapon. This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
|style="vertical-align:top; padding-right: 2ex;"|damage_sides
+
|For weapons, this is the number of dice rolled for damage (e.g. the X of XdY). This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Word'''
+
|style="vertical-align:top; padding-right: 2ex;"|damage_dice
+
|For weapons, this is the number of sides on each die rolled for damage (e.g. the Y of XdY). This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Integer'''
+
|style="vertical-align:top; padding-right: 2ex;"|damage_add
+
|For weapons, this is a flat bonus added to all damage rolls. This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Missile|Missile ID]]
+
|style="vertical-align:top; padding-right: 2ex;"|missile
+
|This must always be a number id. For ranged weapons, this is the missile used by the weapon. For melee weapons, this is the missile used by the throw alternate fire mode (if any). This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Byte'''
+
|style="vertical-align:top; padding-right: 2ex;"|blastradius
+
|This is the [[Distance|radius]] of the explosion caused by a ranged weapon. This should be 0 for weapons with no explosion. This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Byte'''
+
|style="vertical-align:top; padding-right: 2ex;"|shots
+
|This is the number of shots fired by a rapid-fire ranged weapon. This should be 0 (not 1) for single-shot weapons. This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Byte'''
+
|style="vertical-align:top; padding-right: 2ex;"|shotcost
+
|This is the amount of ammo consumed by each shot with a ranged weapon. This should be 0 (not 1) for weapons that take only one ammo per shot. This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Byte'''
+
|style="vertical-align:top; padding-right: 2ex;"|reloadtime
+
|This is the number of 0.1s intervals it takes (without modifiers) to reload a ranged weapon. This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''Byte'''
+
|style="vertical-align:top; padding-right: 2ex;"|usetime
+
|This is the number of 0.1s intervals it takes (without modifiers) to fire/use a weapon. This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#DamageType|DamageType]]
+
|style="vertical-align:top; padding-right: 2ex;"|damagetype
+
|This is the [[Damage type|type]] of the damage caused by a weapon. This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#AltFire|AltFire]]
+
|style="vertical-align:top; padding-right: 2ex;"|altfire
+
|This is the alternate fire mode of a weapon. For ALT_SCRIPT, the details depend on the OnAltFire hook. This property is weapon-specific.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Constants#AltReload|AltReload]]
+
|style="vertical-align:top; padding-right: 2ex;"|altreload
+
|This is the alternate reload mode of a ranged weapon. For RELOAD_SCRIPT, the details depend on the OnAltReload hook. This property is weapon-specific.
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''string'''
+
|style="vertical-align:top; padding-right: 2ex;"|desc
+
|This is the string used to describe the item in the inventory list. For the description in the inventory sidebar, use .proto.desc. This property is read-only.
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Item|Item Prototype]]
+
|style="vertical-align:top; padding-right: 2ex;"|proto
+
|This is the item's prototype.
+
|}
+
 
== API ==
 
== API ==
  
 
The [[Modding:Thing#API|Thing API]] can also be used with items.
 
The [[Modding:Thing#API|Thing API]] can also be used with items.
{|style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
+
{|class="wikitable" style="border: 2px solid darkred; border-spacing: 0; font-size: 90%; margin: 0.25em 0.5em;"
|colspan=2 style="background: darkred; color: yellow; font-size: 120%; text-align: center"|'''Item Interface'''
+
! colspan="2" style="background: darkred; color: yellow; font-size: 120%; text-align: center"|Item Interface
|-
+
{{Table2Col
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|[[Modding:Item|Item]]
+
  |es=background: #333;
|item.[[#item_new|new]]([[Modding:Item|Item ID]] id)
+
  |c1=font-weight:bold; text-align:right; vertical-align:top; padding:0px 2px;
|-style="background: #333;"
+
  |c2=padding:0px 2px;
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |{{modarg|Item}}|{{moddef|list|new|dot||Item ID|iid}}
|[[Modding:Item|Item]]&#058;[[#item_add_mod|add_mod]]('''string''' modletter)
+
  |{{modarg|boolean}}|{{moddef|list|add_mod|cln||string|modletter}}
|-
+
  |{{modarg|boolean}}|{{moddef|list|can_mod|cln||string|modletter}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
  |{{modarg|integer}}|{{moddef|list|get_mod|cln||string|modletter}}
|[[Modding:Item|Item]]&#058;[[#item_can_mod|can_mod]]('''string''' modletter)
+
  |{{modarg|boolean}}|{{moddef|list|clear_mods|cln}}
|-style="background: #333;"
+
  |{{modarg|boolean}}|{{moddef|list|is_damaged|cln}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''integer'''
+
  |{{modarg|boolean}}|{{moddef|list|fix|cln||integer|amount}}
|[[Modding:Item|Item]]&#058;[[#item_get_mod|get_mod]]('''string''' modletter)
+
  |{{modarg|table}}|{{moddef|list|get_mods|cln}}
|-
+
  |{{modarg|table}}|{{moddef|list|get_mod|ids|cln}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''void'''
+
  |{{modarg|boolean}}|{{moddef|list|can_overcharge|cln}}
|[[Modding:Item|Item]]&#058;[[#item_clear_mods|clear_mods]]()
+
  |{{modarg|boolean}}|{{moddef|list|check_mod_array|cln||string|nextmod|integer|techbonus}}
|-style="background: #333;"
+
  |}}
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[Modding:Item|Item]]&#058;[[#item_is_damaged|is_damaged]]()
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[Modding:Item|Item]]&#058;[[#item_fix|fix]]('''integer''' amount)
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''table'''
+
|[[Modding:Item|Item]]&#058;[[#item_get_mods|get_mods]]()
+
|-
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[Modding:Item|Item]]&#058;[[#item_can_overcharge|can_overcharge]]()
+
|-style="background: #333;"
+
|style="text-align: right; vertical-align:top; padding-right: 2ex;"|'''boolean'''
+
|[[Modding:Item|Item]]&#058;[[#item_check_mod_array|check_mod_array]]('''string''' nextmod, '''integer''' techbonus)
+
 
|}
 
|}
  
{{Anchor|item_new}}
+
{{moddef|desc|new|dot|Item|Item ID|iid}}
;item.new([[Modding:Item|Item ID]] id) &rarr; [[Modding:Item|Item]]
+
 
:This returns a newly allocated item create from the specified prototype. This item doesn't exist in the game yet; it must be dropped on the level, added to an inventory, or equipped.
 
:This returns a newly allocated item create from the specified prototype. This item doesn't exist in the game yet; it must be dropped on the level, added to an inventory, or equipped.
 
----
 
----
{{Anchor|item_add_mod}}
+
{{moddef|desc|add_mod|cln|boolean|string|modletter}}
;[[Modding:Item|Item]]&#058;add_mod('''string''' modletter) &rarr; '''boolean'''
+
 
:Adds a mod to the item's mod list and sets the IF_MODIFIED flag. This does not apply any affects of the mod, it is only a primitive operation for accessing the mod list. ''modletter'' should be a single uppercase letter representing the mod. This will check modding restrictions (as [[#item_can_mod|can_mod]]) and return true on success, false on failure.
 
:Adds a mod to the item's mod list and sets the IF_MODIFIED flag. This does not apply any affects of the mod, it is only a primitive operation for accessing the mod list. ''modletter'' should be a single uppercase letter representing the mod. This will check modding restrictions (as [[#item_can_mod|can_mod]]) and return true on success, false on failure.
 
----
 
----
{{Anchor|item_can_mod}}
+
{{moddef|desc|can_mod|cln|boolean|string|modletter}}
;[[Modding:Item|Item]]&#058;can_mod('''string''' modletter) &rarr; '''boolean'''
+
 
:Determines if the given mod can be added to the item. ''modletter'' should be a single uppercase letter representing the mod. This will always use the player's techbonus. It also accounts for limits on the number of mods of a given type and various modability item flags.
 
:Determines if the given mod can be added to the item. ''modletter'' should be a single uppercase letter representing the mod. This will always use the player's techbonus. It also accounts for limits on the number of mods of a given type and various modability item flags.
 
----
 
----
{{Anchor|item_get_mod}}
+
{{moddef|desc|get_mod|cln|integer|string|modletter}}
;[[Modding:Item|Item]]&#058;get_mod('''string''' modletter) &rarr; '''integer'''
+
 
:Counts the number of the given mod that have already been added to the item. ''modletter'' should be a single uppercase letter representing the mod.
 
:Counts the number of the given mod that have already been added to the item. ''modletter'' should be a single uppercase letter representing the mod.
 
----
 
----
{{Anchor|item_clear_mods}}
+
{{moddef|desc|clear_mods|cln|boolean}}
;[[Modding:Item|Item]]&#058;clear_mods()
+
 
:Clears the counts of all mods for the item. The does not undo the affects of the mods nor does it change any flags (including IF_MODIFIED).
 
:Clears the counts of all mods for the item. The does not undo the affects of the mods nor does it change any flags (including IF_MODIFIED).
 
----
 
----
{{Anchor|item_is_damaged}}
+
{{moddef|desc|is_damaged|cln|boolean}}
;[[Modding:Item|Item]]&#058;is_damaged() &rarr; '''boolean'''
+
 
:This determines if the item's durability is less than its maxdurability. For items with IF_NOREPAIR, this function always returns false. (So, in effect this function determines if the item needs to be repaired.)
 
:This determines if the item's durability is less than its maxdurability. For items with IF_NOREPAIR, this function always returns false. (So, in effect this function determines if the item needs to be repaired.)
 
----
 
----
{{Anchor|item_fix}}
+
{{moddef|desc|fix|cln|boolean|integer|amount}}
;[[Modding:Item|Item]]&#058;fix('''integer''' amount) &rarr; '''boolean'''
+
 
:This will increase the item's durability by amount, respecting maxdurability. It returns true is the item is no longer is_damaged. ''amount'' is optional; by default the item is completely repaired.
 
:This will increase the item's durability by amount, respecting maxdurability. It returns true is the item is no longer is_damaged. ''amount'' is optional; by default the item is completely repaired.
 
----
 
----
{{Anchor|item_get_mods}}
+
{{moddef|desc|get_mods|cln|table}}
;[[Modding:Item|Item]]&#058;get_mods() &rarr; '''table'''
+
 
:This will return a table that maps single character mod letters to the corresponding amount of mods that have been applied to the item. Mod letters that have not been applied are not included as keys.
 
:This will return a table that maps single character mod letters to the corresponding amount of mods that have been applied to the item. Mod letters that have not been applied are not included as keys.
 
----
 
----
{{Anchor|item_can_overcharge}}
+
{{moddef|list|get_mod|ids|cln|table}}
;[[Modding:Item|Item]]&#058;can_overcharge() &rarr; '''boolean'''
+
:As get_mods, but the table returned gives all mods in terms of their sID.
 +
----
 +
{{moddef|desc|can_overcharge|cln|boolean}}
 
:This will determine if the item can be overcharged. To be overcharged, an item can't already by overcharged (IF_DESTROY), and must be fully loaded. The ui part of overcharging is included. On success, IF_DESTROY and IF_NOUNLOAD are set, but other affects must be applied by the caller.
 
:This will determine if the item can be overcharged. To be overcharged, an item can't already by overcharged (IF_DESTROY), and must be fully loaded. The ui part of overcharging is included. On success, IF_DESTROY and IF_NOUNLOAD are set, but other affects must be applied by the caller.
 
----
 
----
{{Anchor|item_check_mod_array}}
+
{{moddef|desc|check_mod_array|cln|boolean|string|nextmod|integer|techbonus}}
;[[Modding:Item|Item]]&#058;check_mod_array('''string''' nextmod, '''integer''' techbonus) &rarr; '''boolean'''
+
 
:This will check if the mod indicated by ''nextmod'' (the single uppercase character representing the mod) could form an assembly (given the provided techbonus). If so, the assembly is created on the item (if the player confirms the ui message) with all associated side effects. Returns true only if the assembly is actually created.
 
:This will check if the mod indicated by ''nextmod'' (the single uppercase character representing the mod) could form an assembly (given the provided techbonus). If so, the assembly is created on the item (if the player confirms the ui message) with all associated side effects. Returns true only if the assembly is actually created.

Latest revision as of 16:06, 18 July 2013

DoomRL has many kinds of items. Weapons, powerups, levers, and other things are all items. Items inherit from the Thing class which handles some basic properties in common with beings.

Contents

Prototype

New items are created from item prototypes. Think of an item prototype as a recipe for creating new items. There can be multiple pistols, but they all came from the same prototype. Prototypes are declared by passing a table with the desired properties to the Items function. The available properties depend on the item type. Engine hooks may also be included in the prototype. Mostly, the prototype's properties just describe items' initial properties (occasionally with different names). Items' properties can also mostly be changed after they are instantiated. Required fields are underlined. Sometimes required fields can safely be omitted, but this will generate a message in the log file. All item prototypes are stored in a global table called items. This table can be indexed by id or nid.

Item Prototype
string name This is the item's name.
string id This is the item's sid. It must be distinct from other string ids. (The numeric id is automatically generated and stored in the nid field of the prototype.) It defaults to the first word of the name in all lowercase.
value list overlay This describes of color transformation of the item's sprite. It is only used in the graphical version. This will create overlay_red, overlay_blue, overlay_green, and overlay_alpha attributes for the prototype.
Color color This is the item's color. The default is LIGHTGRAY.
string color_id For the purpose of custom color bindings, this id will be used for the item. Multiple items (like levers) can have the same color_id to prevent them from being distinguished.
integer level This is an item generation parameter. The default is 0.
integer weight This is an item generation parameter.
integer sprite This is the item's sprite. This field is only relevant to the graphical version; use 0 for no sprite.
value list coscolor Some sprites (such as armor and boots) are color-neutral to begin: coscolor determines the color of the sprite in these cases. The list must be written in this form: {red,green,blue,alpha}, where all of these values range from 0.0 to 1.0.
value list glow Creates a customized "glow" effect around the sprite. See coscolor for table specifications.
Item Flag List flags The flags in this list will automatically be included in the item's flag set. The default is an empty list. Some flags may be added automatically. The prototype will automatically be given a flagSet property containing the flags in set format.
ItemSet ID set If included, this item will belong to the given item set. This will modify the item's OnEquip and OnRemove hooks.
string firstmsg If included, this message will be displayed when the an item with this prototype is picked up for the first time. This will modify the item's OnFirstPickup hook.
integer res_bullet This is the item's res_bullet. The default is 0.
integer res_melee This is the item's res_melee. The default is 0.
integer res_shrapnel This is the item's res_shrapnel. The default is 0.
integer res_acid This is the item's res_acid. The default is 0.
integer res_fire This is the item's res_fire. The default is 0.
integer res_plasma This is the item's res_plasma. The default is 0.
ItemType type This is the item's itype. It also determines which other properties can be used in the prototype.

Armor or Boots

These are the fields used by ITEMTYPE_ARMOR and ITEMTYPE_BOOTS.

Armor or Boots Prototype
string desc This is the armor's description that is displayed in the inventory screen.
integer armor This is the armor's armor property.
integer durability This is the armor's maxdurability as well as its initial durability. The default is 100. (This should still be 100 for armors with no durability, as no durability is achieved by a flag.)
integer knockmod This is the armor's knockmod. The default is 0.
integer movemod This is the armor's movemod. The default is 0.
string ascii This is the armor's picture. It should be a length one string. The default is "[" for body armor and ";" for boots.

Consumable

These are the fields used by ITEMTYPE_PACK. This includes mods and relics.

Consumable Prototype
string desc This is the pack's description that is displayed in the inventory screen.
string mod_letter This is the shorthand letter by which the pack will be recognized as a mod. Do not fill this value unless this item is meant to be a mod pack.
function OnUse Packs must provide an OnUse hook.
string ascii This is the pack's picture. It should be a length one string. The default is "+".

Powerup

These are the fields used by ITEMTYPE_POWER.

Powerup Prototype
function OnPickup Powerups must provide an OnPickup hook.
string ascii This is the powerup's picture. It should be a length one string. The default is "^".

Ammo

These are the fields used by ITEMTYPE_AMMO.

Ammo Prototype
string desc This is the ammo's description that is displayed in the inventory screen.
integer ammo This is the ammo's initial ammo property.
integer ammomax This is the ammo's ammomax property.
string ascii This is the ammo's picture. It should be a length one string. The default is "|".

Ammo Pack

These are the fields used by ITEMTYPE_AMMOPACK.

Ammo Pack Prototype
string desc This is the ammo pack's description that is displayed in the inventory screen.
integer ammo This is the ammo pack's initial ammo property.
integer ammomax This is the ammo pack's ammomax property.
string ammo_id This is the ammo pack's ammoid property.
string ascii This is the ammo pack's picture. It should be a length one string. The default is "!".

Ranged Weapon

These fields are used by ITEMTYPE_RANGED.

Ranged Weapon Prototype
string desc This is the weapon's description that is displayed in the inventory screen.
string damage This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
DamageType damagetype This is the weapon's damagetype.
string psprite This is the sprite used to represent the player when this weapon is equipped. It is only relevant in the graphical version.
string group This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
string ammo_id This is the weapon's ammoID.
integer fire This is the weapon's usetime. The default is 10.
integer acc This is the weapon's acc. The default is 0.
integer ammomax This is the weapon's ammomax and the weapon's initial ammo.
integer radius This is the weapon's blastradius. The default is 0.
integer shots This is the weapon's shots. The default is 0 (which will still give one shot).
integer shotcost This is the weapon's shotcost. The default is 0 (which will still require one ammo).
AltFire altfire This is the weapon's altfire. The default is ALT_NONE.
AltReload altreload This is the weapon's altreload. The default is RELOAD_NONE.
string altfirename This is the name the game uses for the weapon's alternate fire mode. Most of the AltFire constants provide defaults.
string altreloadname This is the name the game uses for the weapon's alternate reload mode. Most of the AltReload constants provide defaults.
string sound_id The sound_id will be used to look up sounds if there are no sounds defined for the weapon's actual id. By convention, this is set as the usual wielder's id when applicable.
Missile ID overcharge This field is currently unused.
Missile ID or Missile Prototype missile This is the weapon's missile. (It will be translated into an nid. To use a shotgun missile, the weapon must have the IF_SHOTGUN flag.) If this property is a table, it will be used to declare a new missile with the same id as the weapon.
string ascii This is the weapon's picture. It should be a length one string. The default is "}".

Natural Ranged Weapon

These fields are used by ITEMTYPE_NRANGED. Natural ranged weapons are usually defined inline in a Being definition.

Natural Ranged Weapon Prototype
string damage This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
DamageType damagetype This is the weapon's damagetype.
string group This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
integer fire This is the weapon's usetime. The default is 10.
integer acc This is the weapon's acc. The default is 0.
integer radius This is the weapon's blastradius. The default is 0.
integer shots This is the weapon's shots. The default is 0 (which will still give one shot).
string sound_id The sound_id will be used to look up sounds if there are no sounds defined for the weapon's actual id. By convention, a natural weapon's soundID is the usual wielder's id.
Missile ID or Missile Prototype missile This is the weapon's missile. (It will be translated into an nid. To use a shotgun missile, the weapon must have the IF_SHOTGUN flag.) If this property is a table, it will be used to declare a new missile with the same id as the weapon.
string ascii This is the weapon's picture. It should be a length one string. The default is "?".

Melee Weapon

These fields are used by ITEMTYPE_MELEE.

Melee Weapon Prototype
string desc This is the weapon's description that is displayed in the inventory screen.
string damage This should be a string like "2d4"; the weapon's damage_dice and damage_sides will be parsed from this.
DamageType damagetype This is the weapon's damagetype.
string psprite This is the projectile sprite used with the weapon. It is only relevant in the graphical version.
string group This is the weapon's group for purposes of kill counting. The used weapon groups are "weapon-melee", "weapon-pistol", "weapon-shotgun", "weapon-chain", "weapon-rocket", "weapon-plasma", and "weapon-bfg". The default is "weapon-other".
integer fire This is the weapon's usetime. The default is 10.
integer acc This is the weapon's acc. The default is 0.
integer shotcost This is the weapon's shotcost. The default is 0 (which will still require one ammo).
AltFire altfire This is the weapon's altfire. The default is ALT_NONE.
string altfirename This is the name the game uses for the weapon's alternate fire mode. Most of the AltFire constants provide defaults.
Missile ID or Missile Prototype missile This is the missile used if for the throw alternate fire mode.
Item ID throw_id In the case where the melee weapon can be thrown, this is the item that appears after the item is thrown. It defaults to the item itself.
string ascii This is the weapon's picture. It should be a length one string. The default is "\".

Lever

These fields are used by ITEMTYPE_LEVER. DoomRL levers usually also have a target_area custom property.

Lever Prototype
string desc This is the full description of the lever used if the player has BF_LEVERSENSE2.
string good This is the qualitative description of the lever used if the player has BF_LEVERSENSE1. By convention, this should be "beneficial", "neutral", or "dangerous".
integer fullchance The level generation code will set the lever's target_area to the full map fullchance percent of the time. The default is 0. (To be fair, the level generation code won't generate custom levers.)
string warning This message will be displayed by the level generation code if the fullchance roll succeeds.
null color_id This field is required for levers. By convention, it is set to "lever".
null sound_id If the particular lever doesn't have sound bindings, the game will use the sound ID to look for sound bindings. By default, this is "lever".
string ascii This is the lever's picture. It should be a length one string. The default is "&".

Teleporter

These fields are used by ITEMTYPE_TELE. The built-in teleport item has a custom target property. This can be set to any coord to control the destination.

Teleporter Prototype
function OnEnter This hook is required for teleporters.
string ascii This is the teleporter's picture. It should be a length one string. The default is "*".

Flags

Item Flags
IF_CHAMBEREMPTY For IF_PUMPACTION weapons, this flag indicates whether ammo is in the chamber or not.
IF_UNIQUE This flag is set for unique items. Unique items add a player history message when picked up as well as doing a screen blink. Unique items are also not destroyable.
IF_EXOTIC This flag is set for exotic items. This is used by the game to compile the special items list.
IF_MODIFIED This flag is automatically set for items that have been modded.
IF_HALFKNOCK If a weapon with this flag is wielded, all knockback against the wielder will be halved.
IF_GLOBE This is a marker flag for items that are disallowed in Angel of Masochism.
IF_CURSED Items with this flag cannot be unequipped.
IF_RECHARGE Items with this flag regenerate ammo or durability as with a Nano Pack.
IF_CLEAVE Items with this flag give the wielder the benefits of the Blademaster trait (as Butcher's Cleaver).
IF_NOAMMO Items with this flag don't consume ammo when fired. For the player, a weapon still must have ammo loaded to be fired.
IF_NECROCHARGE Items with this flag recharge as with IF_RECHARGE, but reduce the weilder's health by 1 for each point of recharge (as with Necroarmor).
IF_PUMPACTION Ranged weapons with this flag must be pumped after each shot as with the combat shotgun.
IF_SINGLERELOAD Ranged weapons with this flag only reload one ammo at a time (as with the missile launcher) instead of all at once.
IF_PISTOL This flag indicates whether the weapon counts as a pistol for the purposes of the Son of a Gun and Dualgunner traits. (For kill counting, the weapon group is used instead.)
IF_SHOTGUN This flag causes a weapon's missile to be treated as a shotgun id rather than a missile id. Also, this flag is used to decide if the Shottyman trait should count the weapon as a shotgun. (For kill counting, the weapon group is used instead.)
IF_SPREAD Ranged weapons with this flag fire three shots at once (as the tristar blaster and mancubus natural weapon). In 0.9.9.4, this flag is a bit buggy.
IF_SCATTER For ranged weapons with this flag, each shot is aimed at a different cell near the real target (as with the BFG 10K).
IF_MODABLE Allows a unique item to be fully modded.
IF_SINGLEMOD Restricts the number of allowed mods on the item to one. (For unique items, this must be used along with IF_MODABLE.)
IF_DUALSHOTGUN For multi-shot weapons, this flag eliminates all delay between shots and causes the firing sound to play only once.
IF_AIHEALPACK This flag allows the default AI to pick up and use the item.
IF_NOUNLOAD Ranged weapons with this flag cannot be unloaded.
IF_NUKERESIST Items with this flag will not be destroyed by nuking.
IF_NODROP Items with this flag will not be dropped when the carrier/wearer dies.
IF_AUTOHIT Weapons with this flag never miss (as with items modified by a sniper weapon pack).
IF_SETITEM This flag is automatically set for items that specify a set.
IF_NODURABILITY Armors and boots with this flag have no durability (as with items modified by an Onyx Armor Pack).
IF_NODESTROY Armors with this flag cannot be destroyed by damage. Also, items on the ground with this flag will not be destroyed by explosions.
IF_NONMODABLE Items with this flag cannot be modded.
IF_NOREPAIR Armors and boots with this flag cannot be repaired by normal methods (ie item:fix). Directly setting item.durability bypasses this prohibition. Usually set for shields.
IF_ASSEMBLED This flag is automatically set on assemblies. Items with this flag cannot be used for the base of any other assembly.
IF_DESTROY Weapons with this flag will be destroyed after firing (with a default message). The flag is used for overcharged weapons.
IF_BLADE Weapons with this flag are considered blades for the purpose of activating the flags used for Malicious Blades.
IF_DESTRUCTIVE Weapons with this flag deal double damage to cells (if they can hurt cells, see CF_FRAGILE.)
IF_ROCKET Any weapon with this flag defined as a rocket launcher.
IF_NODEGRADE Armor's or boots' resistances aren't degraded due to damage taken. Usually set for shields.
IF_THROWDROP Combat knife has this flag in 0.9.9.7.
IF_FARHIT
IF_UNSEENHIT

Engine Hooks

These hooks can give greater flexibility for how items work. For some item types, a hook provides the primary function. Sometimes, the engine will add to explicitly defined hooks, but this shouldn't interfere with a modder's use of the hooks. However, modders should be careful when changing hooks.

Item Hooks
boolean OnCreate(Item self)
boolean OnPickup(Item self, Being getter)
boolean OnFirstPickup(Item self, Being getter)
boolean OnPickupCheck(Item self, Being getter)
boolean OnUse(Item self, Being user)
boolean OnUseCheck(Item self, Being user)
boolean OnReload(Item self, Being reloader)
boolean OnAltFire(Item self, Being firer)
boolean OnAltReload(Item self, Being reloader)
boolean OnEquip(Item self, Being equipper)
boolean OnEquipTick(Item self, Being wearer)
boolean OnEquipCheck(Item self, Being equipper)
boolean OnRemove(Item self, Being wearer)
boolean OnKill(Item self, Being dier, Being wearer)
boolean OnHitBeing(Item self, Being attacker, Being target)
boolean OnEnter(Item self, Being enterer)
boolean OnFire(Item self, Being firer)
boolean OnFired(Item self, Being firer)

OnCreate(Item self)
This hook is called when the item is created. For ammo, beware: the game creates and destroys ammo items liberally as a normal part of ammo management.

OnPickup(Item self, Being getter)
When an item is picked up, this hook is called with the being that is picking the item up. This is most commonly used to implement powerups.

OnFirstPickup(Item self, Being getter)
When an item with a given id is picked up for the first time, the function is called. This only works for items that go into the inventory.

OnPickupCheck(Item self, Being getter) → boolean
When a being tries to pick up an item, this function is called with the being that is trying to pick it up. If the return value is true, then the being is allowed to pick the item up, otherwise the being can't. For the player, both cases include the item in the player's previously found items. (This can affect OnFirstPickup.)

OnUse(Item self, Being user) → boolean
This hook is called when levers are used and when packs are used with the being that it using the item. For packs, if the return value is true, the item is consumed, otherwise it is left in the inventory. For levers, the return value is ignored and it is safe not to have a return value.

OnUseCheck(Item self, Being user) → boolean
This hook is called called before OnUse for levers and packs. If the return value is false, then the being can't use the item, otherwise it can. For levers, this can control whether the lever statistic is increased.

OnReload(Item self, Being reloader) → boolean
If it is declared, this hook is called when a weapon is reloaded. If the return value is false, then the normal reload procedure is aborted. This can be used to prevent reloading or to implement a custom reloading mechanism (like for the Acid Spitter). If true is returned, the weapon is reloaded normally afterwards.

OnAltFire(Item self, Being firer) → boolean
This hook works exactly like the OnFire hook, except it is called when the weapon's alternate fire mode is used for weapons with ALT_SCRIPT altfire.

OnAltReload(Item self, Being reloader)
If the weapon's altreload is RELOAD_SCRIPT, then this hook is called with when the weapon's alternate reload mode is used.

OnEquip(Item self, Being equipper)
This hook is called when the item is equipped in any equipment slot. Due to a bug, equipper is the active being. This is always correct during normal play, but modders must be careful when manually equipping items with this hook.

OnEquipTick(Item self, Being wearer)
While this item is equipped in any slot (including the prepared slot), this function is called on each of the being's actions. (Despite the name, it probably won't be called on every tick; it depends on the being's speed.)

OnEquipCheck(Item self, Being equipper) → boolean
This function is called (before OnEquip) when the player tries to equip an item. If the return value is true, then the player is allowed to equip the item; otherwise the player isn't allowed to equip the item.

OnRemove(Item self, Being wearer)
This hook is called when a being unequips the item, or when the item is otherwise removed from the being's equipment. This includes armor being destroyed by damage. Like OnEquip, this is called with the active being which can cause problems especially if this hook is called for armor destruction.

OnKill(Item self, Being dier, Being wearer)
When a being dies, this hook is called on all of the active being's equipment. This includes the prepared slot. (Weapons can check what slot they are in inside of this hook.)

OnHitBeing(Item self, Being attacker, Being target) → boolean
For weapons with no blastradius, this hook is called whenever a being is hit with the weapon. This hook is called before applying damage. If the return value is true, damage is applied as usual. Otherwise, the damage phase is skipped.

OnEnter(Item self, Being enterer)
This function is called whenever a being enters a cell that has the item lying on the floor. For the player, this supresses the usual "There is an item lying here" message. This is used in DoomRL to implement teleports.

OnFire(Item self, Being firer) → boolean
This hook is called when a weapon is fired. This only works for normal firing, not alternative firing (see OnAltFire). This hook is called before a target is selected. If the return value is true, then the rest of the normal firing operation is aborted. If the return value is false, then it continues as usual.

OnFired(Item self, Being firer)
This hook is called after a weapon is fired. This is after the entire usual firing procedure including damage, etc. Currently, this only works for the player.

Properties

Items also have all the Thing properties in addition to those listed below. For items, the meaning of the resistance fields vary depending on the item type. For armor and boots, the resistances are applied only to attacks to the corresponding target. For other equipment, the resistance applies to all attacks. For non-equipment, the resistances aren't used. Also, some properties are only valid for armor, and some are only valid for weapons. For these purposes, armor are items with itype ITEMTYPE_ARMOR and ITEMTYPE_BOOTS and weapons are items with itype ITEMTYPE_AMMO, ITEMTYPE_MELEE, ITEMTYPE_NRANGED, ITEMTYPE_RANGED, and ITEMTYPE_AMMOPACK. Properties of the incorrect type are always indexable, but they may share a memory address with properties of the opposite type, so modders should only use this feature very carefully. The type of such properties is noted. Also, the meaning of many fields is slightly different depending on the itype; these differences are also described.

Item
ItemType itype This determines the basic features of the item. ITEMTYPE_NONE has no features; it can't be picked up or used. ITEMTYPE_RANGED can be picked up and wielded as a ranged weapon. ITEMTYPE_NRANGED is like ITEMTYPE_RANGED, but it isn't designed to exist on the map. ITEMTYPE_ARMOR can be picked up and equipped as armor. ITEMTYPE_MELEE can be picked up and wielded as a melee weapon. ITEMTYPE_AMMO is always a new ammo type that can be picked up and stacked. ITEMTYPE_PACK items can be picked up and used. ITEMTYPE_POWER items are consumed when they are picked up. ITEMTYPE_BOOTS can be picked up and worn as boots. ITEMTYPE_TELE have no special features, but by convention they interact with OnEnter. ITEMTYPE_LEVER have special description routines, and they can be used while on the floor. ITEMTYPE_AMMOPACK can be picked up and wielded in the prepared slot. They provide reloading benefits. While it is possible to change an item's itype, this should almost never be done. If it is done, care must be taken to account for overlapping weapon and armor properties.
byte armor For armor and boots, this is the amount of protection provided at full durability. Weapons in the main slot may also provide a (universal) protection bonus with this field.
word durability For armor and boots, this is the current amount of durability of the item. This property is armor-specific.
word maxdurability For armor and boots, this is the maximum amount of durability. Most effects won't raise the durability above maxdurability. This property is armor-specific.
integer movemod For armor and boots, this percentage movement speed modifier is applied while the item is equipped. This property is armor-specific.
integer knockmod For armor and boots, this percentage knockback modifier is applied while the item is equipped. This property is armor-specific.
Item ID ammoid This must always be a number id. For ranged weapons, this is the item id of the kind of ammo the weapon uses. For ammo packs, this is the kind of ammo provided by the pack. This property is weapon-specific.
word ammo For ranged weapons, this is the amount of currently-loaded ammo. For ammo packs and ammo stacks, this is the amount of ammo inside. This property is weapon-specific.
word ammomax For ranged weapons, this is the size of the magazine. For ammo stacks, this is the maximum stack size (unaffected by BF_BACKPACK). For ammo packs, this is the initial amount of ammo. This property is weapon-specific.
word acc For ranged and melee weapons, this is an accuracy modifier applied to attacks with the weapon. This property is weapon-specific.
word damage_sides For weapons, this is the number of dice rolled for damage (e.g. the X of XdY). This property is weapon-specific.
word damage_dice For weapons, this is the number of sides on each die rolled for damage (e.g. the Y of XdY). This property is weapon-specific.
integer damage_add For weapons, this is a flat bonus added to all damage rolls. This property is weapon-specific.
Missile ID missile This must always be a number id. For ranged weapons, this is the missile used by the weapon. For melee weapons, this is the missile used by the throw alternate fire mode (if any). This property is weapon-specific.
byte blastradius This is the radius of the explosion caused by a ranged weapon. This should be 0 for weapons with no explosion. This property is weapon-specific.
byte shots This is the number of shots fired by a rapid-fire ranged weapon. This should be 0 (not 1) for single-shot weapons. This property is weapon-specific.
byte shotcost This is the amount of ammo consumed by each shot with a ranged weapon. This should be 0 (not 1) for weapons that take only one ammo per shot. This property is weapon-specific.
byte reloadtime This is the number of 0.1s intervals it takes (without modifiers) to reload a ranged weapon. This property is weapon-specific.
byte usetime This is the number of 0.1s intervals it takes (without modifiers) to fire/use a weapon. This property is weapon-specific.
DamageType damagetype This is the type of the damage caused by a weapon. This property is weapon-specific.
AltFire altfire This is the alternate fire mode of a weapon. For ALT_SCRIPT, the details depend on the OnAltFire hook. This property is weapon-specific.
AltReload altreload This is the alternate reload mode of a ranged weapon. For RELOAD_SCRIPT, the details depend on the OnAltReload hook. This property is weapon-specific.
string desc This is the string used to describe the item in the inventory list. For the description in the inventory sidebar, use .proto.desc. This property is read-only.
Item Prototype __proto This is the item's prototype. You can access item prototype fields using this (e.g., item.__proto.color).

API

The Thing API can also be used with items.

Item Interface
Item new(Item ID iid)
boolean add_mod(string modletter)
boolean can_mod(string modletter)
integer get_mod(string modletter)
boolean clear_mods()
boolean is_damaged()
boolean fix(integer amount)
table get_mods()
table get_mod() → cln
boolean can_overcharge()
boolean check_mod_array(string nextmod, integer techbonus)

new(Item ID iid) → Item
This returns a newly allocated item create from the specified prototype. This item doesn't exist in the game yet; it must be dropped on the level, added to an inventory, or equipped.

add_mod(string modletter) → boolean
Adds a mod to the item's mod list and sets the IF_MODIFIED flag. This does not apply any affects of the mod, it is only a primitive operation for accessing the mod list. modletter should be a single uppercase letter representing the mod. This will check modding restrictions (as can_mod) and return true on success, false on failure.

can_mod(string modletter) → boolean
Determines if the given mod can be added to the item. modletter should be a single uppercase letter representing the mod. This will always use the player's techbonus. It also accounts for limits on the number of mods of a given type and various modability item flags.

get_mod(string modletter) → integer
Counts the number of the given mod that have already been added to the item. modletter should be a single uppercase letter representing the mod.

clear_mods() → boolean
Clears the counts of all mods for the item. The does not undo the affects of the mods nor does it change any flags (including IF_MODIFIED).

is_damaged() → boolean
This determines if the item's durability is less than its maxdurability. For items with IF_NOREPAIR, this function always returns false. (So, in effect this function determines if the item needs to be repaired.)

fix(integer amount) → boolean
This will increase the item's durability by amount, respecting maxdurability. It returns true is the item is no longer is_damaged. amount is optional; by default the item is completely repaired.

get_mods() → table
This will return a table that maps single character mod letters to the corresponding amount of mods that have been applied to the item. Mod letters that have not been applied are not included as keys.

get_mod() → cln

As get_mods, but the table returned gives all mods in terms of their sID.

can_overcharge() → boolean
This will determine if the item can be overcharged. To be overcharged, an item can't already by overcharged (IF_DESTROY), and must be fully loaded. The ui part of overcharging is included. On success, IF_DESTROY and IF_NOUNLOAD are set, but other affects must be applied by the caller.

check_mod_array(string nextmod, integer techbonus) → boolean
This will check if the mod indicated by nextmod (the single uppercase character representing the mod) could form an assembly (given the provided techbonus). If so, the assembly is created on the item (if the player confirms the ui message) with all associated side effects. Returns true only if the assembly is actually created.
Personal tools