Manual:Zone Manual/The NPC Section
Contents
The NPC section
Now that you have rooms, it is time to fill your area with some life. An NPC (non-player character, also called a mobile or monster) is anything alive that the game controls: the monsters players hunt, the shopkeepers they trade with, the guards that stop them.
NPCs are defined in the %mobiles section of the zone file. Like every
unit, an NPC starts with its symbol and ends with end; the fields
in between can come in any order. Defining an NPC doesn't put it in the game: a
load command in the %reset section does that (see
Loading objects and NPCs).
Most NPCs are not built field by field. The header macros.h, which
every zone includes, holds hundreds of ready-made templates (a human warrior, a
black dragon, a rat) that set race, level, size, abilities and skills in one
line. You then add the names and descriptions and change what differs. The
templates and the macros they are made of are on the next page,
NPC macros. This page
describes every field, so that you know what the templates set and what you
can change.
A complete NPC built from a template:
hansen
M_SHOP_KEEPER(20, SEX_MALE, RACE_HUMAN)
title "Hansen"
descr "Hansen the postman is standing here, sorting the mail."
names {"hansen", "postman"}
extra {}
"Hansen is a short, round man in a blue coat. He hums while he sorts."
romflags {CHAR_DETECT_INVISIBLE}
end
The NPC fields
The fields marked "unit" can be used on rooms and objects as well; the
Unit building blocks page explains
the general rules. The defaults are what vmc sets when a field is
left out.
| Field | Value | Default | Notes |
|---|---|---|---|
names
|
string list | none | unit; what players type to act on the NPC |
title
|
string | none | unit; shown when the NPC acts or talks |
descr
|
string | none | unit; shown in the room when the NPC stands |
inside_descr
|
string | none | unit; seen from inside the NPC |
extra
|
names and a string | none | unit; the look description and other details |
level
|
0..199 | 1 | |
race
|
RACE_*
|
RACE_HUMAN
|
|
sex
|
SEX_*
|
SEX_NEUTRAL
|
|
alignment
| |||
| 0 | unit | ||
height
|
centimetres | 180 | unit |
weight
|
pounds, up to 32767 | 120 | unit |
ability[ABIL_*]
|
percentage | see below | use MSET_ABILITY
|
weapon[WPN_*]
|
percentage | unarmed 100 | use MSET_WEAPON
|
spell[SPL_*]
|
percentage | all 0 | use MSET_SPELL
|
attack
|
WPN_*
|
WPN_FIST
|
natural attack; use NATURAL_DEF
|
armour
|
ARM_*
|
ARM_HLEATHER
|
natural armour; use NATURAL_DEF
|
offensive
| |||
| 0 | use ATTACK_DEFENSE
| ||
defensive
| |||
| 0 | use ATTACK_DEFENSE
| ||
speed
|
4..200 | 12 | lower is faster |
exp
| |||
| 100 | experience share | ||
money
|
count and coin, ... | none | |
position
|
POSITION_*
|
POSITION_STANDING
|
|
default
|
POSITION_*
|
POSITION_STANDING
|
|
romflags
|
CHAR_* flags
|
none | |
flags
|
UNIT_FL_* flags
|
none | unit |
npcflags
|
NPC_* flags
|
none | |
manipulate
|
MANIPULATE_* flags
|
none | unit |
capacity
|
number | 0 | unit |
light, bright
| |||
| 0 | unit | ||
minv
|
level | 0 | unit |
dilcopy, dilbegin
|
DIL | none | unit; behaviour |
special, affect
|
none | unit; rarely used on NPCs | |
key, open
|
none | unit; for doors and containers | |
hit, mana
|
number | ignored on NPCs |
Symbol, names, title and descriptions
Symbol. Give the NPC a symbol that resembles its title. Administrators and
builders use the symbol to find, examine and load the NPC
(load bldragon@dragonst, wstat bldragon@dragonst),
and wstat zone dragonst mobiles lists the NPCs by symbol only.
title is the short name shown when the NPC does something: "a black dragon
hits you", "Hansen says ...". Start it with a lower-case letter unless it is a
proper name, and don't end it with punctuation. vmc warns about a
title that starts with "A", "An" or "The" ("Title CASE seems to be wrong") and
about one that ends with a full stop or other non-letter ("Title ends with
non-alphabet character").
title "a small dog" title "Hansen" title "an elephant"
descr is the line shown in the room while the NPC is standing. In any
other position the room shows its title and the position instead, for example
"a black dragon is sleeping here." The default field doesn't
change this.
descr "Hansen the postman is standing here, sorting the mail."
names is what players type to look at, attack or talk to the NPC, and
what administrators use in their commands. Cover every way a player might refer
to the title and the description. No name may begin with an earlier name in the
list, so put the longer names first: {"black dragon", "black"}
compiles, {"black", "black dragon"} is a "Name order error".
baby_dragon
title "a baby black dragon"
descr "A tiny baby black dragon is playing here."
names {"tiny baby black dragon", "tiny black dragon", "baby black dragon",
"black dragon", "tiny dragon", "baby dragon", "dragon"}
end
inside_descr is what a player sees from inside the NPC: a stomach, or the back of a mount.
inside_descr "The lining of this stomach looks indestructible. You are in for a long digestion cycle."
extra gives the NPC its details. An extra with an empty names list,
extra {}, is what players see when they look at the NPC. Extras
with names describe parts of it.
extra {}
"The green furry hamster is glowing, and it doesn't look very happy."
extra {"hamster head", "head"}
"This human-like head is covered with green fur, and it looks really
upset."
Extras whose name starts with $ are not shown to players; DIL
programs use them to store data. A few of them change messages. On an NPC that
can be picked up (MANIPULATE_TAKE), these replace the usual
messages of get and drop; $1n is the
player and $2n the NPC:
| Extra | Shown to |
|---|---|
$get_s
|
the player who picks the NPC up |
$get_o
|
the others in the room |
$drop_s
|
the player who drops it |
$drop_o
|
the others in the room |
extra {"$get_s"}
"You pick up $2n. It is very warm and cuddles right up to you."
extra {"$get_o"}
"$1n picks up $2n, and the two of them cuddle together."
Body: race, sex, height, weight
race is one of the RACE_* constants in values.h
(listed in Race Definitions in values.h).
Spells, skills and DIL programs use the race to treat creatures differently;
an aggressive guard can attack only orcs, for example. If no race fits, you can
add a constant to values.h (so that other zones can use it too) or
write the number directly, but a name is easier to read.
race RACE_MONKEY race RACE_DRAGON_BLACK
sex is SEX_NEUTRAL (the default), SEX_MALE or
SEX_FEMALE. Make the descriptions match: a female dragon shouldn't
be "he" in its extras.
sex SEX_MALE
height is in centimetres (default 180). Equipment an NPC gets from an
equip reset is resized to fit it.
weight is in pounds (default 120, at most 32767). A character's weight and
strength decide how much it can carry, and the weight how hard its natural
attack hits (see NPC macros).
height 183 // 6 feet; 1 inch is 2.54 cm weight 80
Level, alignment, experience and money
level is 0..199 (default 1); anything else is a fatal error. The level
decides how many ability and skill points the NPC gets (see below), and with
exp how much experience it gives.
level 50
alignment is -1000 (utterly evil) to +1000 (utterly good). The game counts 350 and above as good, -350 and below as evil, and the rest as neutral. A value outside -1000..1000 is kept within it, with a warning.
alignment -750 // quite evil, maybe a ghoul alignment 350 // just good
exp is the experience share the NPC gives when it is killed, -500..499;
the default 100 is a normal share. The game adjusts it for the level difference
between the NPC and its killers (more for a higher-level NPC, less for a lower
one). Raise it for an NPC that is harder to kill than its level suggests, lower
it for one that is easier. 0 gives no experience, and a negative value takes
experience away from the killer: the shopkeeper template uses
exp -400 to protect shopkeepers.
exp 150 // half as much again as normal exp -50 // killing it costs experience
money is the money the NPC carries, as a count and a coin, separated by
commas. The coins are IRON_PIECE, COPPER_PIECE,
SILVER_PIECE, GOLD_PIECE and
PLATINUM_PIECE. money 25600 and
money 5*GOLD_PIECE (from older manuals) are syntax errors.
money 3 SILVER_PIECE, 20 IRON_PIECE
Each coin is worth eight of the one below it (8 iron pieces make a copper
piece, and so on). vmc warns ("Too much money on ...") when an NPC
carries more than its level suggests: 5 iron pieces per level up to level 20,
10 per level up to level 100, 15 up to 150 and 20 above. A level 50 NPC may
carry 500 iron pieces, a little under 8 silver pieces. It is only advice; the
money is kept.
Abilities, weapon and spell skills
An NPC's abilities (strength, dexterity, constitution, hit points, brain,
charisma, magic and divine power) and its weapon and spell skills aren't given
as numbers. You give percentages, and vmc shares out the points an
NPC of that level gets. The eight ability percentages must add up to 100, and
the weapon and spell percentages together must add up to 100; anything else is
a fatal error.
Don't set ability[...], weapon[...] and
spell[...] one by one: the defaults already add up to 100
(abilities: STR 40, DEX 30, CON 10, HP 15, BRA 3, CHA 2; weapons: unarmed 100),
so a single extra line breaks the sum. Use the macros MSET_ABILITY,
MSET_WEAPON and MSET_SPELL, which set the whole group;
they are described on NPC macros.
The NPC's hit points come from its HP ability (10 + 3 × HP points). The
hit and mana fields are accepted but have no effect on
an NPC.
Combat: natural attack and armour, bonuses, speed
attack and armour are how the NPC fights without a weapon and how it
is protected without armour: a dog bites and has leather-like skin, a metal cat
claws and is as hard as plate. Set both with NATURAL_DEF.
offensive and defensive are bonuses (-1000..1000, default 0) added to
the NPC's attack and defence rolls. Set both with ATTACK_DEFENSE.
speed is the combat speed, 4..200 (default 12); lower is faster. At 12 the
NPC attacks once per combat round, at 4 three times. vme.h has
names for the fast speeds: SPEED_150 (8), SPEED_200
(6), SPEED_240 (5) and SPEED_300 (4). 0 is a fatal
error.
speed SPEED_150
Position
position is the position the NPC is loaded in:
POSITION_DEAD POSITION_MORTALLYW POSITION_INCAP POSITION_STUNNED POSITION_SLEEPING POSITION_RESTING POSITION_SITTING POSITION_FIGHTING POSITION_STANDING
Only POSITION_SLEEPING, POSITION_RESTING,
POSITION_SITTING and POSITION_STANDING (the default)
make sense in a zone file; the others are for DIL. An NPC that doesn't stand is
shown in the room by its title and position, not by its descr.
position POSITION_SITTING
default is the NPC's default position (default
POSITION_STANDING). The game itself doesn't use it; it is shown by
wstat, and DIL programs can read and change it as
defaultpos.
Flags
An NPC has three sets of flags, each with its own field. vmc sees
only numbers, so a flag under the wrong field compiles without a word and sets
a different flag: flags {CHAR_SNEAK} sets
UNIT_FL_NO_WEATHER. Several values go in braces, separated by
commas, and every flags, romflags and
manipulate line adds to the flags already set, so a template's
flags stay.
romflags takes the character flags, CHAR_*
(vme.h). The ones worth setting on an NPC:
| Flag | Effect |
|---|---|
CHAR_PROTECTED
|
Protected by the law system: killing it is a crime, and it reports crimes it
sees. The shopkeeper template sets it. |
CHAR_HIDE
|
Hidden: not shown in the room. Being attacked ends it. |
CHAR_SNEAK
|
Moves without leave and arrive messages. |
CHAR_DETECT_INVISIBLE
|
Sees invisible characters and things. |
CHAR_WIMPY
|
Flees when a blow takes more than a quarter of its hit points, or when it has
less than a quarter left. |
CHAR_BLIND
|
Can't see. |
CHAR_MUTE
|
Can't use the speech commands. |
The other CHAR_* flags are set by the game itself (the law system,
groups, combat, spells, player settings); don't put them in a zone.
romflags {CHAR_HIDE, CHAR_WIMPY}
A romflags line after a template adds to the template's flags:
M_SHOP_KEEPER(...) followed by
romflags {CHAR_DETECT_INVISIBLE} makes a protected, wimpy
shopkeeper who also sees invisible. (Before November 2026 the last
romflags replaced the earlier ones, a macro's too.)
flags takes the unit flags, UNIT_FL_* (vme.h),
which rooms and objects use too. On an NPC these matter:
| Flag | Effect |
|---|---|
UNIT_FL_INVISIBLE
|
Invisible to those who can't detect invisible. |
UNIT_FL_NO_TELEPORT
|
Teleport spells can't take it away, and it can't teleport itself. |
UNIT_FL_TRANS
|
Transparent: the room shows what it carries, and a rider sees out of it.
Needed for a mount (see |
UNIT_FL_NOSAVE
|
A player carrying it can't save it (for a pet that can be picked up). |
UNIT_FL_BURIED
|
Buried: nobody can see it. |
npcflags takes the NPC_* flags. The only one defined is
NPC_NICE_THIEF, and nothing in the current code reads it.
manipulate takes MANIPULATE_* flags. On an NPC two are
useful: MANIPULATE_TAKE lets players pick it up (a familiar, a
pet), and MANIPULATE_ENTER is part of a mount.
// a pet that can be carried but not saved
manipulate {MANIPULATE_TAKE}
flags {UNIT_FL_NOSAVE}
A mount needs UNIT_FL_TRANS, MANIPULATE_ENTER and an
extra named $trained: mount accepts either flag, but
dismount lets the rider off only when all three are there. The
mount must also be strong enough to carry its rider.
flags {UNIT_FL_TRANS}
manipulate {MANIPULATE_ENTER}
extra {"$trained"} ""
Behaviour: DIL
On its own an NPC stands and fights back when attacked. Everything else
(attacking players, wandering, guarding a door, selling, casting spells in a
fight) is done by DIL programs. You seldom write these yourself: the zone
function.zon holds ready-made ones that you copy onto the NPC with
dilcopy, giving the arguments the program needs:
dilcopy evaluate@function(64);
This NPC evaluates weapons and armour for players, for 64 iron pieces each. The
; at the end is required. vmc checks neither the
program's name nor its arguments; a mistake shows up when the server boots or
when the program runs.
The programs for NPCs (aggression, combat magic, wandering, guards, shopkeepers,
team work, rescue and more) and their arguments are described in
DIL functions for NPCs,
and put to work in A more complex set of NPCs.
A program written inside the NPC itself, between dilbegin and
dilend, is the subject of the
DIL manual (see dilcopy
and dilbegin).
A few built-in functions are still attached with special instead of
DIL, for example teachers (special SFUN_TEACH_INIT). The old
specials such as SFUN_AGGRESSIVE and
SFUN_COMBAT_MAGIC are gone; use the DIL functions.
Other fields
light and bright (-6..6, default 0). bright is the
light the NPC gives off: bright 1 lights up the room it is in, a
negative value darkens it, and looking at it says "Light comes from ...".
light is the light inside the NPC, for whoever is in it.
bright 1 // a glowing creature
minv hides the NPC from every character below that level:
minv 239 lets only characters of level 239 and up see it, until an
administrator or a DIL program lowers it.
capacity is how much fits inside the unit. A character's own carrying limit
comes from its strength, dexterity and weight, not from
capacity.
key and open are meant for doors and containers (see the objects section) and are not normally used on NPCs.
affect gives a unit an effect it starts with; the transfer macros in
wmacros.h write it for objects. It is rarely used on NPCs.