#include <mudlib.h>
#include <container.h>
inherit I_CONTAINER;
#define FUNC "/doc/examples/container/iron_chest_funcs"
void
create() {
::create();
set_name("iron chest");
set_short("an iron chest");
set_long("This iron chest looks very heavy and very robust.\n");
add_id(({"iron chest","chest","heavy chest"}));
add_property("iron");
set_value(140);
set_max_weight(58);
set_weight(40);
set_can_open(TRUE);
set_def_open(FALSE);
set_can_lock(TRUE);
set_def_lock(TRUE);
set_keycode("key for chest examples");
set_msgs(TO_PLAYER, UNLOCK_MSG, 0);
set_msgs(TO_ROOM, UNLOCK_MSG, 0);
set_msgs(TO_PLAYER, OPEN_MSG, 0);
set_msgs(TO_ROOM, OPEN_MSG, 0);
add_hook("__unlock",({ FUNC, "unlock_chest" }) );
add_hook("__open",({ FUNC, "open_chest" }) );
replace_program(I_CONTAINER);
}
#include <mudlib.h>
inherit I_DAEMON;
void
unlock_chest(object keyobject) {
object player = this_player();
if (!player)
return;
tell_object(player,
"As you turn the key the lock snaps suddendly open with a loud "
"crack. Unfortunately it was your key that cracked. But the chest is "
"unlocked and you really don't want to carry a useless key, don't "
"you?\n");
tell_room(environment(player), player->query_name() + " unlocks the iron "
"chest but unfortunately " + player->query_possessive() +
" key breaks with a loud crack.\n", ({ player }) );
destruct(keyobject);
}
void
open_chest() {
object player = this_player();
if (!player)
return;
tell_object(player,
"As you open the lid of the chest suddendly a burning liquid spurt "
"forth and burns your hands and face.\n");
tell_room(environment(player), player->query_name() + " opens the iron "
"chest and suddendly a burning liquid sprays over " +
player->query_objective() + ".\n", ({ player }) );
if (player->query_hp() > 20)
player->reduce_hit_point(20);
else
player->reduce_hit_point(player->query_hp()-1);
}