Manual:DIL Manual/npcflags

From DikuMUD Wiki
Jump to navigation Jump to search

npcflags

Field (integer, read/write; units: NPC).

npc.npcflags : integer

An NPC's NPC flags, a bit field set in the zone file with npcflags {...} in the mobile. The only constant in vme.h is NPC_NICE_THIEF (an NPC that should treat thieves non-violently); wstat also names bits for sentinel, scavenger, aggressive and stay-zone, without constants.

The server itself does nothing with these bits besides showing them in wstat and saving them, and nothing in the zones tests them. Test and change them with isset(), set() and unset() if your own programs use them.

Notes

  • NPCs only. On a player, an object, a room or null the field fails.
  • Stored as an 8-bit unsigned number: only the lowest 8 bits are kept.
  • Not to be confused with charflags (every character) or flags (unit flags).

Example

dilbegin integer nice_to_thieves(npc : unitptr);
code
{
   if (npc.type != UNIT_ST_NPC)
      return (FALSE);
   return (isset(npc.npcflags, NPC_NICE_THIEF));
}
dilend

dilbegin make_nice(npc : unitptr);
code
{
   if (npc.type == UNIT_ST_NPC)
      set(npc.npcflags, NPC_NICE_THIEF);
   return;
}
dilend

Tests and sets the NPC_NICE_THIEF bit, for a program that decides how an NPC answers a theft.

See also