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

From DikuMUD Wiki
Jump to navigation Jump to search
(checked against the current code (wiki review 2026-11-15))
 
Line 1: Line 1:
 
=== Building your first NPC ===
 
=== Building your first NPC ===
  
−
Now that you have built your first zone with rooms its time to
+
Now that you have built your first zone with rooms, it is time to populate it
−
populate it with Non playing characters for your players to hunt, kill,
+
with characters for your players to hunt, kill or talk to. The last two pages
−
and or interact with. In the last couple of sections you have looked
+
described the fields and the macros; on this page we build one NPC with them.
−
through the fields.  In this section we are going to make a nice easy
+
I like dragons, as you saw in the room section, so the first NPC is a big, bad,
−
NPC and then show how to use the ''composed.h'' to make
+
ugly black dragon. If you don't like dragons, you will still learn enough from
−
your NPC building easier.  As I have previously stated in the section on
+
it to build whatever you want.
−
room building I like dragons so the first NPC your going to learn to
 
−
build is a big bad ugly dragon. Don't worry if you hate dragons or you
 
−
just want to build a normal world you will learn plenty from my dragon
 
−
example to be able to adjust it to whatever you want.
 
  
−
When making NPCs you create the zone source file first as shown
+
NPCs go in the <code>%mobiles</code> section of the zone file. We add that
−
in (Link to ch-02).  If you only have NPCS you do not need the
+
section to the dragon station zone, <code>dragonst</code>, from the room
−
%reset, %objects, and %rooms fields.  For the examples in this chapter we
+
section; a zone needs only the sections it uses, so a zone of nothing but NPCs
−
will use the zone we created in (Link to ch-04) and add the
+
is fine too. In
−
%mobiles section where we will put all the NPC definitions. At the end
+
[[Manual:Zone Manual/The NPC Section/Dragon station with rooms and NPCs|Dragon station with rooms and NPCs]]
−
of this chapter, in (Link to roomnpczone), we will bring it all together with the rooms we have
+
the rooms and the NPCs come together.
−
already defined and our NPCs.
 
  
−
The first part of all NPC definitions is the symbolic name it is good
+
==== The symbol ====
−
to always pick a name that will match the name of the NPC so it
 
−
will be easy to load the NPC.
 
−
The reason the symbolic and name should match is when you use the
 
−
command '''wstat''' it will only show you a
 
−
list of the NPCs by symbolic name for example if you type '''
 
−
wstat zone dragon mobiles ''' You will get the following:
 
−
<nowiki>
 
−
List of mobiles in zone Dragon:
 
−
dragon clerk trashman</nowiki>
 
−
If you didn't make it clear what the NPC was by the symbolic name
 
−
it might look like this:
 
−
<nowiki>
 
−
List of mobiles in zone Dragon:
 
−
npc1 npc2 npc3</nowiki>
 
−
While this might be great when you first start imagine trying to
 
−
remember each NPC if you have over 30 of them.
 
  
−
Now lets get started with our dragon. As with the rooms all that is required to make a NPC is the symbolic and end fields.  That of course will make a NPC with all defaults.
+
Every NPC starts with its symbol. Pick one that matches the NPC, so that it is
−
<nowiki>
+
easy to find: <code>wstat zone dragonst mobiles</code> lists the zone's NPCs by
−
bldragon
+
symbol only, and <code>load bldragon@dragonst</code> needs the symbol. A list
−
end</nowiki>
+
like <code>dragon clerk trashman</code> tells you what is there; a list like
−
Thats it for that dragon right?  Nope not quite that makes a NPC
+
<code>npc1 npc2 npc3</code> doesn't, and once you have thirty NPCs you will not
−
with all defaults.  That means this will probably be a very wimpy human
+
remember which is which.
−
with a symbolic name of dragon and no description, in short it will be a
 
−
blank when you load it.  Now lets start putting the Dragon
 
−
together.
 
  
−
The first three things we need are the dragons title, description
+
All that an NPC needs is its symbol and <code>end</code>:
−
and names.  The description should be what you see when you do a 'look'
+
<pre>
−
in the room.  The title should be what you see when the NPC is talking
+
bldragon
−
or fighting.  Finally the names should cover everything in the title and
+
end
−
description fields so if you wanted to kill them you can easily
+
</pre>
−
know what to type.
+
That compiles, but every field has its default: a level 1 human of neutral sex
−
<nowiki>
+
with no names, title or description. Let's turn it into a dragon.
−
bldragon
 
  
−
title "a black dragon"
+
==== Title, description and names ====
−
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"}
 
−
...
 
−
end</nowiki>
 
