Let's examine a simple monster. There are some optional functions in here, but players tend to place more importance in monsters so it's a good idea to use the optional functions:
simplemonster.c
inherit STD_LIVING_OB;
void create()
{
   ::create();
   set_name("rat");
   set_id(({"rat","brown rat"}));
   set_short("small brown rat");
   set_race("rodent");
   set_long("This small brown rat is the very first monster ever "+
     "created in this MUD.  It is abused for combat tests without "+
     "supervision by the Humane Society.  Bash away!");

   set_level(1);        // This sets default stats, hit points, and exp value
   set_melee("1d1");    // A rat does only 1 point on successful hit
   set_wimpy(0);        // Set to a positive # of HP to be really annoying...
   set_weight(1);       // A rat weighs 1 pound (OK, so it's a big one..)
   set_base_ac(11);     // Optional.  Default value is 10.
   set_alignment("TN"); // "TN"=True Neutral
   set_size("S");
   set_gender("male");  // "male" or "female".  

   set_stat("str", 7);  // Do this only for small monsters
   set_stat("dex", 7);  // Likewise...
   set_stat("con", 9);  // Likewise...
   set_stat("int", rolldie("1d5"));        // Non-sentient creature
   set_stat("wis", rolldie("1d5"));        // Non-sentient creature

   max_hp = rolldie("1d4");
   hp = max_hp;

   set_diemsg("$N squeeks pitifully and dies.");  // Optional death message
}

Wow! That was a lot of code! What's the absolute minimum needed to make a working monster? Here it is:

inherit STD_LIVING_OB;
void create()
{
   ::create();
   set_name("rat");
   set_id(({"rat","brown rat"}));
   set_short("small brown rat");
   set_race("rodent");
   set_long("This small brown rat is the very first monster ever "+
     "created in this MUD.  It is abused for combat tests without "+
     "supervision by the Humane Society.  Bash away!");
   set_level(1); 
   set_weight(1);
   set_size("S");
}

Let's review the required functions, first, before moving on to the optional ones.

set_name("rat");
We don't use this function in rooms, weapons or armours... only in monsters. This sets the "living name" for the monster, and is required.

set_race("rodent");
The creature's race is displayed in the players' "consider" command. It is also useful when a weapon has a special bonus against a specific race.

set_level(1);
This is the BIG one! This sets the creature's "level", a rating that determines its hit points, saving throws, default feats, and experience awarded when killed. This also initializes the creature's stats. If you intend of tweaking the stats, set the level first or your custom stats will be lost.

set_size(S);
There are three basic creature sizes. Please see Grey before attempting to use another size (Tiny, Gigantic, etc.) as support for them would need to be added to the combat code:


Okay, let's look at the optional functions now. I'll assume you've already read through the room, weapon and armour documents, so I'll skip the functions previously discussed there.

set_melee("1d1");
This sets how much damage the creature can do if it isn't wielding a weapon. The default setting is "1d3" (1 to 3 hit points). I changed it to "1d1" to make rats really easy to kill.

set_wimpy(0);
Want to make a monster that flees the room when it gets close to death? Then change this number of a positive number of hit points... it'll start to flee when its HP fall below this number! The default wimpy is zero.

set_base_ac(11);
The default Armour Class for creatures is 10. The higher the number, the harder the monster is to hit. Rats scurry about underfoot, so they're kind of hard to hit with a sword.

set_alignment("TN");
There are 9 allowed alignment values you can choose from. They are:

Unintelligent monsters, like our rat here, don't really have any choices in life so they're "true neutral". This is the default alignment. Consult the Players' Handbook for a detailed explaination about each of the above alignments.

set_gender("male");
Choose either "male" or "female". It makes no difference in terms of combat ability, size, etc. Don't use this function if you wish to have a "neuter" monster.

set_stat("str", 7);
The six primary stats are randomly set for monsters the same way they're set for players (by rolling a 3d6). You can override them if you know what you're doing, and have a good reason for doing so. Our rat here isn't a muscleman, so I picked a low strength to make sure it didn't get an 18 in a random roll.

set_diemsg("$N squeeks pitifully and dies."); This replaces the default death message of "Rat dies." Be sure to use the $N, as the MUD will replace it with the monster's name.

max_hp = rolldie("1d4");
The default Hit Points (HP) for a creature is calculated by rolling a 1d8 for each level it has. A rat is extremely weak, so I changed its HP from 1-8 to 1-4. In most cases you won't need to do this... just let the level set the HP.

hp = max_hp;
If you change the max_hp, be sure to add this statement as well. Otherwise, the creature may start at less than full health.


And PLEASE... don't call them "mobs"! :)

This brings to mind a black & white horror movie, where a crowd of angry torch-wielding villagers storm Dr. Frankenstein's castle.

If you need to use an abbreviation, try "NPC" (non-player character).


This page may be viewed from any browser, not just one from Redmond.
Last Modified: Feb 10, 2001
Page written by Dave Shay (how to contact me).
Page content copyright ©2000-2001 by Dave Shay. Do not copy without express permission.
Dungeons & Dragons is a registered trademark of TSR, Inc., a subsidiary of Wizards of the Coast.
D&D rules, races, classes, features, etc. used in accordance with the TSR, Inc. Internet Policy.