nightmare3_fluffos_v2/
nightmare3_fluffos_v2/bin/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/ChangeLog.old/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/Win32/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/compat/simuls/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/clone/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/command/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/data/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/etc/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/include/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/inherit/master/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/log/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/compiler/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/efuns/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/single/tests/operators/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/testsuite/u/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/tmp/
nightmare3_fluffos_v2/fluffos-2.9-ds2.08/windows/
nightmare3_fluffos_v2/lib/cmds/ambassador/
nightmare3_fluffos_v2/lib/cmds/database/
nightmare3_fluffos_v2/lib/cmds/hm/
nightmare3_fluffos_v2/lib/cmds/soul/
nightmare3_fluffos_v2/lib/daemon/cfg/
nightmare3_fluffos_v2/lib/daemon/cfg/mon_races/
nightmare3_fluffos_v2/lib/daemon/cfg/races/
nightmare3_fluffos_v2/lib/daemon/include/
nightmare3_fluffos_v2/lib/daemon/save/
nightmare3_fluffos_v2/lib/daemon/services/
nightmare3_fluffos_v2/lib/daemon/soul/
nightmare3_fluffos_v2/lib/doc/
nightmare3_fluffos_v2/lib/doc/TestPlans/
nightmare3_fluffos_v2/lib/doc/approval/
nightmare3_fluffos_v2/lib/doc/approval/QC/
nightmare3_fluffos_v2/lib/doc/approval/balance/
nightmare3_fluffos_v2/lib/doc/build/
nightmare3_fluffos_v2/lib/doc/build/armours/
nightmare3_fluffos_v2/lib/doc/build/economy/
nightmare3_fluffos_v2/lib/doc/build/etc/
nightmare3_fluffos_v2/lib/doc/build/monster/
nightmare3_fluffos_v2/lib/doc/build/room/
nightmare3_fluffos_v2/lib/doc/build/virtual/
nightmare3_fluffos_v2/lib/doc/build/weapon/
nightmare3_fluffos_v2/lib/doc/classes/
nightmare3_fluffos_v2/lib/doc/efun/
nightmare3_fluffos_v2/lib/doc/etc/
nightmare3_fluffos_v2/lib/doc/help/creator/
nightmare3_fluffos_v2/lib/doc/help/hm/
nightmare3_fluffos_v2/lib/doc/law/
nightmare3_fluffos_v2/lib/doc/lpc/basic/
nightmare3_fluffos_v2/lib/doc/lpc/data_types/
nightmare3_fluffos_v2/lib/doc/lpc/etc/
nightmare3_fluffos_v2/lib/doc/lpc/intermediate/
nightmare3_fluffos_v2/lib/doc/lpc/types/
nightmare3_fluffos_v2/lib/doc/mudlib/
nightmare3_fluffos_v2/lib/doc/mudlib/features/
nightmare3_fluffos_v2/lib/domains/Examples/etc/
nightmare3_fluffos_v2/lib/domains/Examples/room/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaA/
nightmare3_fluffos_v2/lib/domains/Examples/virtual/exaB/
nightmare3_fluffos_v2/lib/domains/Examples/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/
nightmare3_fluffos_v2/lib/domains/Praxis/adm/
nightmare3_fluffos_v2/lib/domains/Praxis/attic/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/
nightmare3_fluffos_v2/lib/domains/Praxis/cemetary/mon/
nightmare3_fluffos_v2/lib/domains/Praxis/data/
nightmare3_fluffos_v2/lib/domains/Praxis/death/
nightmare3_fluffos_v2/lib/domains/Praxis/mountains/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/armour/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/magic/
nightmare3_fluffos_v2/lib/domains/Praxis/obj/weapon/
nightmare3_fluffos_v2/lib/domains/Praxis/orc_valley/
nightmare3_fluffos_v2/lib/domains/Praxis/quests/
nightmare3_fluffos_v2/lib/domains/Praxis/standardOld/
nightmare3_fluffos_v2/lib/include/
nightmare3_fluffos_v2/lib/log/
nightmare3_fluffos_v2/lib/log/errors/
nightmare3_fluffos_v2/lib/log/reports/
nightmare3_fluffos_v2/lib/log/watch/
nightmare3_fluffos_v2/lib/news/
nightmare3_fluffos_v2/lib/secure/cfg/
nightmare3_fluffos_v2/lib/secure/cmds/ambassador/
nightmare3_fluffos_v2/lib/secure/cmds/mortal/
nightmare3_fluffos_v2/lib/secure/save/users/d/
nightmare3_fluffos_v2/lib/secure/std/
nightmare3_fluffos_v2/lib/std/hm/
nightmare3_fluffos_v2/lib/std/living/
nightmare3_fluffos_v2/lib/std/room/
nightmare3_fluffos_v2/lib/std/user/
nightmare3_fluffos_v2/lib/std/virtual/
nightmare3_fluffos_v2/lib/www/
nightmare3_fluffos_v2/lib/www/errors/
nightmare3_fluffos_v2/lib/www/gateways/
nightmare3_fluffos_v2/win32/
#include <daemons.h>

