Difference between revisions of "Manual:DIL Manual/UNIT ST NPC"

From DikuMUD Wiki
Jump to navigation Jump to search
(XML import)
(checked against the compiler and the interpreter; example compiles)
 
Line 1: Line 1:
−
<span id="unpc"></span>
+
= UNIT_ST_NPC =
−
'''if the type is UNIT_ST_NPC '''
+
'''Constant''' (integer, vme.h: 0x01).
  
−
      'defaultpos'  :integer (RW)
+
A non-player character: a monster, a shopkeeper, a guard. <code>u.type == UNIT_ST_NPC</code>. The type of a unit is in its <code>type</code> field; the four unit types are bits, so they can be combined with <code>|</code>.
−
          The default position of an NPC, see POSITION_* in values.h and/or vme.h
 
−
  'natural_armour'  :integer (RW)
 
−
    The natural armour of the NPC when naked.
 
−
      'npcflags'    :integer (RW)
 
−
          Some small options for NPC's see NPC_* in values.h and/or vme.h
 
−
      'switched'  :unitptr (RW)
 
−
      Character that is switched into this NPC.
 
−
<span id="unpc"></span>
 
−
'''if the type is UNIT_ST_NPC '''
 
  
−
      'defaultpos'  :integer (RW)
+
== Fields ==
−
          The default position of an NPC, see POSITION_* in values.h and/or vme.h
+
Monsters have the fields of all characters (see [[Manual:DIL Manual/UNIT ST PC and UNIT ST NPC|UNIT_ST_PC and UNIT_ST_NPC]]) and these two, which only monsters have: [[Manual:DIL Manual/defaultpos|defaultpos]], [[Manual:DIL Manual/npcflags|npcflags]].
−
  'natural_armour'  :integer (RW)
+
 
−
    The natural armour of the NPC when naked.
+
== Notes ==
−
      'npcflags'    :integer (RW)
+
* Every unit, whatever its type, has the general fields: [[Manual:DIL Manual/name|name]], [[Manual:DIL Manual/names|names]], [[Manual:DIL Manual/title|title]], [[Manual:DIL Manual/descr|descr]], [[Manual:DIL Manual/outside descr|outside_descr]], [[Manual:DIL Manual/inside descr|inside_descr]], [[Manual:DIL Manual/extra|extra]], [[Manual:DIL Manual/type|type]], [[Manual:DIL Manual/symname|symname]], [[Manual:DIL Manual/nameidx|nameidx]], [[Manual:DIL Manual/zoneidx|zoneidx]], [[Manual:DIL Manual/zone|zone]], [[Manual:DIL Manual/key|key]], [[Manual:DIL Manual/outside|outside]], [[Manual:DIL Manual/inside|inside]], [[Manual:DIL Manual/next|next]], [[Manual:DIL Manual/gnext|gnext]], [[Manual:DIL Manual/gprevious|gprevious]], [[Manual:DIL Manual/flags|flags]], [[Manual:DIL Manual/manipulate|manipulate]], [[Manual:DIL Manual/openflags|openflags]], [[Manual:DIL Manual/opendiff|opendiff]], [[Manual:DIL Manual/weight|weight]], [[Manual:DIL Manual/baseweight|baseweight]], [[Manual:DIL Manual/capacity|capacity]], [[Manual:DIL Manual/height|height]], [[Manual:DIL Manual/light|light]], [[Manual:DIL Manual/bright|bright]], [[Manual:DIL Manual/illum|illum]], [[Manual:DIL Manual/minv|minv]], [[Manual:DIL Manual/alignment|alignment]], [[Manual:DIL Manual/hp|hp]], [[Manual:DIL Manual/max hp|max_hp]], [[Manual:DIL Manual/loadcount|loadcount]], [[Manual:DIL Manual/hasfunc|hasfunc]], [[Manual:DIL Manual/spells|spells]].
−
          Some small options for NPC's see NPC_* in values.h and/or vme.h
+
* <code>spells[]</code> and <code>weapons[]</code> of a monster only go up to the group numbers (<code>SPL_GROUP_MAX</code>, <code>WPN_GROUP_MAX</code> minus one); a player's go up to <code>SPL_TREE_MAX</code> and <code>WPN_TREE_MAX</code> minus one.
−
      'switched'  :unitptr (RW)
+
* Reading a field the unit doesn't have fails, and a failed value is false in every comparison: test the type first.
−
      Character that is switched into this NPC.
+
 
 +
== Example ==
 +
<pre>
 +
dilbegin integer npcdefpos(npc : unitptr);
 +
code
 +
{
 +
  if (npc.type != UNIT_ST_NPC)
 +
      return (-1);
 +
  return (npc.defaultpos);
 +
}
 +
dilend
 +
</pre>
 +
Gives a monster's default position, or -1 for anything else.
 +
 
 +
== See also ==
 +
* [[Manual:DIL Manual/type|type]]
 +
* [[Manual:DIL Manual/Fields|Fields]]
 +
* [[Manual:DIL Manual/UNIT ST PC|UNIT_ST_PC]]
 +
* [[Manual:DIL Manual/UNIT ST PC and UNIT ST NPC|UNIT_ST_PC and UNIT_ST_NPC]]
 +
* [[Manual:DIL Manual/UNIT ST OBJ|UNIT_ST_OBJ]]
 +
* [[Manual:DIL Manual/UNIT ST ROOM|UNIT_ST_ROOM]]

Latest revision as of 23:24, 14 November 2026

UNIT_ST_NPC

Constant (integer, vme.h: 0x01).

A non-player character: a monster, a shopkeeper, a guard. u.type == UNIT_ST_NPC. The type of a unit is in its type field; the four unit types are bits, so they can be combined with |.

Fields

Monsters have the fields of all characters (see UNIT_ST_PC and UNIT_ST_NPC) and these two, which only monsters have: defaultpos, npcflags.

Notes

Example

dilbegin integer npcdefpos(npc : unitptr);
code
{
   if (npc.type != UNIT_ST_NPC)
      return (-1);
   return (npc.defaultpos);
}
dilend

Gives a monster's default position, or -1 for anything else.

See also