−
The names, title and description shouldn't be to hard so I don't
 
−
think its necessary to go into any more description on the subject.
 
−
Lets move on.  Now we have to take care of what a player sees when he or
 
−
she looks at a NPC.  to make the main description of an NPC you place an
 
−
extra on the NPC with no names in the list.  The blank extra is a
 
−
special extra that will be shown every time you look at anything in the
 
−
names list of the NPC.  So a description of a NPC would look something
 
−
like this.
 
−
<nowiki>
 
−
extra {}
 
−
"The black dragons scales glitter like black granite that has been
 
−
polished for years by water.  He has a large neck and huge bat like
 
−
wings.  his eyes watch you as you stand before him.  One claw seems to be
 
−
tapping slightly on the ground as if the dragon is waiting for
 
−
something."</nowiki>
 
−
Now that you have a main description for the NPC you need to make
 
−
any smaller descriptions that you want the player to be able to look at.
 
−
In this case the dragon eyes and claw would be good things to describe
 
−
and maybe a few other things just for humor.
 
−
<nowiki>
 
−
extra {"eyes","eye"}
 
−
"The dragons eyes seem to follow you no matter where you go in the room
 
−
nothing seems to escape the dragons attention."
 
  
−
extra {"claws","claw"}
+
The title is what the game shows when the dragon does something ("a black
−
"The claw is big black and it looks very deadly. It seems like the
+
dragon claws you"). The description is the line players see in the room while
−
dragon has two sets of 4 large claws and 2 sets of 4 smaller claws which
+
it stands. The names are what players type to look at it or attack it, so they
−
to say means the claws are about the size of short swords and long
+
should cover the title and the description. Longer names come first: no name
−
swords."
+
may begin with a name earlier in the list.
 +
<pre>
 +
bldragon
  
−
extra {"scales","scale"}
+
title "a black dragon"
−
"Its a scale!  Haven't you ever seen a dragon before!"
+
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 {"bat wings","wings"}
+
end
−
"The dragon sees you looking and flaps his wings creating one heck of a
+
</pre>
−
wind blast."</nowiki>
+
The other fields go between the names and <code>end</code>.
−
Now that we have the NPC all described we should start setting
 
−
    things like race, gender, level, height, weight, defense, offense,
 
−
    alignment, abilities, and finally skills and spells.  First we will pick a race.  Normally the
 
−
    list of races are in your ''values.h''.  We have
 
−
    the list in (Link to app-c) and I have searched for dragon
 
−
    and found the race I want it is as follows.
 
−
<nowiki>
 
−
race RACE_DRAGON_BLACK</nowiki>
 
−
If you don't think there is any difference in dragons you can
 
−
set them all to one race like you could define a race called
 
−
'RACE_DRAGON' or something like that.
 
  
−
Now we should chose the gender of our dragon.  Make sure your
+
==== What players see when they look ====
−
descriptions match what you pick.  It would be pretty weird to have a
 
−
female dragon and have the descriptions say 'he, him, or his'
 
−
<nowiki>
 
−
    sex SEX_MALE</nowiki>
 
−
Now lets set the height and weight.  Remember you set the height
 
−
in centimeters and the weight in pounds.  In the future the VME will
 
−
standardize to one or the other but for now we have to play the
 
−
conversion game.
 
−
<nowiki>
 
−
//20 feet  (1 inch = 2.54 cm
 
−
height 625
 
  
−
//566 KG (1 lb. = .45359 kg)
+
The description shown by <code>look dragon</code> is an extra with an empty
−
weight 1250</nowiki>
+
names list:
−
Now that we have the size of the dragon we can pick a level.
+
<pre>
−
My dragon is only 20 feet tall and 1250 pounds so I think maybe he
+
extra {}
−
is a bit young and will make his level around 70.
+
"The black dragon's scales glitter like black granite that has been
−
<nowiki>
+
polished for years by water.  He has a long neck and huge bat-like
−
level 70</nowiki>
+
wings.  His eyes watch you as you stand before him.  One claw taps
−
The dragon may not wear armour but by default a dragon should
+
slowly on the ground, as if the dragon is waiting for something."
−
have an armour equal to someone wearing plate mail.  Not only that
+
</pre>
−
but my dragon doesn't like to use his mouth as his natural attack
+
Line breaks in the text are kept as you write them, so keep the lines under
−
and he sure can't punch with those big claws so we need to set his
+
about 72 characters.
−
attack type to claw.
 
−
<nowiki>
 
−
NATURAL_DEF(WPN_CLAW, ARM_PLATE)</nowiki>
 
−
Not many black dragons are good so I will pick almost totally
 
−
evil, since totally evil is -1000 I will set it as follows.
 
−
  <nowiki>
 
−
alignment -900</nowiki>
 
−
Finally we get to the hard part.  Many people have trouble
 
−
setting the NPC abilities, weapons, and spells.  There really is nothing
 
−
to it if you have read (Link to npcmacroability) and (Link to npcmacroweapspl).  The only thing you have to remember is the
 
−
numbers you are putting are not the actual amount but a percentage of
 
−
the skill points you want the game to use on your NPC when having your
 
−
NPC practice as it loads and all amounts of abilities must add up to
 
−
100% as well as all weapons and spells must add up to 100%.  For the
 
−
dragon the following would be what the abilities, weapons, and spells
 
−
would look like.
 
−
<nowiki>
 
−
//big strong and magical most ability points on str and mag
 
−
MSET_ABILITY(20,12,12,12,12,12,20,0)
 
  
−
//Set natural attack highest of weapons because he fights with claws
+
Then describe the parts a player may want to look at, here the eyes and claws,
−
MSET_WEAPON(10,10,10,5,30,5)
+
and a few more for fun:
 +
<pre>
 +
extra {"eyes", "eye"}
 +
"The dragon's eyes follow you wherever you go in the room.  Nothing
 +
escapes the dragon's attention."
  
−
//black dragons have natural defense from acid set it highest
+
extra {"claws", "claw"}
−
MSET_SPELL(0,0,0,0,0,0,0,0,0,0,30)</nowiki>
+
"The claws are big, black and deadly.  The dragon has two sets of four
−
That is all you need to make a basic dragon.  True this dragon
+
large claws and two sets of four smaller ones; the large ones are the
−
will not do anything but claw you to death if you attack it but in (Link to npccomplex) we will give the dragon some more abilities with
+
size of long swords, the small ones the size of short swords."
−
some special DIL functions. For now lets take a look at our finished
 
−
product.
 
−
<nowiki>
 
−
bldragon
 
  
−
title "a black dragon"
+
extra {"scales", "scale"}
−
descr "A big ugly black dragon is clawing the ground here."
+
"It's a scale!  Haven't you ever seen a dragon before?"
−
names {"big ugly black dragon","ugly black dragon","big black dragon",
 
−
"black dragon","dragon"}
 
  
−
extra {}
+
extra {"bat wings", "wings"}
−
"The black dragons scales glitter like black granite that has been
+
"The dragon sees you looking and flaps his wings, raising quite a gale."
−
polished for years by water.  He has a large neck and huge bat like
+
</pre>
−
wings. his eyes watch you as you stand before him.  One claw seems to be
 
−
tapping slightly on the ground as if the dragon is waiting for
 
−
something."
 
  
−
extra {"eyes","eye"}
+
==== Race and sex ====
−
"The dragons eyes seem to follow you no matter where you go in the room
 
−
nothing seems to escape the dragons attention."
 
  
−
extra {"claws","claw"}
+
The races are in <code>values.h</code> (see
−
"The claw is big black and it looks very deadly.  It seems like the
+
[[Manual:Zone Manual/Appendices/Race Definitions in values.h|Race Definitions in values.h]]).
−
dragon has two sets of 4 large claws and 2 sets of 4 smaller claws which
+
Searching for "dragon" finds the one we want:
−
to say means the claws are about the size of short swords and long
+
<pre>
−
swords."
+
race RACE_DRAGON_BLACK
 +
</pre>
 +
Next the sex. Make sure the descriptions match it; a female dragon described as
 +
"he" would be odd.
 +
<pre>
 +
sex SEX_MALE
 +
</pre>
  
−
extra {"scales","scale"}
+
==== Height and weight ====
−
"Its a scale!  Haven't you ever seen a dragon before!"
 
  
−
extra {"bat wings","wings"}
+
Height is in centimetres, weight in pounds. The weight matters in combat: an NPC
−
"The dragon sees you looking and flaps his wings creating one heck of a
+
over 500 pounds hits with its full natural attack, a lighter one with less.
−
wind blast."
+
<pre>
 +
height 625    // about 20 feet; 1 inch is 2.54 cm
 +
weight 1250    // about 567 kg; 1 pound is 0.4536 kg
 +
</pre>
  
−
race RACE_DRAGON_BLACK
+
==== Level ====
−
sex SEX_MALE
 
−
height 625
 
−
weight 1250
 
−
level 70
 
−
NATURAL_DEF(WPN_CLAW, ARM_PLATE)
 
−
alignment -900
 
−
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)
 
  
−
end</nowiki>
+
At 20 feet and 1250 pounds my dragon is still young, so I make him level 70.
−
As you can see there is a bit more to building an NPC than a room
+
The level decides how many ability and skill points he gets.
−
but its really not that much harder. Try changing some stuff and make
+
<pre>
−
sure to practice debugging your errors the more compiling you do the
+
level 70
−
better you will get.
+
</pre>
 +
 
 +
