Manual:Zone Manual/The NPC Section/Compiling and debugging your first NPC
Contents
Compiling and debugging your first NPC
As we said in
Compiling and debugging your first room,
it is a good idea to build one or two things and then compile, so that errors
are easy to find. Here we compile the dragon from
Building your first NPC
on its own, in a zone of its own, so that the rooms don't get in the way. A zone
must be in a file of the same name, so this zone, debug_npc, is the
file debug_npc.zon. The mistakes in it are there on purpose; if you
type it in, you can find and fix them with us.
#include <macros.h>
%zone debug_npc
lifespan 20
reset RESET_ANYHOW
creators {"whistler"}
notes
"The black dragon on its own, to compile and test it before it joins the
dragon station."
help
"Not sure what could help you now. You are stuck on one of the weirdest
space stations you have ever seen, and you smell burning sulphur."
%mobiles
bldragon
title "a black dragon"
descr "A big ugly black dragon is clawing the ground here."
names {"big ugly black dragon", "ugly black dragon", "big black dragon",
"black dragon", "dragon"}
extra
"The black dragon's scales glitter like black granite that has been
polished for years by water. He has a long neck and huge bat-like
wings. His eyes watch you as you stand before him. One claw taps
slowly on the ground, as if the dragon is waiting for something."
extra {"eyes", "eye"}
"The dragon's eyes follow you wherever you go in the room. Nothing
escapes the dragon's attention."
extra {"claws", "claw"}
"The claws are big, black and deadly. The dragon has two sets of four
large claws and two sets of four smaller ones; the large ones are the
size of long swords, the small ones the size of short swords."
extra {"scales", "scale"}
"It's a scale! Haven't you ever seen a dragon before?"
extra {"bat wings", "wings"}
"The dragon sees you looking and flaps his wings, raising quite a gale."
race RACE_DRAGON_BLACK
sex SEX_MALE
height 625
weight 1250
level 70
NATURAL_DEF(WPN_CLAW_LARGE, ARM_PLATE)
aligment -900
money 1 GOLD_PIECE, 10 SILVER_PIECE
MSET_ABILITY(21,12,12,12,12,12,20,0)
MSET_WEAPON(10,10,10,5,30,5)
MSET_SPELL(0,0,0,0,0,0,1,0,0,0,30)
end
%end
The first compile: syntax errors
Zone files live in vme/zone, and vmc is built into
vme/bin. From vme/zone the command is:
../bin/vmc -d ../etc/ -I../include/ debug_npc.zon
-d tells vmc where the money file and the other
definitions are, -I where macros.h and the other
headers are. The other options are described in
General Compiler Information.
This is what we get:
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'debug_npc.zon' v: debug_npc.zon: 31: syntax error Token: 'extra' v: debug_npc.zon: 52: syntax error Token: 'aligment' Compilation aborted.
The first two lines show when your vmc was built and with which
options, so yours may differ. Each error gives the line number and the word
(token) where vmc gave up.
Line 52 is easy: alignment is misspelt. Line 31 is harder, because
there is nothing wrong with it:
extra {"eyes", "eye"}
When the line looks right, the mistake is usually above it: vmc
only noticed at this word that something before it didn't fit. Going up from
line 31 we find the first extra, on line 25, without its {}.
vmc took the description as the extra's names and then waited for
the description, but found the next extra instead. We add the
{} back:
extra {}
"The black dragon's scales glitter like black granite that has been
polished for years by water. He has a long neck and huge bat-like
wings. His eyes watch you as you stand before him. One claw taps
slowly on the ground, as if the dragon is waiting for something."
and correct the spelling:
alignment -900
Often it is safest to fix the first error and compile again, because one mistake can cause errors further down that aren't really there. Here the two errors are clearly separate, so we fix both at once.
The second compile: values
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'debug_npc.zon' FATAL: Abilities in 'bldragon' sums up to 101,and not 100. FATAL: Spells&weapons in 'bldragon' sums up to 101, and not 100. WARNING: Too much money on bldragon. (2 gold pieces and 2 silver pieces vs a gold piece, 2 silver pieces, 7 copper pieces and 4 iron pieces) WARNING: Fatal errors in zone.
The syntax is right now, and vmc checks the values. These messages
have no line numbers, but they name the unit, bldragon.
The abilities must add up to 100, and mine add up to 101: one too many in
MSET_ABILITY. The weapons and spells together must also add up to
100, and they are one over too: one too many in MSET_SPELL. Search
for MSET_ and you are there. We take one off strength and the
stray 1 out of the spells:
MSET_ABILITY(20,12,12,12,12,12,20,0) MSET_WEAPON(10,10,10,5,30,5) MSET_SPELL(0,0,0,0,0,0,0,0,0,0,30)
A "FATAL" error stops the compile; a "WARNING" doesn't. The money warning is advice: a level 70 NPC is expected to carry at most what follows "vs", a little over one gold piece, and we gave the dragon more than two.
The third compile: a warning
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'debug_npc.zon' WARNING: Too much money on bldragon. (2 gold pieces and 2 silver pieces vs a gold piece, 2 silver pieces, 7 copper pieces and 4 iron pieces) VMC Done.
"VMC Done." means the zone compiled: a warning alone doesn't stop it. We follow the advice anyway:
money 1 GOLD_PIECE
and compile once more:
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026] VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG] Compiling 'debug_npc.zon' VMC Done.
No errors, no warnings. The option -l makes most warnings fatal, if
you want to be strict with yourself.
What the dragon got
With -v (verbose), vmc also shows the abilities each
NPC got from its level and percentages; the HIT column is its hit points:
../bin/vmc -v -d ../etc/ -I../include/ debug_npc.zon
VMC 2.0 Copyright (C) 2001 by Valhalla [Nov 14 2026]
VMC Compiled with [-DDMSERVER -DPOSIX -DVMC -DVMC_SRC -DLINUX -DMUD_DEBUG]
Compiling 'debug_npc.zon'
STR DEX CON HIT BRA CHA MAG DIV
bldragon 102 75 75 235 75 75 102 0
VMC Done.
The files
A successful compile leaves these files next to the zone:
debug_npc.data debug_npc.dot debug_npc.err debug_npc.reset debug_npc.zon
.data and .reset are what the server loads.
.err repeats the errors and warnings found after parsing (it is
empty now); syntax errors are only printed. .dot is a map of the
zone's rooms for Graphviz. A zone with DIL also gets a .dh file.
None of these are sources; don't edit them.
If the compile fails, vmc doesn't write new .data and
.reset files, and old ones from an earlier compile stay. The server
would then load the old version without a word, so make sure the last compile
ended with "VMC Done.".
Trying it in the game
The server loads only the zones listed in vme/etc/zonelist. Add a
line for a new zone; copy the line of an ordinary zone such as
haon_dor and change the name. A blank line ends the list, and zones
after it are never loaded. The server reads zones only when it starts, so
restart it after every compile.
Then log in with your builder character and load the dragon:
load bldragon@debug_npc
wstat zone debug_npc mobiles lists the zone's NPCs and
wstat bldragon@debug_npc shows everything about the dragon.
Things vmc doesn't check, such as the names of DIL functions in a
dilcopy, show up when the server starts: look for the zone's name
in vme/bin/vme.log.
There you go: you have compiled your first NPC. With what you have learnt so far you can already make a wide range of monsters. The next page covers the DIL functions you can give an NPC, and then we get on to more complex examples.