Difference between revisions of "Manual:DIL Manual/addequip()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = addequip() = | |
| − | + | '''Procedure.''' Puts an object a character carries on, at a given position. | |
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | addequip(u : unitptr, pos : integer) | |
| − | |||
| − | addequip ( u : unitptr , | ||
| − | |||
| − | |||
| − | |||
| − | |||
| − | + | <code>u</code> must be an object in a character's inventory and <code>pos</code> a free position: one of the <code>WEAR_</code> constants in vme.h (<code>WEAR_FINGER_R</code> 2 to <code>WEAR_ANKLE_R</code> 24). The object is then worn there: its light counts for the wearer, and its transfer affects (see [[Manual:DIL Manual/addaff()|addaff()]]) go on the wearer until it is taken off. | |
| + | |||
| + | It does this silently. There are no messages, and it isn't the <code>wear</code> command, so programs waiting for that command don't hear of it. To let the character wear something the ordinary way, use <code>exec("wear " + ..., ch)</code>. | ||
| + | |||
| + | == Parameters == | ||
| + | {| class="wikitable" | ||
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | u || unitptr || The object, in the inventory of a player or NPC. | ||
| + | |- | ||
| + | | pos || integer || The <code>WEAR_</code> position. | ||
| + | |} | ||
| + | |||
| + | == Notes == | ||
| + | * Nothing happens, and nothing tells you, when <code>u</code> isn't an object, isn't directly in a character, or the position is taken. Test <code>u.equip</code> afterwards, or check first with [[Manual:DIL Manual/equipment()|equipment()]]. | ||
| + | * Nothing is checked about the object: whether it can be worn there (its <code>MANIPULATE_WEAR_</code> flags), its size, or whether <code>pos</code> is a real position. A position that isn't one of the <code>WEAR_</code> 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. [[Manual:DIL Manual/unequip()|unequip()]] it first. | ||
| + | * Pass a variable. A null straight from a function (such as <code>equipment()</code> for an empty position) stops the program with a type error in the zone log. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | 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 | ||
| + | </pre> | ||
| + | Puts handcuffs on a character's right wrist, taking off whatever was worn there, as <code>cuff_target</code> in midgaard.zon does. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/unequip()|unequip()]] | ||
| + | * [[Manual:DIL Manual/equipment()|equipment()]] | ||
| + | * [[Manual:DIL Manual/equip|equip]] | ||
| + | * [[Manual:DIL Manual/link()|link()]] | ||
Latest revision as of 23:16, 14 November 2026
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
uisn't an object, isn't directly in a character, or the position is taken. Testu.equipafterwards, or check first with equipment(). - Nothing is checked about the object: whether it can be worn there (its
MANIPULATE_WEAR_flags), its size, or whetherposis a real position. A position that isn't one of theWEAR_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.