Manual:DIL Manual/isaff()

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

isaff()

Function (integer). Tells whether a unit carries an affect with a given id.

isaff(u : unitptr, id : integer)

Looks through the affects on u (spells, poisons, curses and other timed effects added with addaff()) and is TRUE if one of them has the id id. It works on any unit: characters, objects and rooms.

Parameters

Name Type Meaning
u unitptr The unit to look at.
id integer The affect id, an ID_* constant.

Returns

Integer: 1 if u has at least one affect with that id, otherwise 0. If u is null, the result fails: false in an if, so not isaff(null, ...) is true.

Notes

  • The ID_* constants are in vme/include/vme.h (ID_CORPSE, ID_BLIND_CHAR, ID_INVISIBILITY, ID_CURSE, ...) and vme/include/values.h. There is no ID_BLIND.
  • It only tests for the affect, not its strength or time left. getaffects() lists a unit's affects.
  • An affect isn't the same as a flag: blindness, for instance, can come from an affect (ID_BLIND_CHAR) or from the flag CHAR_BLIND in charflags, so baselook.zon tests both.

Example

dilbegin integer is_blind(u : unitptr);
code
{
   if (u == null)
      return (FALSE);
   return (isaff(u, ID_BLIND_CHAR) or isset(u.charflags, CHAR_BLIND));
}
dilend

Tells whether a character is blind, from an affect or from the flag, as baselook.zon does.

See also