Manual:DIL Manual/equipment()

From DikuMUD Wiki
< Manual:DIL Manual
Revision as of 23:17, 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

equipment()

Function (unitptr). The object a character wears or wields in a given position.

equipment(ch : unitptr, pos : integer) : unitptr

Looks through what ch carries and returns the first object that is equipped in position pos, or null when nothing is there.

Parameters

Name Type Meaning
ch unitptr The character (player or NPC) to look at.
pos integer A WEAR_* position from vme/include/vme.h, such as WEAR_WIELD, WEAR_HOLD, WEAR_SHIELD, WEAR_BODY or WEAR_FINGER_R.

Returns

The equipped object, or null when that position is empty. When ch is null or not a character, the call fails: a variable it is assigned to keeps its old value.

Notes

  • The position is read as a number from 0 to 255. Position 0 means "not equipped", so equipment(ch, 0) returns the first object in the inventory that isn't worn. Use WEAR_* values only.
  • It doesn't check the object's type: equipment(ch, WEAR_WIELD) can be something other than a weapon.
  • The position of an object itself is its equip field.

Example

dilbegin show_wielded();
var
   wpn : unitptr;
code
{
   wpn := equipment(self, WEAR_WIELD);
   if (wpn == null)
      sendtext("You wield nothing.<br/>", self);
   else
      act("You wield $2n.", A_ALWAYS, self, wpn, null, TO_CHAR);
   quit;
}
dilend

Tells the character what it is wielding.

See also