Difference between revisions of "Manual:DIL Manual/weapon info()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = weapon_info() = | |
| + | '''Function''' (intlist). The figures etc/weapons.def gives a weapon type. | ||
| − | + | weapon_info(i : integer) : intlist | |
| − | + | == Parameters == | |
| − | + | {| class="wikitable" | |
| − | + | ! Name !! Type !! Meaning | |
| − | + | |- | |
| + | | i || integer || A weapon type: one of the <code>WPN_</code> numbers in values.h. A weapon object (<code>ITEM_WEAPON</code>) holds its type in <code>value[0]</code>. | ||
| + | |} | ||
| − | + | == Returns == | |
| − | + | A new intlist of 20 numbers: | |
| − | + | {| class="wikitable" | |
| − | + | ! Index !! Meaning | |
| − | + | |- | |
| − | + | | 0 || Hands: 1 for a one-handed weapon, 2 for a two-handed one. | |
| − | + | |- | |
| − | + | | 1 || Speed (the <code>SPEED_</code> values defined in weapons.def). | |
| + | |- | ||
| + | | 2 || Kind of damage: <code>WPNT_SLASH</code> 0, <code>WPNT_BLUDGEON</code> 1, <code>WPNT_PIERCE</code> 2, <code>WPNT_NONE</code> -1 for the weapon groups (spelldef.h). | ||
| + | |- | ||
| + | | 3 || What a shield does against it: <code>SHIELD_M_BLOCK</code> 0, <code>SHIELD_M_REDUCE</code> 1, <code>SHIELD_M_USELESS</code> 2 (vme.h). | ||
| + | |- | ||
| + | | 4 || The group it belongs to (its <code>sphere</code>), such as <code>WPN_AXE_HAM</code>. | ||
| + | |- | ||
| + | | 5 to 19 || Its <code>attack</code> lines: three numbers (offset, base damage, alpha) for each armour type in the order <code>ARM_CLOTHES</code>, <code>ARM_LEATHER</code>, <code>ARM_HLEATHER</code>, <code>ARM_CHAIN</code>, <code>ARM_PLATE</code> (vme.h). The offset for armour type a is at <code>5 + 3*a</code>. | ||
| + | |} | ||
| + | For a number below 0 or from <code>WPN_TREE_MAX</code> (200) up, it returns null: an empty list. | ||
| + | == Notes == | ||
| + | * A number in range that weapons.def doesn't define gives the defaults: one hand, <code>WPNT_SLASH</code>, speed 0, <code>SHIELD_M_BLOCK</code>, group <code>WPN_ROOT</code>, 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 <code>weapon_info(item.value[0]).[0]</code> is 2 (through a variable: a field or index can't follow a call directly). | ||
| − | + | == Example == | |
| − | + | <pre> | |
| − | + | dilbegin integer two_handed(wpn : unitptr); | |
| − | + | var | |
| − | + | il : intlist; | |
| − | + | code | |
| − | + | { | |
| − | + | if (wpn == null) | |
| − | + | return (FALSE); | |
| − | + | if (wpn.objecttype != ITEM_WEAPON) | |
| − | il: | + | return (FALSE); |
| − | + | il := weapon_info(wpn.value[0]); | |
| + | if (length(il) == 0) | ||
| + | return (FALSE); | ||
| + | return (il.[0] == 2); | ||
| + | } | ||
dilend | dilend | ||
| + | </pre> | ||
| + | Tells whether a unit is a two-handed weapon, as two_handed in commands.zon. | ||
| − | + | == See also == | |
| − | + | * [[Manual:DIL Manual/weapon name()|weapon name()]] | |
| − | + | * [[Manual:DIL Manual/value|value]] | |
| − | + | * [[Manual:DIL Manual/objecttype|objecttype]] | |
| − | + | * [[Manual:DIL Manual/intlist|intlist]] | |
| − | + | * [[Manual:DIL Manual/length()|length()]] | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
| − | |||
Latest revision as of 23:19, 14 November 2026
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.