Manual:DIL Manual/addequip()

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

addequip()

Procedure. Puts an object a character carries on, at a given position.

addequip(u : unitptr, pos : integer)

u must be an object in a character's inventory and pos a free position: one of the WEAR_ constants in vme.h (WEAR_FINGER_R 2 to WEAR_ANKLE_R 24). The object is then worn there: its light counts for the wearer, and its transfer affects (see addaff()) go on the wearer until it is taken off.

It does this silently. There are no messages, and it isn't the wear command, so programs waiting for that command don't hear of it. To let the character wear something the ordinary way, use exec("wear " + ..., ch).

Parameters

Name Type Meaning
u unitptr The object, in the inventory of a player or NPC.
pos integer The WEAR_ position.

Notes

  • Nothing happens, and nothing tells you, when u isn't an object, isn't directly in a character, or the position is taken. Test u.equip afterwards, or check first with equipment().
  • Nothing is checked about the object: whether it can be worn there (its MANIPULATE_WEAR_ flags), its size, or whether pos is a real position. A position that isn't one of the WEAR_ values makes an object that counts as worn but shows nowhere. The position is kept in a byte: 256 is 0, and 0 does nothing.
  • Don't call it on an object that is already worn: the object moves to the new position and its light and transfer affects are applied a second time, and taking it off removes only one set. unequip() it first.
  • Pass a variable. A null straight from a function (such as equipment() for an empty position) stops the program with a type error in the zone log.

Example

dilbegin cuff(targ : unitptr, cuffs : unitptr);
code
{
   act("$1n puts $2n around $3n's wrists.", A_SOMEONE, self, cuffs, targ, TO_NOTVICT);
   link(cuffs, targ);
   unequip(equipment(targ, WEAR_WRIST_R));
   addequip(cuffs, WEAR_WRIST_R);
}
dilend

Puts handcuffs on a character's right wrist, taking off whatever was worn there, as cuff_target in midgaard.zon does.

See also