inherit STD_ROOM_OB;
void create()
{
::create();
set_short("Elven workshop");
set_long("An elven workshop.\n\n"+
"An elf blacksmith looks up at you from his work and smiles at you. "+
"Next to him, on the table, is a suit of armor he's working on.");
add_exit("east", __DIR__+"villagesquare");
}
void reset()
{
::reset();
if(!present("blacksmith"))
new("/wizards/grey/mon/blacksmith")->move(this_object());
}
OK, in the above example, I haven't introduced anything new you haven't already seen. So what's wrong with this room? Three things, really.
Here's how we can fix the above problems!
simpleroom3.c
inherit STD_ROOM_OB;
void create()
{
::create();
set_short("Elven workshop");
set_long("An elven workshop.\n\n"+
"An elf blacksmith looks up at you from his work and smiles at you. "+
"Next to him, on the table, is a suit of armor he's working on.");
set_slaughter("blacksmith",
"A bloody elven workshop.\n\n"+
"An elf blacksmith used to work here, but now the workshop is in "+
"disarray. A murder has recently been committed here! Blood stains "+
"cover the table.");
add_item("table","The table is a simple workbench used for polishing "+
"weapons and armor. A suit of armor is on the table.");
add_item("armor","A suit of armor occupies the blacksmith's table. "+
"An inscription has been written on the suit.");
add_item("inscription", "The inscription on the suit says:\n\n"+
" %^RED%^To my son, Feanor, on his 120th birthday.%^RESET%^");
add_exit("east", __DIR__+"villagesquare");
}
void reset()
{
::reset();
if(!present("blacksmith"))
new("/wizards/grey/mon/blacksmith")->move(this_object());
}
Let's examine the two new function calls I've added:
set_slaughter("blacksmith","A bloody elven workshop...");
The set_slaughter function is used to create an alternate long description
for the room. This alternate description is used when the named creature
is not present. It works just like set_long(), except that it requires
two "arguments" (things separated by commas) instead of just one. The first
"argument" (also called a "parameter") is the monster's name. The second
is the alternate long description. Pretty slick, eh? :)
add_item("armor","A suit of armor occupies...");
This defines a "virtual item" to be included in the room. This is
NOT a "real" object which could be picked up by a player.
The first argument is the item's name. The second argument is what the
player sees when "look at {named item}" is typed.
Well-written areas always make extensive use of these two functions. The set_item function exists on most lpmud/MudOS style MUDs, so many experienced players expect to be able to "look at" items mentioned in the room's description. The set_slaughter function was custom-written for Coastal Legends and Core 26**.
In our next lesson, we'll have fun with secret doors, locked doors, and doors guarded by monsters!