Manual:DIL Manual/subaff()

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

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.

See also