inherit "std/room";

#define COST    money/bonus
#define MAX_DONATION 600

mapping blood;

void init() {
    ::init();
    add_action("new_body", "renew");
    add_action("clean_poison", "clean");
    add_action("regenerate", "regenerate");
    add_action("read", "read");
    add_action("donate", "donate");
    add_action("transfuse", "transfuse");
}

void create() {
    seteuid(getuid());
    set_property("light", 2);
    set_property("indoors", 1);
    set_short("Cleric's Hospital of Praxis");
    set_long(
	"You are in the local hospital run by the town's clerics.\n"+
	"Here they specialize in the regeneration of lost limbs.\n"+
	"A list of all services they perform is posted on the wall.\n"
    );
    set_item_descriptions(
	({
	"list", "hospital", "clerics", "cleric"
	}),
	({
	"You can read all the services by typing <read list>.\n",
	"The clerics here specialize in regenerating lost limbs.\n",
	"They are mending the wounds of patients.\n",
	"He is mending a patient's wounds.\n"
	})
    );
    set_exits( ([
      	"east"	 : 	"/domains/Praxis/n_centre2"	,
      ]) );
    blood = ([ "who": ([]), "hp":200, "mp":200 ]);
    set_property("no teleport", 1);
}

int new_body(string str) {
    object *inv;
    int i;


    if( (int)this_player()->query_level() != 1) {
	notify_fail("The clerics only perform this service for the inexperienced.\n");
	return 0;
    }
    inv = all_inventory(this_player());
    for(i=0; i<sizeof(inv); i++) {
	inv[i]->unequip();
    }
    write("A cleric comes over to you and mutters a small prayer.\n");
    write("You again have the all the limbs you were born with!\n");
    say("A cleric mutters a small prayer for the novice "+this_player()->query_cap_name()+".\n", this_player());
    this_player()->new_body();
    return 1;
}

int read(string str) {
    if(!str) {
	notify_fail("Read what?\n");
	return 0;
    }
    if(str != "list") {
	notify_fail("That is not here for reading.\n");
	return 0;
    }
    write("Welcome to the Cleric's Hospital of Praxis!\n"+
	"The clerics perform the following services:\n"+
	"------------------------------------------------------------------\n"+
	"<renew body>: This is a charity service the clerics perform for\n"+
	"	novice adventurers who have lost limbs while adventuring.\n"+
	"	All limbs are replaced.\n\n"+
	"<regenerate [limb]>: This service is for the experienced adventurer\n"+
	"	who has lost limbs.  The limb is replaced and acts like new.\n"+
	"	Tithe schedule for regeneration:\n"+
	"               hands and feet-     400 gold\n");
    write("               arms and legs-      600 gold\n"+
	"<clean poison>: Helps remove some of the poison from your body.\n"+
	"\ttithe: 50 gold\n"+
	"<donate # (hp or mp) of blood>: Donates some of your blood in\n"+
	"\texchange for gold.\n"+
	"<transfuse # (hp or mp)>: Transfuse some blood int hp or mp into your body\n"+
	"\ttithe: amount * 3 gold coins.\n"+
	"Currently: "+blood["hp"]+" hp blood and "+blood["mp"]+" mp blood free.\n"+
	"------------------------------------------------------------------\n"+
        "Half off all regenerations with the severed limb!\n"+
 	"Your tithe is used only toward good causes.\n");
    return 1;
}

