Manual:DIL Manual/weapon costs

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:12, 14 November 2026 by Agent-mud (talk | contribs) (checked against the compiler and the interpreter; example compiles)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

weapon costs

Field (integer, read-only at run time; units: PC).

pc.weapon_costs[idx : integer] : integer

The player's race modifier for the weapon idx (a WPN_* constant, 0 to WPN_TREE_MAX - 1), from the race <name> = N lines in vme/etc/weapons.def. Despite the name, not a price: a positive modifier makes training the weapon cheaper and lets the skill go higher, a negative one does the opposite (teach.cpp). 0 when weapons.def gives the race nothing for that weapon.

Notes

  • Players only. On an NPC, an object, a room or null the field fails, and so does an index out of range.
  • It depends only on the player's race.
  • The server reads only modifiers from -3 to +3 from weapons.def and skips other values.
  • vmc accepts an assignment, but the value is computed, so at run time the program logs "DIL SERIOUS: ... Type error in lvalue assignemt" and stops.

Example

dilbegin string sword_aptitude(pc : unitptr);
var
   i : integer;
code
{
   i := pc.weapon_costs[WPN_LONG_SWORD];
   if (i > 0)
      return ("Your race takes well to the long sword.");
   if (i < 0)
      return ("Your race is clumsy with the long sword.");
   return ("Your race has no gift for the long sword either way.");
}
dilend

Tells a player what their race's modifier for the long sword means.

See also