==== Natural attack and armour ====
 +
 
 +
The dragon wears no armour, but his scales should protect him like plate mail.
 +
He doesn't bite or punch; he fights with his claws, and large ones:
 +
<pre>
 +
NATURAL_DEF(WPN_CLAW_LARGE, ARM_PLATE)
 +
</pre>
 +
 
 +
==== Alignment ====
 +
 
 +
Not many black dragons are good. Utterly evil is -1000; mine is nearly that:
 +
<pre>
 +
alignment -900
 +
</pre>
 +
 
 +
==== Money ====
 +
 
 +
A dragon should have a hoard, but a level 70 NPC may carry only a little over
 +
one gold piece before <code>vmc</code> warns that it is too much:
 +
<pre>
 +
money 1 GOLD_PIECE
 +
</pre>
 +
A real hoard is better made as treasure objects loaded next to the dragon by the
 +
reset section.
 +
 
 +
==== Abilities, weapons and spells ====
 +
 
 +
This is the part people find hardest, but there is little to it once you have
 +
read [[Manual:Zone Manual/The NPC Section/NPC macros|NPC macros]]. The numbers
 +
are not the abilities and skills themselves but the share, in per cent, of the
 +
points the game gives an NPC of this level. The eight abilities must add up to
 +
100, and the weapons and spells together must add up to 100.
 +
