Manual:DIL Manual/isaff()
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 invme/include/vme.h(ID_CORPSE,ID_BLIND_CHAR,ID_INVISIBILITY,ID_CURSE, ...) andvme/include/values.h. There is noID_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 flagCHAR_BLINDincharflags, 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.