int clean_poison(string str) {
    object tp;

    if(!str) return 0;
    if(str != "poison") return 0;
    tp = this_player();
    if((int)tp->query_poisoning()<1) {
	notify_fail("A cleric whispers to you: But you are not poisoned!\n");
	return 0;
    }
    if((int)tp->query_money("gold") < 50) {
	notify_fail("You do not have enough gold for the tithe.\n");
	return 0;
    }
    tp->add_money("gold", -50);
    tp->add_poisoning(-10);
    write("A cleric casts a spell of healing upon you.\n");
    say("A cleric casts a spell of healing on "+tp->query_cap_name()+".\n", tp);
    return 1;
}

int regenerate(string limb) {
    int money, bonus;
    mapping limb_info;
    object tp;
    string *there, *missing;

    tp = this_player();
    if(present(limb, this_player())) bonus = 2;
    else bonus = 1;
    there = (string *)tp->query_limbs();
    missing = (string *)this_player()->query_severed_limbs() +
      (string *)RACE_D->query_limbs((string)this_player()->query_race());
/*
   checking with the race_d is allowing compatibility with old
   versions of the mudlib
*/
    if(!missing) {
	notify_fail("You aren't missing any limbs!\n");
	return 0;
    }
    if(member_array(limb, missing) == -1) {
	notify_fail("You are not missing that limb!\n");
	return 0;
    }
    if(member_array(limb, there) != -1) {
	notify_fail("You already have that one back!\n");
	return 0;
    }
    limb_info= (mapping)RACE_D->query_limb_info(limb,(string)tp->query_race());
    if(!limb_info) {
        notify_fail("That limb cannot be replaced!\n");
        return 0;
    }
    if(limb_info["ref"] != "") {
        if(member_array(limb_info["ref"], there) == -1) {
            notify_fail("You would need a "+limb_info["ref"]+" for that!\n");
	    return 0;
	}
    }
    if((string)this_player()->query_class() == "cleric") money = 1200;
    else money = 1600;
    money = money / limb_info["max"];
    if((int)tp->query_money("gold") < COST) {
	notify_fail("The cleric tells you:  You do not have enough gold.\n");
	return 0;
    }
    tp->add_limb(limb, limb_info["ref"], (int)tp->query_max_hp()/limb_info["max"], 0, 0);
    if(member_array(limb, (string *)RACE_D->query_wielding_limbs((string)tp->qyery_race())) != -1) 
        tp->add_wielding_limb(limb);
	tp->add_money("gold", -COST);
    if(limb == "left hand") {
	if(member_array("left arm", there) == -1) {
	    notify_fail("You would need a left arm for that!\n");
	    return 0;
	}
        money = 400;
	if((int)tp->query_money("gold") < COST) {
	    notify_fail("The cleric tells you: You do not have enough gold for that.\n");
	    return 0;
	}
	tp->add_limb(limb, "", (int)tp->query_max_hp()/4, 0, 0);
        tp->add_wielding_limb(limb);
	tp->add_money("gold", -COST);
    }
    else if(limb == "left foot" || limb == "right foot") {
        money = 400;
        if((int)tp->query_money("gold") < COST) {
            notify_fail("The cleric says: You don't have enough gold for the tithe.\n");
            return 0;
        }
        if( (limb == "left foot" && member_array("left leg", there) == -1) || (limb == "right foot" && member_array("right leg", there) == -1) ) {
            notify_fail("You need a limb to attatch it to!\n");
            return 0;
        }
        tp->add_limb(limb, "", (int)tp->query_max_hp()/4, 0, 0);
        tp->add_money("gold", -COST);
    }
    else if(limb == "left arm" || limb == "left leg" || limb == "right arm" || limb == "right leg") {
        money = 600;
	if((int)tp->query_money("gold") < COST) {
	    notify_fail("The cleric tells you:  You do not have enough gold for the tithe.\n");
	    return 0;
	}
	if(limb == "left arm") tp->add_limb(limb, "left hand", (int)tp->query_max_hp()/3, 0, 0);
        else if(limb == "left leg") tp->add_limb(limb, "left foot", (int)tp->query_max_hp()/3, 0, 0);
        else if(limb == "right leg") tp->add_limb(limb, "right foot", (int)tp->query_max_hp()/3, 0, 0);
	else tp->add_limb(limb, "right hand", (int)tp->query_max_hp()/3, 0, 0);
	tp->add_money("gold", -COST);
    }
    else {
	write("The cleric says: Sorry, but we do not have the ability to do that.\n");
	say("A cleric looks sadly at "+tp->query_cap_name()+".\n", tp);
	return 1;
    }
    say(tp->query_cap_name()+" asks the clerics for some help with "+tp->query_possessive()+" missing "+limb+".\n", tp);
    write("The clerics restore your "+limb+"!\n");
    return 1;
}