<pre>
 +
// big, strong and magical: most points in strength and magic
 +
MSET_ABILITY(20,12,12,12,12,12,20,0)
 +
 
 +
// he fights with his claws, so most of the weapon share is unarmed (70% in all)
 +
MSET_WEAPON(10,10,10,5,30,5)
 +
 
 +
// black dragons are acid creatures: the rest goes to external (acid) spells
 +
MSET_SPELL(0,0,0,0,0,0,0,0,0,0,30)
 +
</pre>
 +
The 30% in external spells is both his skill with acid spells and his
 +
resistance to them.
 +
 
 +
==== The finished dragon ====
 +
 
 +
That is all a basic dragon needs. He will do nothing but claw you to death if
 +
you attack him; in
 +
[[Manual:Zone Manual/The NPC Section/A more complex set of NPCs|A more complex set of NPCs]]
 +
we give NPCs more to do with DIL functions. Here is the finished product:
 +
<pre>
 +
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)
 +
alignment -900
 +
money 1 GOLD_PIECE
 +
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)
 +
 
 +
end
 +
</pre>
 +
 
 +
==== The quick way: a template ====
 +
 
 +
<code>macros.h</code> already has black dragons, in six sizes. With a template
 +
the same dragon is much shorter:
 +
<pre>
 +
bldragon
 +
 
 +
M_DRAGON_BLACK_MEDIUM(70, SEX_MALE)
 +
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."
 +
 
 +
height 625
 +
weight 1250
 +
alignment -900
 +
 
 +
end
 +
</pre>
 +
The template sets race, level, sex, natural attack and armour, abilities and
 +
skills, and it makes the dragon breathe acid in a fight and attack players
 +
(it copies the <code>combat_mag</code> and <code>aggressive</code> DIL functions
 +
onto him). Put the template first: the fields after it change what it set, so
 +
here the dragon keeps our height, weight and alignment instead of the
 +
template's. The templates are listed on
 +
[[Manual:Zone Manual/The NPC Section/NPC macros|NPC macros]].
 +
 
 +
There is a bit more to an NPC than to a room, but not much. Try changing things,
 +
and practise finding your mistakes: the more you compile, the better you get at
 +
it. The next page does exactly that.
  
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_NPC_Section/NPC_macros|Previous: NPC macros]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: left;float:left;width:50%;'>[[Manual:Zone_Manual/The_NPC_Section/NPC_macros|Previous: NPC macros]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_NPC_Section/Compiling_and_debugging_your_first_NPC|Next: Compiling and debugging your first NPC]]</div>
 
<div style='padding-top: 30px; padding-bottom: 20px; text-align: right;float:right;width:50%;'>[[Manual:Zone_Manual/The_NPC_Section/Compiling_and_debugging_your_first_NPC|Next: Compiling and debugging your first NPC]]</div>

Latest revision as of 06:20, 15 November 2026

Building your first NPC

