Difference between revisions of "Manual:DIL Manual/subaff()"
Jump to navigation
Jump to search
(XML import) |
(checked against the compiler and the interpreter; example compiles) |
||
| Line 1: | Line 1: | ||
| − | + | = subaff() = | |
| − | + | '''Procedure.''' Removes an affect from a unit. | |
| − | |||
| − | |||
| − | |||
| − | + | subaff(u : unitptr, id : integer) | |
| − | |||
| − | subaff ( u : unitptr, | ||
| − | |||
| − | |||
| − | |||
| − | + | Removes the first affect on <code>u</code> whose id is <code>id</code> (the <code>ID_</code> constants in vme.h and values.h). It ends the way an affect that runs out does: its apply function is undone (a lowered ability goes back up, a flag is taken off) and its last-tick function runs, which usually tells the player ("You can see again."). | |
| + | |||
| + | == Parameters == | ||
| + | {| class="wikitable" | ||
| + | ! Name !! Type !! Meaning | ||
| + | |- | ||
| + | | u || unitptr || The character, object or room. | ||
| + | |- | ||
| + | | id || integer || The affect id, e.g. <code>ID_BLIND_CHAR</code>. Negative ids are the transfer affects on objects. | ||
| + | |} | ||
| + | |||
| + | == Notes == | ||
| + | * Only one affect goes, the first one with that id. If the unit can carry several (a spell cast twice), call it until [[Manual:DIL Manual/isaff()|isaff()]] says no. | ||
| + | * Nothing happens when the unit has no such affect or the variable is null. | ||
| + | * It works from any zone; [[Manual:DIL Manual/addaff()|addaff()]] only from zones with access level 0. | ||
| + | * Removing a transfer affect (negative id) from an object that is being worn doesn't take the bonus off the wearer, and the later unequip no longer finds it: the wearer keeps it. [[Manual:DIL Manual/unequip()|Unequip]] the object first. | ||
| + | |||
| + | == Example == | ||
| + | <pre> | ||
| + | dilbegin cure_blind(tgt : unitptr); | ||
| + | code | ||
| + | { | ||
| + | if (not isaff(tgt, ID_BLIND_CHAR)) | ||
| + | { | ||
| + | act("Nothing happens.", A_ALWAYS, self, null, null, TO_CHAR); | ||
| + | return; | ||
| + | } | ||
| + | subaff(tgt, ID_BLIND_CHAR); | ||
| + | act("You touch $3n's eyes.", A_ALWAYS, self, null, tgt, TO_CHAR); | ||
| + | } | ||
| + | dilend | ||
| + | </pre> | ||
| + | Takes blindness off a character, as <code>spl_cure_blind</code> in spells.zon does. | ||
| + | |||
| + | == See also == | ||
| + | * [[Manual:DIL Manual/addaff()|addaff()]] | ||
| + | * [[Manual:DIL Manual/isaff()|isaff()]] | ||
| + | * [[Manual:DIL Manual/getaffects()|getaffects()]] | ||
Latest revision as of 23:16, 14 November 2026
subaff()
Procedure. Removes an affect from a unit.
subaff(u : unitptr, id : integer)
Removes the first affect on u whose id is id (the ID_ constants in vme.h and values.h). It ends the way an affect that runs out does: its apply function is undone (a lowered ability goes back up, a flag is taken off) and its last-tick function runs, which usually tells the player ("You can see again.").
Parameters
| Name | Type | Meaning |
|---|---|---|
| u | unitptr | The character, object or room. |
| id | integer | The affect id, e.g. ID_BLIND_CHAR. Negative ids are the transfer affects on objects.
|
Notes
- Only one affect goes, the first one with that id. If the unit can carry several (a spell cast twice), call it until isaff() says no.
- Nothing happens when the unit has no such affect or the variable is null.
- It works from any zone; addaff() only from zones with access level 0.
- Removing a transfer affect (negative id) from an object that is being worn doesn't take the bonus off the wearer, and the later unequip no longer finds it: the wearer keeps it. Unequip the object first.
Example
dilbegin cure_blind(tgt : unitptr);
code
{
if (not isaff(tgt, ID_BLIND_CHAR))
{
act("Nothing happens.", A_ALWAYS, self, null, null, TO_CHAR);
return;
}
subaff(tgt, ID_BLIND_CHAR);
act("You touch $3n's eyes.", A_ALWAYS, self, null, tgt, TO_CHAR);
}
dilend
Takes blindness off a character, as spl_cure_blind in spells.zon does.