Manual:DIL Manual/UNIT ST PC and UNIT ST NPC

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

UNIT_ST_PC and UNIT_ST_NPC

Constants (integer, vme.h: 0x02 and 0x01).

Characters: players (UNIT_ST_PC) and monsters (UNIT_ST_NPC). Test for both with u.type & (UNIT_ST_PC | UNIT_ST_NPC); the same mask works in foreach and findunit(). The type of a unit is in its type field; the four unit types are bits, so they can be combined with |.

Fields

Every character has: abilities, attack_type, charflags, defensive, endurance, exp, exptol, fighting, follower, followercount, level, mana, master, max_endurance, max_mana, natural_armour, offensive, opponentcount, position, race, sex, speed, switched, weapons. Players have more fields (see UNIT_ST_PC), and monsters two of their own (see UNIT_ST_NPC).

Notes

Example

dilbegin countchars();
var
   u : unitptr;
   n : integer;
code
{
   n := 0;
   foreach (UNIT_ST_PC | UNIT_ST_NPC, u)
      n := n + 1;
   log(itoa(n) + " characters around " + self.name);
   quit;
}
dilend

Counts the players and monsters around the unit.

See also