small_chest.c - example for course 15

[previous example] [course15] [Table of contents] [next example]
/* File          : small_chest.c
 * Description   : example for use of a container
 *
 * written       : 25-Nov-2000 - Ghorwin
 * last modified : 26-Mar-2001 - Ghorwin
 */

#include <mudlib.h>
#include <container.h>
inherit I_CONTAINER;

void
create() {
    ::create();
    set_name("small chest");
    set_short("a small chest");
    set_long("This chest is quite small. It's an example only.\n");
    add_id(({"chest"}));
    set_value(50);
    set_max_weight(4);
    set_weight(2);

    set_can_open(TRUE);
    set_def_open(FALSE);

    set_can_lock(TRUE);         // now it has a lock
    set_def_lock(TRUE);         // lock it during reset
    set_keycode("key for chest examples");  // which key?

    // setup your private messages

    // set only one message at a time
    set_msgs(TO_PLAYER, OPEN_MSG, "As you open the chest you hear a voice "
        "behind you: You fool. This chest has been cursed and now you have "
        "opened it!\n");
    set_msgs(TO_PLAYER, CLOSE_MSG, "You close the chest and hear a relieved "
        "voice behind you: Very good. The chest is closed now! May nobody "
        "ever open it again.\n");

    // set a bunch of messages (one whole category)
    set_msgs(TO_ROOM, ({ "Oh no! #N opened the chest!\n",
                         "Good!! #N closed the chest again!\n",
                         "Great! #N locked the chest!\n",
                         "Bugger... #N just unlocked the cursed chest!\n" }) );

    replace_program(I_CONTAINER);
}