Manual:DIL Manual/weapons
Jump to navigation
Jump to search
Contents
weapons
Field (integer, read/write; units: characters).
ch.weapons[idx : integer] : integer
A character's skill, in percent, with a weapon. The index is a WPN_* constant: the weapon groups (WPN_AXE_HAM, WPN_SWORD, WPN_CLUB_MACE, WPN_POLEARM, WPN_UNARMED, WPN_SPECIAL) are in vme.h, the single weapons (WPN_DAGGER, WPN_LONG_SWORD, ...) in values.h.
Players have a skill for every weapon, index 0 to WPN_TREE_MAX - 1. NPCs have one for each weapon group only, index 0 to WPN_GROUP_MAX - 1 (0 to 6).
Notes
- An index out of range fails: on an NPC,
u.weapons[WPN_DAGGER]fails, because a dagger is not a group. - A player's skills can be assigned only by a program in a zone with access level 0 (the fourth column of
vme/etc/zonelist), such as basis.zon, which sets a new player's first skills. Elsewhere vmc accepts the assignment, but at run time the program logs "DIL SERIOUS: ... Type error in lvalue assignemt" and stops. An NPC's skills can be assigned from any zone. Reading works everywhere. - On null it fails. On an object or a room it is a type error, logged in vme.log.
- Stored as a 16-bit signed number.
Example
dilbegin integer backstab_chance(pc : unitptr);
code
{
if (pc.type != UNIT_ST_PC)
return (0);
return ((pc.abilities[ABIL_DEX] + pc.weapons[WPN_DAGGER]) / 2);
}
dilend
Combines a player's dexterity with the dagger skill, as thievesguild.zon does.