Manual:DIL Manual/npcs
Jump to navigation
Jump to search
Contents
npcs
Field (unitptr, read-only; on a zoneptr).
z.npcs : unitptr
A copy, in the game, of the zone's NPC whose symbolic name sorts first. Only that one NPC is looked at: if no copy of it is loaded, the field fails, even when the zone's other NPCs are about.
It is not the start of a list of the zone's NPCs: next on the NPC gives the next unit in the same place. To find copies of a particular NPC, use findsymbolic("name@zone").
Notes
- It fails on a null zoneptr, on a zone without NPCs, and when the first NPC has no copy in the game. A failed value isn't assigned: after
u := z.npcs;in those cases,ustill holds what it held before, so set it to null first. - It can't be assigned (vmc: "Illegal lvalue").
Example
dilbegin testzonenpcs();
var
z : zoneptr;
u : unitptr;
code
{
z := zhead();
while (z)
{
u := null;
u := z.npcs;
if (u)
log(z.name + ": " + u.symname);
z := z.next;
}
quit;
}
dilend
Logs, for every zone, the copy of its first NPC, as the test in test.zon does.