/* A Well
#include <mudlib.h>
inherit ROOM;
void reset(status arg) {
if(arg) return;
set_short("Knowledge Street");
set_long(
"\tKnowledge Street.\n"+
"The cobblestones beneath your feet are more wet here, moistened \n"+
"by the humid sea air that blows in from the wharves to the east.\n);
set_items(({
"cobblestone#cobblestones",
"Fine street pathing stones. They appear a little moistened",
"wharf#wharves",
"Great sea ships berth at the wharves to the east",
"ship#ships#great ships",
"They're moured at the wharf",
}));
set_weather(2, 1, 0);
set_smell("You can smell the sea air.\n");
set_listen("The waves crash in from the east.\n");
}
* The well is a simple place where the players can drink and get a
* free heal every reset or so. Only MAX_WATER drinks can be taken
* from the well, with WATER hp being healed each time
* (c) Angel, Jan 1994
*/
#define NAME (string)this_player()->query_name()
#define MAX_WATER 3
#define WATER (random(5) + 5)
#include <mudlib.h>
int water; /* the amount of water in the well */
int water_counter;
status bucket; /* is there a bucket handy? */
status rope; /* is there any rope? */
status tied_to_bucket; /* is the rope tied to the bucket */
status tied_to_well; /* is the rope tied to the well? */
status up; /* is the bucket up or down? */
status dry; /* is the well dry? */
inherit ROOM;
void reset(status arg) {
up = 1;
dry = 0;
water = 0;
bucket = 1;
rope = 1;
tied_to_bucket = 1;
tied_to_well = 1;
if(arg) return;
set_weather(2, 4, 0);
set_short("Knowledge Street");
set_long("\tKnowledge Street.\n"+
"To the west the great Tempus city library stands, while to the \n"+
"east you can clearly see the ocean. In the center of the street \n"+
"is a small well.\n");
set_exits(({
"room/city/knowl1", "west",
"room/city/jetty", "east",
}));
set_items(({
"library",
"The library was made five centuries ago by the elves to the north.\n"+
"It serves as a great center for learning for all its citizens",
}));
}
void init() {
::init();
add_action("get_item", "get");
add_action("turn_handle", "turn");
add_action("untie_stuff", "untie");
add_action("tie_stuff", "tie");
add_action("drink", "drink");
}
status drink(string str) {
if(!up) {
notify_fail("The bucket must be at the top of the well "+
"to drink from the well.\n");
return 0;
}
if(!bucket) {
notify_fail("But there is no bucket to drink from.\n");
return 0;
}
if(!water) {
notify_fail("There is no water left in the bucket.\n");
return 0;
}
if(dry) {
notify_fail("The well is dry.\n");
return 0;
}
if(!this_player()->drink_soft(WATER)) {
write("You can't possibly drink any more!\n");
return 1;
}
write("You drink the water from the well.\n");
say(NAME+" drinks water from the well.\n");
water = 0;
return 1;
}
status turn_handle(string str) {
if(str != "handle") {
notify_fail("Turn what?\n");
return 0;
}
if(!up) {
write("You turn the handle and the bucket comes up the well.\n");
say(NAME+" turns the handle on the well and the bucket comes up.\n",
this_player());
up = 1;
return 1;
}
if(up) {
write("You turn the handle and the bucket goes down the well.\n");
say(NAME+" turns the handle on the well and the bucket goes down.\n",
this_player());
up = 0;
water = 1;
water_counter += 1;
if(water_counter > MAX_WATER) dry = 1;
if(!dry)
tell_room(this_object(),
"You hear a splash as the bucket hits the water.\n");
else
tell_room(this_object(),
"You hear the bucket hit the dry bottom of the well.\n");
return 1;
}
return 0;
}
status tie_stuff(string str) {
string tmp1, tmp2;
object ob;
if(!str) return 0;
if(!rope && !present("rope", this_player())) {
notify_fail("There is no rope here.\n");
return 0;
}
if(!up) {
notify_fail("You can't. The bucket is at the bottom of the well.\n");
return 0;
}
if(sscanf(str, "rope%sbucket%s", tmp1, tmp2) ||
sscanf(str, "bucket%srope%s", tmp1, tmp2)) {
if(tied_to_bucket) {
notify_fail("The rope is already tied to the bucket.\n");
return 0;
}
write("You tie the rope to the bucket.\n");
say(NAME+" ties the rope to the bucket.\n", this_player());
tied_to_bucket = 1;
if(!rope && present("rope", this_player()))
destruct(present("rope", this_player()));
return 1;
}
if(sscanf(str, "rope%swell%s", tmp1, tmp2) ||
sscanf(str, "well%srope%s", tmp1, tmp2)) {
if(tied_to_well) {
notify_fail("The rope is already tied to the well.\n");
return 0;
}
write("You tie the rope to the well.\n");
say(NAME+" unties the rope from the well.\n", this_player());
tied_to_well = 1;
if(!rope && present("rope", this_player()))
destruct(present("rope", this_player()));
return 1;
}
write("Untie what from where?\n");
return 1;
}
status untie_stuff(string str) {
string tmp1, tmp2;
if(!str) return 0;
if(!rope) {
notify_fail("There is no rope here.\n");
return 0;
}
if(!up) {
notify_fail("You can't. The bucket is at the bottom of the well.\n");
return 0;
}
if(sscanf(str, "rope%sbucket%s", tmp1, tmp2) ||
sscanf(str, "bucket%srope%s", tmp1, tmp2)) {
if(!tied_to_bucket) {
notify_fail("The rope is already untied from the bucket.\n");
return 0;
}
write("You untie the rope from the bucket.\n");
say(NAME+" unties the rope from the bucket.\n", this_player());
tied_to_bucket = 0;
return 1;
}
if(sscanf(str, "rope%swell%s", tmp1, tmp2) ||
sscanf(str, "well%srope%s", tmp1, tmp2)) {
if(!tied_to_well) {
notify_fail("The rope is already untied from the well.\n");
return 0;
}
write("You untie the rope from the well.\n");
say(NAME+" unties the rope from the well.\n", this_player());
tied_to_well = 0;
return 1;
}
write("Untie what from where?\n");
return 1;
}
status look_at(string str) {
if(str == "well") {
write("There is a handle attached to the well.\n"+
"Perhaps you could drink from it?\n");
if(up && bucket && rope)
write("The rope and bucket is at the top of the well.\n");
if(!up && bucket && rope)
write("The rope and bucket are at the bottom of the well.\n");
if(!water)
write("The well appears dry.\n");
else
write("The well appears to have some water in it.\n");
if(!bucket)
write("There used to be a bucket attached to the wall.\n");
if(tied_to_well)
write("There is a rope tied to the well.\n");
if(tied_to_bucket)
write("There is a rope tied to the bucket.\n");
return 1;
}
if(str == "bucket") {
if(!bucket) {
notify_fail("There is no bucket here.\n");
return 0;
}
write("A small wooden bucket.\n");
if(tied_to_bucket)
write("The bucket is tied to a rope.\n");
return 1;
}
if(str == "rope") {
if(!rope) {
notify_fail("There is no rope here.\n");
return 0;
}
if(tied_to_well)
write("The rope is tied to the well.\n");
if(tied_to_bucket)
write("The rope is tied to a bucket.\n");
return 1;
}
return::look_at(str);
}
status get_item(string str) {
object ob;
if(str == "bucket") {
if(!bucket) {
notify_fail("There is no bucket attached to the well.\n");
return 0;
}
if(tied_to_bucket) {
notify_fail("You can't. The bucket is tied to the well.\n");
return 0;
}
ob = clone_object(CONTAINER);
ob -> set_short("A bucket");
ob -> set_long("A small wooden bucket.\n");
ob -> set_weight(2);
ob -> set_sell_destruct(1);
ob -> set_value(10);
if(!this_player()->add_weight(2)) {
write("The bucket is too heavy. \n"+
"You drop a bucket.\n");
say(NAME+" drops a bucket.\n", this_player());
move_object(ob, this_object());
}
else {
write("You take the bucket.\n");
say(NAME+" takes a bucket.\n", this_player());
move_object(ob, this_player());
}
bucket = 0;
return 1;
}
if(str == "rope") {
if(!rope) {
notify_fail("There is no rope here.\n");
return 0;
}
if(tied_to_bucket) {
notify_fail("You can't. The rope is tied to the bucket.\n");
return 0;
}
if(tied_to_well) {
notify_fail("You can't. The rope is tied to the well.\n");
return 0;
}
write("You take the rope.\n");
move_object(clone_object("objects/rope"),this_player());
say(NAME+" takes a rope.\n", this_player());
return 1;
rope = 0;
}
return ::get_extra_object(str);
}