Crashcourse - Part 04

[previous part] [Table of contents] [next part]

Ah, we are finally ready to start building some rooms and defining some of their behaviour.

Let's get started with this file:

FILENAME: mbase.c

This roomfile is a place outside a cave in a mountain. The room has several items and 3 exits. The first thing that you encounter while reading through the file, is the call of the set_light() function. ALL objects are as default non-illuminating objects. And that includes rooms. So, therefore we have to do a set_light(1) to raise the light level in the room to 1. The name of the set_light() function is really misleading. It doesn't set the light, it changes it. The name add_light() would have been better. Using the set_light() function you may alter the light in a room to both negative and positive values. The higher the value the more lit is it, the lower the value is, the more light is needed to light up the room. Usually, a value of 1 is used. Further down the standard set_short() and set_long() functions are called. They work almost just as you know it from items and monsters. Except that the short is seen only if you turn on the brief mode ('toggle brief'). As you can see in this file, I have used quite a lot of add_item() calls. This is because you should strive to describe all your rooms as best as possible. It is important that all basic items are in your rooms. For instance, if you're outside, you should be able to look at the sky, clouds, the sun, the ground and all other natural items. I'm not saying that you have to include every single little item you would see in real life, just the most important ones. And try to make it all natural. If you describe a northern wall inside a house, you should also have the other walls described.

The only new function in this file is the function called add_exit(). add_exit() sets the exit out of the room, using the filename for the new room as the first parameter, and the direction as the second parameter. You don't have to type in the complete pathname for the filenames, it is sufficient to type in the relative pathname. For instance "./mbase" for a file in the same dir, "../mbase" for a file in the parent dir and "./mountain/mbase" for a file in the sub directory mountain.

Note! It is important to note that you should NOT use the suffixes for the files when addressing them like this. The mudlib knows that all code files end in '.c'.

As you can see from the exitnames, you're not restricted to using north/south/east/etc. as direction. Anything you write will be the "command" the players have to type in to get there. But, only the standard directions will be abbrievated(s=south,n=north,u=up,ne=northeast,etc).

FILENAME: mbase_w.c

There's only one new function to introduce here, but it's a nice function that can help give atmosphere to a place. The add_neg() function lets you add certain commands to a room. The first parameter is the command (sniff, take, smell, etc), the second is the "what" parameter (flower, flowers) and the third is the message to be written to the player. Please read 'man add_neg' for further enlightenment. It is important to note that add_neg() will only allow one use of a single verb. You can't have several add_neg()'s for the same verb. If you need this, you will have to use add_trigger() and check for the different ids. We'll come back to this in a later course(#05).

FILENAME: mbase_e.c

In this file, we introduce some new parameters for the add_item() function. You can actually use the add_item() instead of the add_neg() in some cases. If you take a look at the water/river item, you see that the third parameter is a verb: drink. This tells the add_item() function that when a player types the verb drink plus one of the ids of the item, the player shall get the message stored in the fourth parameter of the add_item() function.

At the end of the file a new function has been included: add_reset_object() This function will attach an object to the room which will be loaded and moved into the room when the room is created and when it is reset. This function has three parameters, the first one is the name of the object to be included. The second one is the filename of that object, while the third is the number of objects to clone into the room. There are three new properties in this room:

no_magic Will block all magic inside the room.
no_flee It is impossible to flee from the room.
no_teleport It is impossible to teleport in and out of the room.

FILENAME: cave.c

This cave is haunted... The light is gone... Strange noises are heard inside it... :-0
Let's first take a look at those three properties:

indoors Must be in ALL indoor rooms!
underground Used in rooms under ground.
no_pet Keeps those annoying pets out...

Read more about possible properties of rooms with 'lookupp -V Rooms'.

It's time to look at what makes the room so darned noisy. As you can see we're using a function called add_room_modifier(). This function can change a lot of different modifiers in a room. It can make a room heal players, it can make it drain players, it can keep players from eating inside it, etc. We have used the modifier called 'noise'. The parameters for this function using this modifier are as follows: The first parameter is the modifier name('noise'), the second one is the timer. The timer tells you how often a message shall be written to the room. It's important that you don't make the messages appear too often or the room will be much too noisy. The timer is measured in seconds. The third parameter is an array of strings that shall be written to the room every time the timer strikes.
I strongly advise you to take a look at this function since it may help improve your rooms drastically. But, this noise modifier should not be abused. It's noisy and should only be used in special rooms.

WRITTEN: 30 - Sep - 1996 - Gunner
LAST UPDATE: 26 - May - 1998 - Gunner
HTML Version: 01 - Feb - 2000 - Ghorwin

[previous part] [to the top] [Table of contents] [next part]