Difference between revisions of "Manual:Zone Manual/The NPC Section"

From DikuMUD Wiki
Jump to navigation Jump to search
(romflags adds to flags already set (vmc, PR #555); CHAR_HIDE in the example)
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
 
== The NPC section ==
 
== The NPC section ==
  
−
Now that you have rooms down it is time to start filling your area
+
Now that you have rooms, it is time to fill your area with some life. An NPC
−
with some life. The NPC is the Non-player Character or mobile.  These
+
(non-player character, also called a mobile or monster) is anything alive that
−
are the things players will hunt and interact with
+
the game controls: the monsters players hunt, the shopkeepers they trade with,
 +
the guards that stop them.
  
−
In order to get started building NPCs you should first be aware
+
NPCs are defined in the <code>%mobiles</code> section of the zone file. Like every
−
of the NPC fields you can use.  The (Link to npcfields) shows a full listing
+
unit, an NPC starts with its symbol and ends with <code>end</code>; the fields
−
of all the NPC fields and their types as defined in (Link to ch-03).
+
in between can come in any order. Defining an NPC doesn't put it in the game: a
−
{| class="wikitable"
+
<code>load</code> command in the <code>%reset</code> section does that (see
−
|+NPC fields and types
+
[[Manual:Zone Manual/The Reset Section/Loading objects and NPCs|Loading objects and NPCs]]).
−
|-
 
−
!Field
 
−
!Type
 
−
!Field
 
−
!Type
 
−
|-
 
−
|Symbolic name
 
−
|Symbol
 
−
|level
 
−
|Integer
 
−
|-
 
−
|names
 
−
|Stringlist
 
−
|height
 
−
|Integer
 
−
|-
 
−
|title
 
−
|String
 
−
|race
 
−
|Integer
 
−
|-
 
−
|descr
 
−
|String
 
−
|attack
 
−
|Integer
 
−
|-
 
−
|inside_descr
 
−
|String
 
−
|armour
 
−
|Integer
 
−
|-
 
−
|extra
 
−
|Structure
 
−
|speed
 
−
|Integer
 
−
|-
 
−
|manipulate
 
−
|Integer
 
−
|position
 
−
|Integer
 
−
|-
 
−
|flags
 
−
|Integer
 
−
|default
 
−
|Integer
 
−
|-
 
−
|weight
 
−
|Integer
 
−
|ability
 
−
|two Integers
 
−
|-
 
−
|capacity
 
−
|Integer
 
−
|weapon
 
−
|two Integers
 
−
|-
 
−
|dilbegin or dilcopy
 
−
|Function pointer
 
−
|spell
 
−
|two Integers
 
−
|-
 
−
|defensive
 
−
|Integer
 
−
|romflags
 
−
|Integer
 
−
|-
 
−
|offensive
 
−
|Integer
 
−
|light
 
−
|Integer
 
−
|-
 
−
|mana
 
−
|Integer
 
−
|alignment
 
−
|Integer
 
−
|-
 
−
|hit
 
−
|Integer
 
−
|minv
 
−
|Integer
 
−
|-
 
−
|money
 
−
|Integer
 
−
|key
 
−
|String
 
−
|-
 
−
|exp
 
−
|Integer
 
−
|open
 
−
|Integer
 
−
|-
 
−
|sex
 
−
|Integer
 
−
|end tag
 
−
|Symbol
 
−
|}
 
−
Many of the same fields you found in rooms, as you can see from
 
−
(Link to npcfields), can also be found in NPCs. The fields do
 
−
not always have exactly the same use when coding rooms, NPCs, and
 
−
objects but they are normally set in the same manor.  It is very
 
−
important that you read and understand the differences of each field as
 
−
they pertains to rooms and or NPCs.
 
−
=== Description of NPC fields ===
 
  
 +
Most NPCs are not built field by field. The header <code>macros.h</code>, 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,
 +
[[Manual:Zone Manual/The NPC Section/NPC macros|NPC macros]]. This page
 +
describes every field, so that you know what the templates set and what you
 +
can change.
  
−
;symbolic name
+
A complete NPC built from a template:
−
: The rules of the symbols has been explained in (Link to ch-03), if you didn't read them yet you may want to review.
+
<pre>
−
The important thing to realize with the NPC symbol is it is always
+
hansen
−
good practice to give the NPC a symbol that resembles the title so
+
M_SHOP_KEEPER(20, SEX_MALE, RACE_HUMAN)
−
that administrators and builders can use the
+
title "Hansen"
−
'''load''' and the '''wstat''' to easily
+
descr "Hansen the postman is standing here, sorting the mail."
−
locate, examine, and load the NPC in question.
+
names {"hansen", "postman"}
−
;title
+
extra {}
−
: The NPC title is what is shown if the NPC is being attacked or talking.
+
"Hansen is a short, round man in a blue coat.  He hums while he sorts."
−
It is also what is shown if the NPC can be picked up. there should be
+
romflags {CHAR_DETECT_INVISIBLE}
−
no punctuation in the NPC title because of how it is used in the VME
+
end
−
server.  If you add punctuation or forget to capitalize something
+
</pre>
−
that the VMC thinks you should it will give you a warning when you
 
−
compile.
 
−
<nowiki>
 
−
title "a small dog"
 
−
title "Hansen"
 
−
title "a black dragon"
 
−
title "Drako"
 
−
title "an elephant"</nowiki>
 
−
; descr
 
−
*
 
  
−
The description field is what the player sees when walking into the room
+
=== The NPC fields ===
−
or when looking with no arguments. The description on a NPC will only
 
−
show up when the NPC is in the standing position.  All other positions
 
−
will show the title and the position they are in.
 
−
<nowiki>
 
−
descr
 
−
"a small fluffy dog is chasing its tail here."
 
−
descr
 
−
"Hansen is standing here sorting the mail."</nowiki>
 
−
;names
 
−
: The NPC name field is much more important then the room name field.  It is what is used when players are hunting and killing and even for administrators who are trying to use their administrator commands on a NPC.  The names should match the title and the descr fields and have all normal combinations of each.
 
−
<nowiki>
 
−
title "a baby black dragon"
 
−
descr "a tiny baby black dragon is here playing."
 
−
names {"tiny baby black dragon", "tiny black dragon",
 
−
"baby black dragon", "black dragon", "tiny dragon",
 
−
"baby dragon","dragon"}
 
  
−
title "Hansen"
+
The fields marked "unit" can be used on rooms and objects as well; the
−
descr "Hansen the post man is standing here sorting mail."
+
[[Manual:Zone Manual/Unit Building Blocks|Unit building blocks]] page explains
−
names{"postman","hansen"}</nowiki>
+
the general rules. The defaults are what <code>vmc</code> sets when a field is
−
The idea of course is to make any combination that a player may
+
left out.
−
type to try and act upon your NPC.  You would not want to describe and
 
−
title your NPC with an entirely different theme than you created its
 
−
names with because a player would not know what it is called.
 
−
;inside_descr
 
−
: The inside description is what a player sees if it is inside the NPC.  This could be used to show the player its stomach or if on a mount it could be used to show the back of the horse.
 
−
<nowiki>
 
−
inside_descr
 
−
"The lining of this stomach looks indestructible.  Looks like you are in
 
−
for a long digestion cycle."</nowiki>
 
−
;extra
 
−
: The extra's on the NPC can be used to do many things.  It can be used to store information for DIL programs or it can be used to show a part of the NPC like the room extras show a part of the room.  There is also a special extra, the NPCs description when you look at it with the look &lt;NPC&gt; command.
 
  
−
Lets show the NPC description extra first.  If you use an extra
 
−
with no names list it will become the NPCs description when you look at
 
−
any of the names on the NPC.
 
−
<nowiki>
 
−
extra {}
 
−
"The green furry hamster seems to be glowing and it doesn't seem very
 
−
happy."</nowiki>
 
−
You can also use extras to show parts of the NPC.
 
−
<nowiki>
 
−
extra {"hamster head","head"}
 
−
"This human like head is covered with a lot of green fur and it looks
 
−
really  upset."</nowiki>
 
−
You can also use the extras to give more detailed and vivid
 
−
descriptions when the NPC is acted upon.
 
 
{| class="wikitable"
 
{| class="wikitable"
−
|+NPC special action extras
+
|+NPC fields
 
|-
 
|-
−
!Extra
+
!Field
−
!Description
+
!Value
 +
!Default
 +
!Notes
 
|-
 
|-
−
|$get_s
+
|<code>names</code>
−
|A message shown to activator when getting a NPC.
+
|string list
 +
|none
 +
|unit; what players type to act on the NPC
 
|-
 
|-
−
|$get_o
+
|<code>title</code>
−
|A message shown to others when getting a NPC.
+
|string
 +
|none
 +
|unit; shown when the NPC acts or talks
 
|-
 
|-
−
|$drop_s
+
|<code>descr</code>
−
|a message shown to activator when dropping a NPC.
+
|string
 +
|none
 +
|unit; shown in the room when the NPC stands
 
|-
 
|-
−
|$drop_o
+
|<code>inside_descr</code>
−
|A message shown to others when dropping an NPC.
+
|string
 +
|none
 +
|unit; seen from inside the NPC
 
|-
 
|-
−
|$enter_s
+
|<code>extra</code>
−
|A message shown to activator When mounting
+
|names and a string
 +
|none
 +
|unit; the look description and other details
 
|-
 
|-
−
|$enter_o
+
|<code>level</code>
−
|A message shown to others when mounting.
+
|0..199
 +
|1
 +
|
 
|-
 
|-
−
|$exit_s
+
|<code>race</code>
−
|A message shown to others when dismounting
+
|<code>RACE_*</code>
 +
|<code>RACE_HUMAN</code>
 +
|
 
|-
 
|-
−
|$exit_o
+
|<code>sex</code>
−
|a message shown to others when dismounting
+
|<code>SEX_*</code>
−
|}
+
|<code>SEX_NEUTRAL</code>
−
In the following example, $1n is the activator and $2n is the
+
|
−
unit in question.  Assume you are defining a familiar.
 
−
<nowiki>
 
−
extra {"$get_s"}
 
−
"You pick up the $2n it is very warm and cuddles right up to you."
 
−
 
 
−
extra {"$get_o"}
 
−
"$1n picks up the $2n and you see them cuddle together."</nowiki>
 
−
Finally you can use extras to store information for DIL programs.
 
−
We will not cover this because it is a topic covered in-depth in
 
−
the DIL documentation.
 
−
;manipulate
 
−
: The manipulate filed only has two values for NPCs The two values are 'MANIPULATE_TAKE' and 'MANIPULATE_ENTER'.  The 'MANIPULATE_TAKE'
 
−
makes it possible for a NPC to be picked up this would be good for
 
−
something like a familiar.  The 'MANIPULATE_ENTER' is used for things
 
−
like mounts when making a mount you will also have to set the capacity
 
−
so a fat player can jump on.  The following is how you set the
 
−
manipulate flag.
 
−
<nowiki>
 
−
//Make a  NPC takable.
 
−
manipulate {MANIPULATE_TAKE}
 
−
 
 
−
//Make a NPC takable and able to be entered
 
−
manipulate {MANIPULATE_TAKE|MANIPULATE_ENTER}</nowiki>
 
−
;flags
 
−
: This field on a NPC is used to set special attributes in order to make the NPC able to be buried or not or no-teleportable and many others.  The NPC flag list uses the UNIT_FL_* variables that both the objects and the rooms also use, therefore while you can set some flags on an NPC it may not have any affect unless you as a builder or administrator adds the functionality.  You can also add extras on an NPC that can be used as a special flag which you will learn as you learn to use DIL.  The following is a full list of all unit flags and how they affect NPC, if they do.
 
−
{| class="wikitable"
 
−
|+NPC unit flag affects
 
 
|-
 
|-
−
!Flag
+
|<code>alignment</code>
−
!Description
+
|-1000..1000
 +
|0
 +
|unit
 
|-
 
|-
−
|UNIT_FL_PRIVATE
+
|<code>height</code>
−
|Currently has no affect on a NPC.
+
|centimetres
 +
|180
 +
|unit
 
|-
 
|-
−
|UNIT_FL_INVISIBLE
+
|<code>weight</code>
−
|Makes unit invisible
+
|pounds, up to 32767
 +
|120
 +
|unit
 
|-
 
|-
−
|UNIT_FL_NO_BURY
+
|<code>ability[ABIL_*]</code>
−
|Makes it so you can create NPC that can be taken like familiars or
+
|percentage
−
pets that can not be buried.  This flag is not needed on every NPC
+
|see [[#Abilities, weapon and spell skills|below]]
−
because the bury command will not allow you to bury an NPC outside of
+
|use <code>MSET_ABILITY</code>
−
your inventory.
 
 
|-
 
|-
−
|UNIT_FL_BURIED
+
|<code>weapon[WPN_*]</code>
−
|Makes unit buried when loaded
+
|percentage
 +
|unarmed 100
 +
|use <code>MSET_WEAPON</code>
 
|-
 
|-
−
|UNIT_FL_NO_TELEPORT
+
|<code>spell[SPL_*]</code>
−
|Makes it so you can not summon the NPC with this flag and the NPC with
+
|percentage
−
this flag can not teleport.  You can still teleport to NPC with this
+
|all 0
−
flag the current way teleport is written.  Remember all spells are in
+
|use <code>MSET_SPELL</code>
−
DIL and you can modify them in ''spells.zon''
 
 
|-
 
|-
−
|UNIT_FL_NO_MOB
+
|<code>attack</code>
−
|Currently has no affect on a NPC.
+
|<code>WPN_*</code>
 +
|<code>WPN_FIST</code>
 +
|natural attack; use <code>NATURAL_DEF</code>
 
|-
 
|-
−
|UNIT_FL_NO_WEATHER
+
|<code>armour</code>
−
|Currently has no affect on a NPC.
+
|<code>ARM_*</code>
 +
|<code>ARM_HLEATHER</code>
 +
|natural armour; use <code>NATURAL_DEF</code>
 
|-
 
|-
−
|UNIT_FL_INDOORS
+
|<code>offensive</code>
−
|Currently has no affect on NPC.
+
|-1000..1000
 +
|0
 +
|use <code>ATTACK_DEFENSE</code>
 
|-
 
|-
−
|UNIT_FL_TRANS
+
|<code>defensive</code>
−
|Makes unit transparent If the Unit is transparent you will be able
+
|-1000..1000
−
to see any other NPCs that it is carrying. For example if a NPC was
+
|0
−
carrying a familiar you would see that as you walked into the room. It
+
|use <code>ATTACK_DEFENSE</code>
−
also is used in mounts so the PC can see outside its mount.  If the
 
−
flag is not set on its mount the player will not see what is in the
 
−
room.
 
 
|-
 
|-
−
|UNIT_FL_NO_SAVE
+
|<code>speed</code>
−
|Makes it so a PC can't save with unit
+
|4..200
 +
|12
 +
|lower is faster
 
|-
 
|-
−
|UNIT_FL_SACRED
+
|<code>exp</code>
−
|Currently has no affect on a NPC.
+
|-500..499
 +
|100
 +
|experience share
 
|-
 
|-
−
|UNIT_FL_MAGIC
+
|<code>money</code>
−
|Currently has no affect on a NPC.
+
|count and coin, ...
−
|}
+
|none
−
If you wanted to make a NPC that a player can carry around but can
+
|
−
not save you would set the manipulate and flags as follows.
 
−
<nowiki>
 
−
manipulate {MANIPULATE_TAKE}
 
−
flags {UNIT_FL_NO_SAVE}</nowiki>
 
−
;romflags
 
−
: Like flags these are just integer values that are used to change how the NPC interacts with its environment.
 
−
{| class="wikitable"
 
−
|+Room flags for NPCs
 
 
|-
 
|-
−
!Flag
+
|<code>position</code>
−
!Description
+
|<code>POSITION_*</code>
 +
|<code>POSITION_STANDING</code>
 +
|
 
|-
 
|-
−
|CHAR_PROTECTED
+
|<code>default</code>
−
|Set this flag if the character is protected by the law-system.
+
|<code>POSITION_*</code>
 +
|<code>POSITION_STANDING</code>
 +
|
 
|-
 
|-
−
|CHAR_LEGAL_TARGET
+
|<code>romflags</code>
−
|This flag is used by the law system and should not be set unless you are re-writing your law system.
+
|<code>CHAR_*</code> flags
 +
|none
 +
|
 
|-
 
|-
−
|CHAR_OUTLAW
+
|<code>flags</code>
−
|This flag is used by the law system and should not be set unless you are re-writing your law system.
+
|<code>UNIT_FL_*</code> flags
 +
|none
 +
|unit
 
|-
 
|-
−
|CHAR_GROUP
+
|<code>npcflags</code>
−
|This is used by the follow and group commands and should not be set unless you are re-writing your, movement, status, and combat systems.
+
|<code>NPC_*</code> flags
 +
|none
 +
|
 
|-
 
|-
−
|CHAR_BLIND
+
|<code>manipulate</code>
−
|Set this if the character is blinded.
+
|<code>MANIPULATE_*</code> flags
 +
|none
 +
|unit
 
|-
 
|-
−
|CHAR_HIDE
+
|<code>capacity</code>
−
|Set flag if character is hidden.
+
|number
 +
|0
 +
|unit
 
|-
 
|-
−
|CHAR_MUTE
+
|<code>light</code>, <code>bright</code>
−
|Set flag if character is mute.
+
|-6..6
 +
|0
 +
|unit
 
|-
 
|-
−
|CHAR_SNEAK
+
|<code>minv</code>
−
|Set flag if character is in sneaking mode.
+
|level
 +
|0
 +
|unit
 
|-
 
|-
−
|CHAR_DETECT_ALIGN
+
|<code>dilcopy</code>, <code>dilbegin</code>
−
|No actual effect on NPCs.
+
|DIL
 +
|none
 +
|unit; behaviour
 
|-
 
|-
−
|CHAR_DETECT_INVISIBLE
+
|<code>special</code>, <code>affect</code>
−
|Set flag if character can see invisible units.
+
|
 +
|none
 +
|unit; rarely used on NPCs
 
|-
 
|-
−
|CHAR_DETECT_MAGIC
+
|<code>key</code>, <code>open</code>
−
|No actual effect on NPCs.
+
|
 +
|none
 +
|unit; for doors and containers
 
|-
 
|-
−
|CHAR_DETECT_POISON
+
|<code>hit</code>, <code>mana</code>
−
|No actual effect on NPCs.
+
|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
 +
(<code>load bldragon@dragonst</code>, <code>wstat bldragon@dragonst</code>),
 +
and <code>wstat zone dragonst mobiles</code> 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. <code>vmc</code> 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").
 +
<pre>
 +
title "a small dog"
 +
title "Hansen"
 +
title "an elephant"
 +
</pre>
 +
 
 +
'''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 <code>default</code> field doesn't
 +
change this.
 +
<pre>
 +
descr "Hansen the postman is standing here, sorting the mail."
 +
</pre>
 +
 
 +
'''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: <code>{"black dragon", "black"}</code>
 +
compiles, <code>{"black", "black dragon"}</code> is a "Name order error".
 +
<pre>
 +
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
 +
</pre>
 +
 
 +
'''inside_descr''' is what a player sees from inside the NPC: a stomach, or the
 +
back of a mount.
 +
<pre>
 +
inside_descr
 +
"The lining of this stomach looks indestructible.  You are in for a long
 +
digestion cycle."
 +
</pre>
 +
 
 +
'''extra''' gives the NPC its details. An extra with an empty names list,
 +
<code>extra {}</code>, is what players see when they look at the NPC. Extras
 +
with names describe parts of it.
 +
<pre>
 +
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."
 +
</pre>
 +
 
 +
Extras whose name starts with <code>$</code> 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 (<code>MANIPULATE_TAKE</code>), these replace the usual
 +
messages of <code>get</code> and <code>drop</code>; <code>$1n</code> is the
 +
player and <code>$2n</code> the NPC:
 +
 
 +
{| class="wikitable"
 
|-
 
|-
−
|CHAR_DETECT_UNDEAD
+
!Extra
−
|No actual effect on NPCs.
+
!Shown to
 
|-
 
|-
−
|CHAR_DETECT_CURSE
+
|<code>$get_s</code>
−
|No actual effect on NPCs.
+
|the player who picks the NPC up
 
|-
 
|-
−
|CHAR_DETECT_LIFE
+
|<code>$get_o</code>
−
|No actual effect on NPCs.
+
|the others in the room
 
|-
 
|-
−
|CHAR_WIMPY
+
|<code>$drop_s</code>
−
|Set flag if character if wimpy. Wimpy characters flee when they are
+
|the player who drops it
−
low on hit points, and they gain less experience when killing others.
 
−
If a character is both wimpy and aggressive (NPC_AGGRESSIVE) it will
 
−
only attack sleeping players.
 
 
|-
 
|-
−
|CHAR_SELF_DEFENCE
+
|<code>$drop_o</code>
−
|This is an internal combat flag set this only if you create your own combat system.
+
|the others in the room
 
|}
 
|}
−
These flags are set in the same way as other flags in rooms NPCs
+
<pre>
−
and objects.  The following are a few examples.
+
extra {"$get_s"}
−
<nowiki>
+
"You pick up $2n.  It is very warm and cuddles right up to you."
−
//wimpy and hidden
 
−
romflags {CHAR_HIDE, CHAR_WIMPY}
 
  
−
//NPC can see invisible
+
extra {"$get_o"}
−
romflags {CHAR_DETECT_INVISIBLE}</nowiki>
+
"$1n picks up $2n, and the two of them cuddle together."
−
: romflags adds to the flags the NPC already has, so the flags a macro sets stay: <code>M_SHOP_KEEPER(...)</code> followed by <code>romflags {CHAR_DETECT_INVISIBLE}</code> makes a protected, wimpy shopkeeper who also sees invisible. Several romflags lines add up. (Before November 2026 the last romflags replaced the earlier ones, a macro's too.)
+
</pre>
−
;weight
 
−
: The weight is the weight of the NPC in pounds.  In the future we may adjust this to allow you to make things lighter for example you could set it in ounces or grams.  Right now however all we have is pounds so we have some pretty heavy feathers out there.
 
  
−
To use this you just enter the 'weight' keyword and then the
+
=== Body: race, sex, height, weight ===
−
value.
 
−
<nowiki>
 
−
/80 lbs.
 
−
weight 80</nowiki>
 
−
<blockquote style="background-color: #E8E8E8; font-style: italic; ">The weight affects the NPCs natural attack damage.</blockquote>
 
−
;capacity
 
−
: This field along with the NPCs strength and dexterity decides how much a NPC can carry.  If you set the capacity to 300 lbs.  the NPC will only be able to carry that much depending if it has the strength and dexterity to carry that much.  This of course doesn't affect DIL programs that link the objects directly into the NPC.  To set the capacity you just put the keyword and the amount in your NPC.
 
−
<nowiki>
 
−
capacity  300</nowiki>
 
−
;height
 
−
: The height field is the size of the NPC in centimeters.  This determines the size of the equipment the NPC is wearing.  You will learn more about size and height in the object section but for now just understand this makes your NPC the right or wrong size.  To set the 'height' you just put the 'height' keyword followed by the number of centimeters.
 
−
<nowiki>
 
−
//6 feet tall since 1 inch equals 2.54
 
−
height 183</nowiki>
 
−
;dilbegin or dilcopy
 
−
: The DIL functions are what give VME servers the edge over all other muds.
 
−
We will only give some examples here and leave it up to the DIL manual to teach
 
−
you how to create your own functions that will make your rooms, NPC, and
 
−
objects more than special.
 
  
−
There are several NPC functions that come standard with the VME
+
'''race''' is one of the <code>RACE_*</code> constants in <code>values.h</code>
−
2.0. The following is a list of the functions.
+
(listed in [[Manual:Zone Manual/Appendices/Race Definitions in values.h|Race Definitions in values.h]]).
−
* Mercenary
+
Spells, skills and DIL programs use the race to treat creatures differently;
−
* obey
+
an aggressive guard can attack only orcs, for example. If no race fits, you can
−
* evaluate
+
add a constant to <code>values.h</code> (so that other zones can use it too) or
−
* guard direction
+
write the number directly, but a name is easier to read.
−
* shop keeper
+
<pre>
−
* combat magic
+
race RACE_MONKEY
−
* fido
+
race RACE_DRAGON_BLACK
−
* zone wander
+
</pre>
−
* global wander
 
−
* team work
 
−
* rescue
 
−
* agressive
 
−
These are the only NPC functions currently documented in the VME
 
−
2.0 release but if you go through the zones that are released with the
 
−
VME you are sure to find many more. Hopefully with the descriptions in
 
−
(Link to npcdilfunc). You will be able to use the functions
 
−
listed here and figure out ones that are not.
 
  
−
Since these are just DIL's written by builders for the
+
'''sex''' is <code>SEX_NEUTRAL</code> (the default), <code>SEX_MALE</code> or
−
Valhalla mud all you have to do is use the dilcopy keyword in the
+
<code>SEX_FEMALE</code>. Make the descriptions match: a female dragon shouldn't
−
NPC with the function name you want to use and the arguments that
+
be "he" in its extras.
−
function require.  The following is what you would find in the
+
<pre>
−
''function.zon'' for evaluate.
+
sex SEX_MALE
−
<nowiki>
+
</pre>
−
/* Evaluate DIL. amt is the cost of evaluation in iron pieces.
 
−
  Note: not to be confused with '''evaluate@commands''', which
 
−
  is a command.
 
−
*/
 
−
dilbegin aware evaluate (amt: integer);
 
  
−
var u1 : unitptr;
+
'''height''' is in centimetres (default 180). Equipment an NPC gets from an
−
    arg: string;
+
<code>equip</code> reset is resized to fit it.
−
    buf: string;
+
'''weight''' is in pounds (default 120, at most 32767). A character's weight and
−
    cur: integer;
+
strength decide how much it can carry, and the weight how hard its natural
−
    craft: integer;
+
attack hits (see [[Manual:Zone Manual/The NPC Section/NPC macros|NPC macros]]).
−
    category: integer;
+
<pre>
 +
height 183    // 6 feet; 1 inch is 2.54 cm
 +
weight 80
 +
</pre>
  
−
    pc : unitptr;
+
=== Level, alignment, experience and money ===
−
    pcn: string;
 
  
−
    arm_text  : stringlist;
+
'''level''' is 0..199 (default 1); anything else is a fatal error. The level
−
    shi_text  : stringlist;
+
decides how many ability and skill points the NPC gets (see below), and with
−
    craft_text: stringlist;
+
<code>exp</code> how much experience it gives.
−
code
+
<pre>
−
{
+
level 50
 +
</pre>
  
−
craft_text:=  {"horrible","very bad","bad","worse than average","average",
+
'''alignment''' is -1000 (utterly evil) to +1000 (utterly good). The game counts
−
  "a little better than average","better than average","good","very good",
+
350 and above as good, -350 and below as evil, and the rest as neutral. A value
−
  "supreme"};
+
outside -1000..1000 is kept within it, with a warning.
−
arm_text:= {"clothes", "leather", "hard leather", "chain", "plate"};
+
<pre>
−
shi_text:= {"small", "medium", "large"};
+
alignment -750  // quite evil, maybe a ghoul
 +
alignment 350    // just good
 +
</pre>
  
−
heartbeat:= PULSE_SEC*3;
+
'''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
 +
<code>exp -400</code> to protect shopkeepers.
 +
<pre>
 +
exp 150  // half as much again as normal
 +
exp -50  // killing it costs experience
 +
</pre>
  
−
:start:
+
'''money''' is the money the NPC carries, as a count and a coin, separated by
−
arg:= "";
+
commas. The coins are <code>IRON_PIECE</code>, <code>COPPER_PIECE</code>,
−
u1:= null;
+
<code>SILVER_PIECE</code>, <code>GOLD_PIECE</code> and
 +
<code>PLATINUM_PIECE</code>. <code>money 25600</code> and
 +
<code>money 5*GOLD_PIECE</code> (from older manuals) are syntax errors.
 +
<pre>
 +
money 3 SILVER_PIECE, 20 IRON_PIECE
 +
</pre>
 +
Each coin is worth eight of the one below it (8 iron pieces make a copper
 +
piece, and so on). <code>vmc</code> 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.
  
−
wait (SFB_CMD, command("evaluate"));
+
=== Abilities, weapon and spell skills ===
  
−
if (visible(pc, self) == FALSE)
+
An NPC's abilities (strength, dexterity, constitution, hit points, brain,
−
    goto start; // Pc is just trying to evaluate using the command
+
charisma, magic and divine power) and its weapon and spell skills aren't given
 +
as numbers. You give percentages, and <code>vmc</code> 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.
  
−
block;
+
Don't set <code>ability[...]</code>, <code>weapon[...]</code> and
 +
<code>spell[...]</code> 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 <code>MSET_ABILITY</code>,
 +
<code>MSET_WEAPON</code> and <code>MSET_SPELL</code>, which set the whole group;
 +
they are described on [[Manual:Zone Manual/The NPC Section/NPC macros|NPC macros]].
  
−
pc:= activator;
+
The NPC's hit points come from its HP ability (10 + 3 × HP points). The
−
if (pc.type == UNIT_ST_PC) pcn := pc.name;
+
<code>hit</code> and <code>mana</code> fields are accepted but have no effect on
−
else pcn := pc.title;
+
an NPC.
  
−
arg:= argument;
+
=== Combat: natural attack and armour, bonuses, speed ===
  
−
if (visible(self, pc) == FALSE)
+
'''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
−
    exec ("say I don't do business with people I can't see.", self);
+
claws and is as hard as plate. Set both with <code>NATURAL_DEF</code>.
−
    goto start;
 
−
    }
 
  
−
if (arg == "")
+
'''offensive''' and '''defensive''' are bonuses (-1000..1000, default 0) added to
−
    {
+
the NPC's attack and defence rolls. Set both with <code>ATTACK_DEFENSE</code>.
−
    exec ("say Which item do you wish to evaluate, "+pcn+"?", self);
 
−
    goto start;
 
−
    }
 
  
−
u1:= findunit (pc, arg, FIND_UNIT_IN_ME, null);
+
'''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. <code>vme.h</code> has
 +
names for the fast speeds: <code>SPEED_150</code> (8), <code>SPEED_200</code>
 +
(6), <code>SPEED_240</code> (5) and <code>SPEED_300</code> (4). 0 is a fatal
 +
error.
 +
<pre>
 +
speed SPEED_150
 +
</pre>
  
−
if (not u1)
+
=== Position ===
−
    {
 
−
    exec ("say You do not have such an item, "+pcn+".", self);
 
−
    goto start;
 
−
    }
 
  
−
if ((u1.type != UNIT_ST_OBJ) or ( (u1.objecttype != ITEM_WEAPON) and
+
'''position''' is the position the NPC is loaded in:
−
    (u1.objecttype != ITEM_ARMOR) and (u1.objecttype != ITEM_SHIELD) ))
+
<pre>
−
    {
+
POSITION_DEAD
−
    exec ("say The "+u1.name+" is neither a sword, shield nor armor!", self);
+
POSITION_MORTALLYW
−
    goto start;
+
POSITION_INCAP
−
    }
+
POSITION_STUNNED
 +
POSITION_SLEEPING
 +
POSITION_RESTING
 +
POSITION_SITTING
 +
POSITION_FIGHTING
 +
POSITION_STANDING
 +
</pre>
 +
Only <code>POSITION_SLEEPING</code>, <code>POSITION_RESTING</code>,
 +
<code>POSITION_SITTING</code> and <code>POSITION_STANDING</code> (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 <code>descr</code>.
 +
<pre>
 +
position POSITION_SITTING
 +
</pre>
  
−
// Currency, skip for now
+
'''default''' is the NPC's default position (default
 +
<code>POSITION_STANDING</code>). The game itself doesn't use it; it is shown by
 +
<code>wstat</code>, and DIL programs can read and change it as
 +
[[Manual:DIL Manual/defaultpos|defaultpos]].
  
−
if (not transfermoney (pc, null, amt * IRON_MULT))
+
=== Flags ===
−
    {
 
−
    exec ("say The cost is merely "+moneystring(amt*IRON_MULT, TRUE)+
 
−
        ", get them first.", self);
 
−
    goto start;
 
−
    }
 
  
−
category:= u1.value[0];
+
An NPC has three sets of flags, each with its own field. <code>vmc</code> sees
−
craft:= u1.value[1] / 5 + 4; // / 5 + 4 is to get corresponding craft_text val
+
only numbers, so a flag under the wrong field compiles without a word and sets
 +
a different flag: <code>flags {CHAR_SNEAK}</code> sets
 +
<code>UNIT_FL_NO_WEATHER</code>. Several values go in braces, separated by
 +
commas, and every <code>flags</code>, <code>romflags</code> and
 +
<code>manipulate</code> line adds to the flags already set, so a template's
 +
flags stay.
  
−
if (craft < 0) craft := 0;  if (craft > 9) craft := 9;
+
'''romflags''' takes the character flags, <code>CHAR_*</code>
 +
(<code>vme.h</code>). The ones worth setting on an NPC:
  
−
// Change the following to use skill_text(craft) instead of itoa(craft)
+
{| class="wikitable"
−
if (u1.objecttype == ITEM_WEAPON)
+
|-
−
    buf := "say The "+u1.name+" is a "+weapon_name(category)+" of "+
+
!Flag
−
        craft_text.[craft]+" craftmanship and material.";
+
!Effect
 +
|-
 +
|<code>CHAR_PROTECTED</code>
 +
|Protected by the law system: killing it is a crime, and it reports crimes it
 +
sees. The shopkeeper template sets it.
 +
|-
 +
|<code>CHAR_HIDE</code>
 +
|Hidden: not shown in the room. Being attacked ends it.
 +
|-
 +
|<code>CHAR_SNEAK</code>
 +
|Moves without leave and arrive messages.
 +
|-
 +
|<code>CHAR_DETECT_INVISIBLE</code>
 +
|Sees invisible characters and things.
 +
|-
 +
|<code>CHAR_WIMPY</code>
 +
|Flees when a blow takes more than a quarter of its hit points, or when it has
 +
less than a quarter left.
 +
|-
 +
|<code>CHAR_BLIND</code>
 +
|Can't see.
 +
|-
 +
|<code>CHAR_MUTE</code>
 +
|Can't use the speech commands.
 +
|}
 +
The other <code>CHAR_*</code> flags are set by the game itself (the law system,
 +
groups, combat, spells, player settings); don't put them in a zone.
 +
<pre>
 +
romflags {CHAR_HIDE, CHAR_WIMPY}
 +
</pre>
 +
A <code>romflags</code> line after a template adds to the template's flags:
 +
<code>M_SHOP_KEEPER(...)</code> followed by
 +
<code>romflags {CHAR_DETECT_INVISIBLE}</code> makes a protected, wimpy
 +
shopkeeper who also sees invisible. (Before November 2026 the last
 +
<code>romflags</code> replaced the earlier ones, a macro's too.)
  
−
if (u1.objecttype == ITEM_ARMOR)
+
'''flags''' takes the unit flags, <code>UNIT_FL_*</code> (<code>vme.h</code>),
−
    buf := "say The "+u1.name+" is made of "+arm_text.[category]+" and is of "+
+
which rooms and objects use too. On an NPC these matter:
−
        craft_text.[craft]+" craftmanship and material.";
 
  
−
if (u1.objecttype == ITEM_SHIELD)
+
{| class="wikitable"
−
    buf := "say The "+u1.name+" is a "+shi_text.[category]+" shield of "+
+
|-
−
        craft_text.[craft]+" craftmanship and material.";
+
!Flag
−
 
+
!Effect
−
exec (buf, self);
+
|-
−
 
+
|<code>UNIT_FL_INVISIBLE</code>
−
goto start;
+
|Invisible to those who can't detect invisible.
−
 
+
|-
−
}
+
|<code>UNIT_FL_NO_TELEPORT</code>
−
 
+
|Teleport spells can't take it away, and it can't teleport itself.
−
dilend</nowiki>
+
|-
−
If this DIL function scares you don't worry you don't have to
+
|<code>UNIT_FL_TRANS</code>
−
understand it or adjust it you only have to use it. In fact this is a
+
|Transparent: the room shows what it carries, and a rider sees out of it.
−
really easy DIL to use.  It only has one argument which is 'amt', the integer value of money you want the evaluator to charge when a
+
Needed for a mount (see <code>manipulate</code>).
−
person evaluates their stuff. So to use this function it would look
+
|-
−
like this on an NPC.
+
|<code>UNIT_FL_NOSAVE</code>
−
<nowiki>
+
|A player carrying it can't save it (for a pet that can be picked up).
−
dilcopy evaluate@function (5*GOLD_PIECE);</nowiki>
+
|-
−
this tells the evaluate DIL to charge 5 gold pieces each time a player
+
|<code>UNIT_FL_BURIED</code>
−
evaluates something. For more information on the money see the money
+
|Buried: nobody can see it.
−
field.
+
|}
  
−
All released DIL NPC functions are described in
+
'''npcflags''' takes the <code>NPC_*</code> flags. The only one defined is
−
(Link to npcdilfunc).
+
<code>NPC_NICE_THIEF</code>, and nothing in the current code reads it.
−
Then we put some to work so you can see how
 
−
to use them in (Link to npccomplex)
 
−
;defensive
 
−
: This field sets the NPC natural defense. The defense is a natural bonus the NPC gets when being attacked.  If this value is set high enough the NPC becomes almost indestructible.  You should use the macro to set the NPC natural attack and defense in (Link to npcmacroattdef).
 
−
;offensive
 
−
: This field sets the NPC natural offense.  The offense is a natural bonus the NPC gets when being attacked.  If this value is set high enough the NPC can do some serious damage when attacking.  You should use the macro to set the NPC natural attack and defense in (Link to npcmacroattdef).
 
−
;mana
 
−
: This sets the NPC max mana points.  Using this field you can create special NPCs that have more or less mana points than the VME server would normally give when a NPC is loaded.
 
  
−
this field is simple all you have to do to set it is put the 'mana'
+
'''manipulate''' takes <code>MANIPULATE_*</code> flags. On an NPC two are
−
keyword followed by the amount of mana points you want the NPC to have as
+
useful: <code>MANIPULATE_TAKE</code> lets players pick it up (a familiar, a
−
its max. The following definition would make an NPC with only 100 mana
+
pet), and <code>MANIPULATE_ENTER</code> is part of a mount.
−
points no matter what level.
+
<pre>
−
<nowiki>
+
// a pet that can be carried but not saved
−
mana 100</nowiki>
+
manipulate {MANIPULATE_TAKE}
−
;hit
+
flags {UNIT_FL_NOSAVE}
−
: This sets the NPC max hit points. Using this field you can create special NPCs that have more or less hit points than the VME server would normally give when a NPC is loaded.
+
</pre>
 +
A mount needs <code>UNIT_FL_TRANS</code>, <code>MANIPULATE_ENTER</code> and an
 +
extra named <code>$trained</code>: <code>mount</code> accepts either flag, but
 +
<code>dismount</code> lets the rider off only when all three are there. The
 +
mount must also be strong enough to carry its rider.
 +
<pre>
 +
flags {UNIT_FL_TRANS}
 +
manipulate {MANIPULATE_ENTER}
 +
extra {"$trained"} ""
 +
</pre>
  
−
this field is simple all you have to do to set it is put the 'hit'
+
=== Behaviour: DIL ===
−
keyword followed by the amount of hit points you want the NPC to have as
 
−
its max.  The following definition would make an NPC with only 100 hit
 
−
points no matter what level.
 
−
<nowiki>
 
−
hit 100</nowiki>
 
−
;money
 
−
: The money field is how you give your NPC money to have while going along its marry way through your world.  The money field is an integer that tells the VME how much money the NPC is carrying.  It would however be hard to calculate the amount you want on an NPC with out the macros we have provided.  For example to put 5 gold on an NPC you would have to use the following on your NPC.
 
−
<nowiki>
 
−
money 25600</nowiki>
 
−
I of course am not sure this will make 5 gold pieces since I did
 
−
the math in my head and with all this righting I am doing my math mind
 
−
doesn't seem to be working right.  So to make life easier for you and me
 
−
we have added some macros to help that are rather self
 
−
explanatory.
 
−
<nowiki>
 
−
IRON_PIECE
 
−
COPPER_PIECE
 
−
SILVER_PIECE
 
−
GOLD_PIECE
 
−
PLATINUM_PIECE</nowiki>
 
−
Now if we wanted to make a NPC carrying five gold it would be as
 
−
simple as this:
 
−
<nowiki>
 
−
money 5*GOLD_PIECE</nowiki>
 
−
the macro method also gains you the ability to tell the VME what
 
−
amount of each coin you want on the NPC.  If you set it using a single
 
−
integer the compiler would pick how many of each coin.  This of course
 
−
is not what is desired in fact you want to be able to set your money
 
−
however you like.  So setting more than one coin is as simple as adding
 
−
a comma between the first and second coin.
 
−
<nowiki>
 
−
money 5*GOLD_PIECE, 20*IRON_PIECE</nowiki>
 
−
;exp
 
−
: By default a monster gives 100% of the experience it is worth.
 
−
This amount is calculated according to the level of the NPC verses the
 
−
level of the person fighting it.  Sometimes the amount of experience is
 
−
not right since the NPC is really hard to kill for example a dragon with
 
−
breath weapon and heal at the same level as a merchant with a dagger.
 
−
These should of course give different experience.  The 'exp' field is
 
−
designed to do just that.  The possible range for the 'exp' field is
 
−
-500% to 500%.  If you put the NPC at a negative experience value it
 
−
will take experience away when it is killed.  If you want the default of
 
−
100% you do not even need to place this field in your NPC.
 
−
<nowiki>
 
−
//add 50% to the experience gained
 
−
exp 150
 
  
−
/subtract 150% from the experience gained
+
On its own an NPC stands and fights back when attacked. Everything else
−
exp -50</nowiki>
+
(attacking players, wandering, guarding a door, selling, casting spells in a
−
;sex
+
fight) is done by DIL programs. You seldom write these yourself: the zone
−
: Gender, one of these:
+
<code>function.zon</code> holds ready-made ones that you copy onto the NPC with
−
<nowiki>
+
<code>dilcopy</code>, giving the arguments the program needs:
−
SEX_NEUTRAL
+
<pre>
−
SEX_MALE
+
dilcopy evaluate@function(64);
−
SEX_FEMALE</nowiki>
+
</pre>
−
the values are pretty obvious which is which gender so all we will
+
This NPC evaluates weapons and armour for players, for 64 iron pieces each. The
−
show here is how to set it.
+
<code>;</code> at the end is required. <code>vmc</code> checks neither the
−
<nowiki>
+
program's name nor its arguments; a mistake shows up when the server boots or
−
//Setting a male NPC
+
when the program runs.
−
sex SEX_MALE</nowiki>
 
−
;level
 
−
: When  creating a NPC it must be between level 0 and  199.  The level  of  the NPC decides how many skill points  and  ability points the NPC has.  It, along with the 'exp' percentage, determines the amount of experience gained when the NPC is killed. To set the level of the NPC you use the 'level' keyword and then follow it by the level you are setting.
 
−
<nowiki>
 
−
//set a NPC to level 50
 
−
level 50</nowiki>
 
−
;race
 
−
: The 'race' keyword is what you use to set the characters race.
 
−
Races in VME are defined by using an integer that lets the spells and
 
−
skills act differently for each specific type. The VME comes standard
 
−
with many races defined in the ''values.h''.  For
 
−
ease in access we have provided them in (Link to app-c).  For now
 
−
you can look at the short list below taken from the over all
 
−
race list.
 
−
<nowiki>
 
−
#define RACE_RAT            1102
 
−
#define RACE_HORSE          1103
 
−
#define RACE_BADGER        1104
 
−
#define RACE_SKUNK          1105
 
−
#define RACE_BOAR          1106
 
−
#define RACE_MOUSE          1107
 
−
#define RACE_MONKEY        1108
 
−
#define RACE_PORCUPINE      1110
 
−
#define RACE_ELEPHANT      1112
 
−
#define RACE_CAMEL          1113
 
−
#define RACE_FERRET        1114</nowiki>
 
−
If for example you wanted to make a monkey you could simply put
 
−
the 'race' keyword and follow it by the monkey define like this:
 
−
<nowiki>
 
−
race RACE_MONKEY</nowiki>
 
−
If the race your looking for doesn't exist in the
 
−
''values.h'' list, you can either add one buy picking a
 
−
number not already used and creating your own define in the
 
−
''values.h'' or by adding the define to your zone.
 
−
Defines added to a single zone will not be accessible if another builder
 
−
wants to use it.  You could also just set it using a number.  The
 
−
following two methods would act the same.
 
−
<nowiki>
 
−
//add define to values.h and use in your zone
 
−
#define RACE_SPACE_TROLL  5059
 
−
race RACE_SPACE_TROLL
 
  
−
//Just plug in a number
+
The programs for NPCs (aggression, combat magic, wandering, guards, shopkeepers,
−
race 5059</nowiki>
+
team work, rescue and more) and their arguments are described in
−
If you don't use the macros things can get confusing really fast with
+
[[Manual:Zone Manual/The NPC Section/DIL functions for NPCs|DIL functions for NPCs]],
−
the amount of races there are.
+
and put to work in [[Manual:Zone Manual/The NPC Section/A more complex set of NPCs|A more complex set of NPCs]].
−
;attack
+
A program written inside the NPC itself, between <code>dilbegin</code> and
−
: This field sets the NPCs natural attack type.  Do not use this field directly instead use the macro described in (Link to npcmacroattarm)
+
<code>dilend</code>, is the subject of the
−
;armour
+
[[Manual:DIL Manual|DIL manual]] (see [[Manual:DIL Manual/dilcopy()|dilcopy]]
−
: This field sets the NPCs natural armour type.  Do not use this field directly instead use the macro described in (Link to npcmacroattarm)
+
and [[Manual:DIL Manual/dilbegin|dilbegin]]).
−
;speed
 
−
: Speed determines the NPCs speed.  The range is one to twelve.  You should not set this when compiling an NPC since the result is really undefined.  If you have a special NPC that you want to try to make move faster and hit faster then you could try setting this.  This field is mainly added so DIL can adjust speed.  The lower the number the faster the NPC speed.
 
−
<nowiki>
 
−
//fastest speed.
 
−
speed 0
 
  
−
//slowest speed
+
A few built-in functions are still attached with <code>special</code> instead of
−
speed 12</nowiki>
+
DIL, for example teachers (<code>special SFUN_TEACH_INIT</code>). The old
−
;position
+
specials such as <code>SFUN_AGGRESSIVE</code> and
−
: This field sets the position that the NPC will be in when it is first loaded. The following positions are recognized by the compiler.
+
<code>SFUN_COMBAT_MAGIC</code> are gone; use the DIL functions.
−
<nowiki>
 
−
POSITION_DEAD
 
−
POSITION_MORTALLYW
 
−
POSITION_INCAP
 
−
POSITION_STUNNED
 
−
POSITION_SLEEPING
 
−
POSITION_RESTING
 
−
POSITION_SITTING
 
−
POSITION_FIGHTING
 
−
POSITION_STANDING</nowiki>
 
−
Some of these positions make no sense you would not load a
 
−
  NPC into a fight or you would not load an NPC that is already dead.
 
−
  The positions are availible for DIL and you will need to read the DIL
 
−
  manuals to find out what you would want those for.  For now the
 
−
  following are enough.
 
−
<nowiki>
 
−
  POSITION_SLEEPING
 
−
POSITION_RESTING
 
−
POSITION_SITTING
 
−
POSITION_STANDING</nowiki>
 
−
The position combined with the default position determines what
 
−
will be shown when a player looks in the room. If the position of the
 
−
NPC matches its default position the NPC description will be shown.  If
 
−
it doesn't match the NPCs title and position will be shown.  The
 
−
default value for both 'position' and 'default' is 'POSITION_STANDING'
 
  
−
To set the position like with other fields you type the 'position'
+
=== Other fields ===
−
keyword first and follow it by the position you are setting.
 
−
<nowiki>
 
−
position POSITION_SITTING</nowiki>
 
−
;default
 
−
: The default position along with the position determines what is shown when a NPC is in each position.  If the position and default positions match the 'descr' field is shown.  If they do not match the NPC title is shown along with the current position information.  If
 
−
'default' is not set it defaults to 'POSITION_STANDING'.  The following
 
−
are possible default positions.
 
−
<nowiki>
 
−
    POSITION_DEAD
 
−
POSITION_MORTALLYW
 
−
POSITION_INCAP
 
−
POSITION_STUNNED
 
−
POSITION_SLEEPING
 
−
POSITION_RESTING
 
−
POSITION_SITTING
 
−
POSITION_FIGHTING
 
−
POSITION_STANDING</nowiki>
 
−
Setting the default field is exactly like setting the 'position'
 
−
field you place the 'default' keyword first and then the position you
 
−
want to be default like this:
 
−
<nowiki>
 
−
default POSITION_RESTING</nowiki>
 
−
;ability
 
−
: this field is used to set each of the NPCs abilities.
 
−
It should not be used directly but instead set through the macro described
 
−
in (Link to npcmacroability)
 
−
;weapon
 
−
: this field is used to set each of the NPCs weapon proficiencies.
 
−
It should not be used directly but instead set through the macro described
 
−
in (Link to npcmacroweapspl)
 
−
;spell
 
−
: this field is used to set each of the NPCs spells.
 
−
It should not be used directly but instead set through the macro described
 
−
in (Link to npcmacroweapspl)
 
−
;light
 
−
: The light field on NPC is not normally set.  If however you have a strange creature like a 'light bug' you can set a light value on a NPC.
 
−
The default light is set to 0 which means it neither adds or subtracts
 
−
from the rooms light.  To set the light value on a NPC you just put the
 
−
'light' keyword first and then the value you want to add to the current
 
−
light.
 
−
<nowiki>
 
−
//add one to light in room
 
−
light 1
 
  
−
//default
+
'''light''' and '''bright''' (-6..6, default 0). <code>bright</code> is the
−
light 0
+
light the NPC gives off: <code>bright 1</code> lights up the room it is in, a
 +
negative value darkens it, and looking at it says "Light comes from ...".
 +
<code>light</code> is the light inside the NPC, for whoever is in it.
 +
<pre>
 +
bright 1  // a glowing creature
 +
</pre>
  
−
//take one away
+
'''minv''' hides the NPC from every character below that level:
−
light -1</nowiki>
+
<code>minv 239</code> lets only characters of level 239 and up see it, until an
−
;alignment
+
administrator or a DIL program lowers it.
−
: This field  is  a  value between -1000 and +1000,  where  -1000  is ultimate  evil, 0 is neutral and +1000 is ultimate good.  Good  is per  definition any value from +1000..+350, neutral is  any  value from  +349..-349 and evil is any value from -350..-1000. Any value in between can also be used.
 
−
<nowiki>
 
−
// Quite evil, maybe a Ghoul
 
−
alignment -750
 
  
−
// Barely evil.
+
'''capacity''' is how much fits inside the unit. A character's own carrying limit
−
alignment -350
+
comes from its strength, dexterity and weight, not from
 +
<code>capacity</code>.
  
−
//barely good
+
'''key''' and '''open''' are meant for doors and containers (see the objects
−
alignment 350</nowiki>
+
section) and are not normally used on NPCs.
−
;minv
 
−
: This field is the administrator invisible level of the NPC it is set on.  This means that if you set the 'minv' to two hundred it will make it so the NPC can not be seen by anyone below the administrator level of two hundred.  This is good for hiding ghosts that only come visible when they attack.  In order for the 'minv' to be removed an administrator or a DIL function must change it.
 
−
<nowiki>
 
−
minv 239</nowiki>
 
−
;key
 
−
: Currently this field is not used in the VME 2.0 release.  It was added so in the future you wanted to add keys to a NPC for some weird reason like a living trunk then you can.  In order to set the key you first place the 'key' keyword and then add the symbolic name of the key.
 
−
<nowiki>
 
−
//if the key is in your zone
 
−
key mynpckey
 
  
−
//if the key is in some other zone
+
'''affect''' gives a unit an effect it starts with; the transfer macros in
−
key someoneelses@keyzone</nowiki>
+
<code>wmacros.h</code> write it for objects. It is rarely used on NPCs.
−
;open
 
−
: this field is not used yet in the VME 2.0 release.  The field was added so you could make a NPC that can be opened, closed, locked,
 
−
and everything else that a room or an object can have set on it.  For
 
−
now we will not document this but if you are interested in how you could
 
−
use it study the open fields on objects or rooms.
 
  
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Room_Section/Suggested_room_exercises|Previous: Suggested room exercises]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_Room_Section/Suggested_room_exercises|Previous: Suggested room exercises]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_NPC_Section/NPC_macros|Next: NPC macros]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_NPC_Section/NPC_macros|Next: NPC macros]]</div>

Latest revision as of 06:20, 15 November 2026

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.

NPC fields
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 manipulate).

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.

Previous: Suggested room exercises
Next: NPC macros