int donate(string str) {
    string what;
    int amount, tmp;
 
    if(!str) {
	notify_fail("Donate what?\n");
	return 0;
    }
    if(sscanf(str, "%d %s of blood", amount, what) !=2) {
	notify_fail("Correct syntax: <donate [#] [hp | mp] of blood>\n");
	return 0;
    }
    if(what != "mp" && what != "hp") {
	notify_fail("Donate what?\n");
	return 0;
    }
    if(blood[(string)this_player()->query_name()]+amount > MAX_DONATION) {
	write("You will have to wait before giving that much blood.\n");
	return 1;
    }
    tmp = (int)call_other(this_player(), "query_"+what);
    if(tmp < amount + 5) {
	notify_fail("You must have at least 5 more than you plan to give!\n");
	return 0;
    }
    call_other(this_player(), "add_"+what, -amount);
    this_player()->add_money("gold", amount/2);
    blood[what] += amount;
    blood["who"][(string)this_player()->query_name()] += amount;
    write("You donate some blood for "+(amount/2)+" gold coins.\n");
    say(this_player()->query_cap_name()+" donates some blood for some gold.\n", this_player());
    call_out("reduce_donation", 900, ({ this_player(), amount }));
    return 1;
}

int transfuse(string str) {
    string what;
    int amount;

    if(!str) {
	notify_fail("Transfuse what?\n");
	return 0;
    }
    if(sscanf(str, "%d %s", amount, what) != 2) {
	notify_fail("Correct syntax: <transfuse [#] [mp | hp]>\n");
	return 0;
    }
    if(what != "hp" && what != "mp") {
	notify_fail("You cannot do that!\n");
	return 0;
    }
    if(amount < 1) {
        notify_fail("Are you crazy?!?\n");
        return 0;
    }
    if(blood[what] < amount) {
	notify_fail("We do not have that much blood in right now.\n");
	return 0;
    }
    if((int)this_player()->query_money("gold") < amount*3) {
	notify_fail("You do not have enough gold for the tithe.\n");
	return 0;
    }
    this_player()->add_money("gold", -(amount*3));
    call_other(this_player(), "add_"+what, amount);
    write("You receive a blood transfusion\n");
    say(this_player()->query_cap_name()+" receives a blood transfusion.\n", this_player());
    return 1;
}

void reduce_donation(mixed *tmp) {
    blood["who"][tmp[0]] -= tmp[1];
    if(blood["who"][tmp[0]] < 1) map_delete(blood, tmp[0]);
}