Now that you have built your first zone with rooms, it is time to populate it with characters for your players to hunt, kill or talk to. The last two pages described the fields and the macros; on this page we build one NPC with them. I like dragons, as you saw in the room section, so the first NPC is a big, bad, ugly black dragon. If you don't like dragons, you will still learn enough from it to build whatever you want.

NPCs go in the %mobiles section of the zone file. We add that section to the dragon station zone, dragonst, from the room section; a zone needs only the sections it uses, so a zone of nothing but NPCs is fine too. In Dragon station with rooms and NPCs the rooms and the NPCs come together.

The symbol

Every NPC starts with its symbol. Pick one that matches the NPC, so that it is easy to find: wstat zone dragonst mobiles lists the zone's NPCs by symbol only, and load bldragon@dragonst needs the symbol. A list like dragon clerk trashman tells you what is there; a list like npc1 npc2 npc3 doesn't, and once you have thirty NPCs you will not remember which is which.

All that an NPC needs is its symbol and end:

bldragon
end

That compiles, but every field has its default: a level 1 human of neutral sex with no names, title or description. Let's turn it into a dragon.

Title, description and names

The title is what the game shows when the dragon does something ("a black dragon claws you"). The description is the line players see in the room while it stands. The names are what players type to look at it or attack it, so they should cover the title and the description. Longer names come first: no name may begin with a name earlier in the list.

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"}

end

The other fields go between the names and end.

What players see when they look

The description shown by look dragon is an extra with an empty names list:

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."

Line breaks in the text are kept as you write them, so keep the lines under about 72 characters.

Then describe the parts a player may want to look at, here the eyes and claws, and a few more for fun:

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 and sex

The races are in values.h (see Race Definitions in values.h). Searching for "dragon" finds the one we want:

race RACE_DRAGON_BLACK

Next the sex. Make sure the descriptions match it; a female dragon described as "he" would be odd.

sex SEX_MALE

Height and weight

Height is in centimetres, weight in pounds. The weight matters in combat: an NPC over 500 pounds hits with its full natural attack, a lighter one with less.

height 625     // about 20 feet; 1 inch is 2.54 cm
weight 1250    // about 567 kg; 1 pound is 0.4536 kg

Level

At 20 feet and 1250 pounds my dragon is still young, so I make him level 70. The level decides how many ability and skill points he gets.

level 70

Natural attack and armour

The dragon wears no armour, but his scales should protect him like plate mail. He doesn't bite or punch; he fights with his claws, and large ones:

NATURAL_DEF(WPN_CLAW_LARGE, ARM_PLATE)

Alignment

Not many black dragons are good. Utterly evil is -1000; mine is nearly that:

alignment -900

Money

A dragon should have a hoard, but a level 70 NPC may carry only a little over one gold piece before vmc warns that it is too much:

money 1 GOLD_PIECE

A real hoard is better made as treasure objects loaded next to the dragon by the reset section.

Abilities, weapons and spells

This is the part people find hardest, but there is little to it once you have read NPC macros. The numbers are not the abilities and skills themselves but the share, in per cent, of the points the game gives an NPC of this level. The eight abilities must add up to 100, and the weapons and spells together must add up to 100.

// big, strong and magical: most points in strength and magic
MSET_ABILITY(20,12,12,12,12,12,20,0)

// he fights with his claws, so most of the weapon share is unarmed (70% in all)
MSET_WEAPON(10,10,10,5,30,5)

// black dragons are acid creatures: the rest goes to external (acid) spells
MSET_SPELL(0,0,0,0,0,0,0,0,0,0,30)

The 30% in external spells is both his skill with acid spells and his resistance to them.

The finished dragon

That is all a basic dragon needs. He will do nothing but claw you to death if you attack him; in A more complex set of NPCs we give NPCs more to do with DIL functions. Here is the finished product:

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)
alignment -900
money 1 GOLD_PIECE
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)

end

The quick way: a template

macros.h already has black dragons, in six sizes. With a template the same dragon is much shorter:

bldragon

M_DRAGON_BLACK_MEDIUM(70, SEX_MALE)
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."

height 625
weight 1250
alignment -900

end

The template sets race, level, sex, natural attack and armour, abilities and skills, and it makes the dragon breathe acid in a fight and attack players (it copies the combat_mag and aggressive DIL functions onto him). Put the template first: the fields after it change what it set, so here the dragon keeps our height, weight and alignment instead of the template's. The templates are listed on NPC macros.

There is a bit more to an NPC than to a room, but not much. Try changing things, and practise finding your mistakes: the more you compile, the better you get at it. The next page does exactly that.

Previous: NPC macros
Next: Compiling and debugging your first NPC