Manual:Zone Manual/The NPC Section/Building your first NPC
Contents
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.