Manual:DIL Manual/UNIT ST NPC
Jump to navigation
Jump to search
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
- Every unit, whatever its type, has the general fields: name, names, title, descr, outside_descr, inside_descr, extra, type, symname, nameidx, zoneidx, zone, key, outside, inside, next, gnext, gprevious, flags, manipulate, openflags, opendiff, weight, baseweight, capacity, height, light, bright, illum, minv, alignment, hp, max_hp, loadcount, hasfunc, spells.
spells[]andweapons[]of a monster only go up to the group numbers (SPL_GROUP_MAX,WPN_GROUP_MAXminus one); a player's go up toSPL_TREE_MAXandWPN_TREE_MAXminus one.- Reading a field the unit doesn't have fails, and a failed value is false in every comparison: test the type first.
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.