Manual:DIL Manual/weapon info()
Jump to navigation
Jump to search
weapon_info()
Function (intlist). The figures etc/weapons.def gives a weapon type.
weapon_info(i : integer) : intlist
Parameters
| Name | Type | Meaning |
|---|---|---|
| i | integer | A weapon type: one of the WPN_ numbers in values.h. A weapon object (ITEM_WEAPON) holds its type in value[0].
|
Returns
A new intlist of 20 numbers:
| Index | Meaning |
|---|---|
| 0 | Hands: 1 for a one-handed weapon, 2 for a two-handed one. |
| 1 | Speed (the SPEED_ values defined in weapons.def).
|
| 2 | Kind of damage: WPNT_SLASH 0, WPNT_BLUDGEON 1, WPNT_PIERCE 2, WPNT_NONE -1 for the weapon groups (spelldef.h).
|
| 3 | What a shield does against it: SHIELD_M_BLOCK 0, SHIELD_M_REDUCE 1, SHIELD_M_USELESS 2 (vme.h).
|
| 4 | The group it belongs to (its sphere), such as WPN_AXE_HAM.
|
| 5 to 19 | Its attack lines: three numbers (offset, base damage, alpha) for each armour type in the order ARM_CLOTHES, ARM_LEATHER, ARM_HLEATHER, ARM_CHAIN, ARM_PLATE (vme.h). The offset for armour type a is at 5 + 3*a.
|
For a number below 0 or from WPN_TREE_MAX (200) up, it returns null: an empty list.
Notes
- A number in range that weapons.def doesn't define gives the defaults: one hand,
WPNT_SLASH, speed 0,SHIELD_M_BLOCK, groupWPN_ROOT, and 100, 0, 100 for every armour type. - The list is a copy: changing it changes nothing in the game.
- A weapon's abilities and fumble chance from weapons.def are not in the list.
- The usual use is the hands: baselook.zon shows "two hand wielded" when
weapon_info(item.value[0]).[0]is 2 (through a variable: a field or index can't follow a call directly).
Example
dilbegin integer two_handed(wpn : unitptr);
var
il : intlist;
code
{
if (wpn == null)
return (FALSE);
if (wpn.objecttype != ITEM_WEAPON)
return (FALSE);
il := weapon_info(wpn.value[0]);
if (length(il) == 0)
return (FALSE);
return (il.[0] == 2);
}
dilend
Tells whether a unit is a two-handed weapon, as two_handed in commands.zon.