dsIIr4/bin/
dsIIr4/extra/creremote/
dsIIr4/extra/wolfpaw/
dsIIr4/lib/cmds/admins/
dsIIr4/lib/cmds/common/
dsIIr4/lib/cmds/creators/include/
dsIIr4/lib/cmds/creators/include/SCCS/
dsIIr4/lib/daemon/services/
dsIIr4/lib/doc/
dsIIr4/lib/domains/Ylsrim/
dsIIr4/lib/domains/Ylsrim/adm/
dsIIr4/lib/domains/Ylsrim/armor/
dsIIr4/lib/domains/Ylsrim/broken/
dsIIr4/lib/domains/Ylsrim/fish/
dsIIr4/lib/domains/Ylsrim/meal/
dsIIr4/lib/domains/Ylsrim/npc/
dsIIr4/lib/domains/Ylsrim/virtual/
dsIIr4/lib/domains/Ylsrim/weapon/
dsIIr4/lib/domains/campus/adm/
dsIIr4/lib/domains/campus/etc/
dsIIr4/lib/domains/campus/meals/
dsIIr4/lib/domains/campus/npc/
dsIIr4/lib/domains/campus/save/
dsIIr4/lib/domains/campus/txt/
dsIIr4/lib/domains/campus/txt/ai/charles/
dsIIr4/lib/domains/campus/txt/ai/charles/bak2/
dsIIr4/lib/domains/campus/txt/ai/charles/bak2/bak1/
dsIIr4/lib/domains/campus/txt/ai/charly/
dsIIr4/lib/domains/campus/txt/ai/charly/bak/
dsIIr4/lib/domains/campus/txt/jenny/
dsIIr4/lib/domains/default/creator/
dsIIr4/lib/domains/default/doors/
dsIIr4/lib/domains/default/etc/
dsIIr4/lib/domains/default/virtual/
dsIIr4/lib/domains/default/weap/
dsIIr4/lib/domains/town/virtual/
dsIIr4/lib/lib/comp/
dsIIr4/lib/lib/lvs/
dsIIr4/lib/lib/user/
dsIIr4/lib/lib/virtual/
dsIIr4/lib/log/
dsIIr4/lib/obj/book_source/
dsIIr4/lib/obj/include/
dsIIr4/lib/realms/template/
dsIIr4/lib/realms/template/adm/
dsIIr4/lib/realms/template/area/armor/
dsIIr4/lib/realms/template/area/npc/
dsIIr4/lib/realms/template/area/obj/
dsIIr4/lib/realms/template/area/room/
dsIIr4/lib/realms/template/area/weap/
dsIIr4/lib/realms/template/bak/
dsIIr4/lib/realms/template/cmds/
dsIIr4/lib/save/
dsIIr4/lib/save/kills/o/
dsIIr4/lib/secure/cfg/classes/
dsIIr4/lib/secure/cmds/creators/include/
dsIIr4/lib/secure/cmds/players/
dsIIr4/lib/secure/cmds/players/include/
dsIIr4/lib/secure/daemon/include/
dsIIr4/lib/secure/lib/
dsIIr4/lib/secure/lib/include/
dsIIr4/lib/secure/lib/net/include/
dsIIr4/lib/secure/lib/std/
dsIIr4/lib/secure/modules/
dsIIr4/lib/secure/npc/
dsIIr4/lib/secure/obj/include/
dsIIr4/lib/secure/room/
dsIIr4/lib/secure/save/
dsIIr4/lib/secure/save/boards/
dsIIr4/lib/secure/save/players/g/
dsIIr4/lib/secure/tmp/
dsIIr4/lib/secure/verbs/creators/
dsIIr4/lib/shadows/
dsIIr4/lib/spells/
dsIIr4/lib/std/board/
dsIIr4/lib/std/lib/
dsIIr4/lib/tmp/
dsIIr4/lib/verbs/admins/include/
dsIIr4/lib/verbs/common/
dsIIr4/lib/verbs/common/include/
dsIIr4/lib/verbs/creators/include/
dsIIr4/lib/verbs/players/include/SCCS/
dsIIr4/lib/verbs/rooms/
dsIIr4/lib/verbs/rooms/include/
dsIIr4/lib/www/
dsIIr4/v22.2b14-dsouls2/
dsIIr4/v22.2b14-dsouls2/ChangeLog.old/
dsIIr4/v22.2b14-dsouls2/Win32/
dsIIr4/v22.2b14-dsouls2/compat/
dsIIr4/v22.2b14-dsouls2/compat/simuls/
dsIIr4/v22.2b14-dsouls2/include/
dsIIr4/v22.2b14-dsouls2/mudlib/
dsIIr4/v22.2b14-dsouls2/testsuite/
dsIIr4/v22.2b14-dsouls2/testsuite/clone/
dsIIr4/v22.2b14-dsouls2/testsuite/command/
dsIIr4/v22.2b14-dsouls2/testsuite/data/
dsIIr4/v22.2b14-dsouls2/testsuite/etc/
dsIIr4/v22.2b14-dsouls2/testsuite/include/
dsIIr4/v22.2b14-dsouls2/testsuite/inherit/
dsIIr4/v22.2b14-dsouls2/testsuite/inherit/master/
dsIIr4/v22.2b14-dsouls2/testsuite/log/
dsIIr4/v22.2b14-dsouls2/testsuite/single/
dsIIr4/v22.2b14-dsouls2/testsuite/single/tests/compiler/
dsIIr4/v22.2b14-dsouls2/testsuite/single/tests/efuns/
dsIIr4/v22.2b14-dsouls2/testsuite/single/tests/operators/
dsIIr4/v22.2b14-dsouls2/testsuite/u/
dsIIr4/v22.2b14-dsouls2/tmp/
dsIIr4/win32/
#include <lib.h>

inherit LIB_NPC;

object *slips;
int busy;

static void create() {
    npc::create();
    SetKeyName("clepius");
    SetId(({"clepius","doctor","healer"}));
    SetAdjectives(({"a.s.", "A.S.", "doctor","dr","Dr.","dr."}));
    SetShort("Clepius the healer");
    SetLong("Clepius is a kindly old man, legendary for his "
      "nearly superhuman powers of healing. He is even "
      "rumored capable of resurrecting the dead. He runs "
      "a medical care service in town, and can be asked to "
      "help when needed, though his help is not free.");
    SetLevel(50);
    SetRace("human");
    SetClass("mage");
    SetGender("male");
    SetInventory(([
	"/domains/town/weap/rod":1,
	"/domains/town/obj/medbag":1,
	"/domains/town/armor/toga":"wear toga",
      ]) );
    slips = ({});
    busy=0;
}

int CanReceive() {
    if(present("healer token", this_object())){
	return 0;
    }

    eventForce("nod");
    set_heart_beat(1);
    return 1;
}

int CheckBag(){
    object bag,slip;
    string player, problem;
    slip = present("healer token", this_object());
    if(!slip && busy == 1) {
	eventForce("say That's a bit odd...\n\n");
	eventForce("I'm sorry but I must have misplaced your slip. Do you have another one?");
	busy = 0;
	return 1;
    }
    if(slip){
	busy = 1;
	eventForce("say mmhmmm...");
	problem = slip->GetProperty("problem");
	player = slip->GetPatient();
	this_object()->DiagPatient(player,problem);
    }
    return 1;
}

void heart_beat(){
    if(busy == 0 && present("healer token", this_object())){
    }

    this_object()->CheckBag();
}

int ejectRabble(string str){
    object *riffraff,patient;
    environment()->SetProperty("busy",1);
    riffraff = get_livings(environment(this_object()));
    if(! patient = present(str,environment(this_object())) ){
	patient = find_player(str);
    }
    foreach(object bum in riffraff){
	if( bum->GetKeyName() != patient->GetKeyName() &&
	  bum->GetKeyName() != "clepius" ){
	    tell_object(bum,"The doctor ejects you from his office in order to "+
	      "treat "+patient->GetName()+".\n\n");
	    bum->eventMoveLiving("/domains/town/room/healer");
	    tell_object(patient,"The doctor ejects "+bum->GetName()+" from "+
	      "his office in order to treat you.");
	}
    }
    return 1;
}

int NextPatient(){
    eventForce("put my first slip in bin");
    environment()->SetProperty("busy",0);
    tell_room(load_object("/domains/town/room/healer"),"From the back room "+
      "you hear the doctor holler: \"%^BOLD%^CYAN%^NEXT!%^RESET%^\"");
    tell_room(environment(),"The doctor leans into the east doorway "+
      "and hollers: \"%^BOLD%^CYAN%^NEXT!%^RESET%^\"");
    busy = 0;
    environment()->SetProperty("busy",0);
    return 1;

}

int PerformHeal(string dude){
    object person;
    int hp,mhp;
    person = present(dude,environment());
    if(!person) {
	eventForce("look");
	eventForce("shrug");
	return 1;
    }
    eventForce("say All right...let's take a look at you.");
    hp = person->GetHealthPoints();
    mhp = person->GetMaxHealthPoints()-10;
    if(hp > mhp){
	eventForce("say You look fine to me. Take back your slip and save it for when you really need it.");
	eventForce("give my first slip to "+dude);
	return 1;
    }
    if(present("clepius mojo",person)){
	eventForce("say You already have salve on you. Give it a chance to work, then come back later.");
	eventForce("give my first slip to "+dude);
	return 1;
    }
    eventForce("say Yes, you can use a little help.");
    tell_room(environment(),"Clepius vigorously rubs a healing salve onto your body. You can feel it enhancing your body's recovery.");
    new("/secure/obj/mojo")->eventMove(person);
    return 1;
}

int PerformRegenerate(string dude){
    int i;
    mapping stumps;
    object person;
    person = present(dude,environment());
    stumps=person->GetMissingLimbs();

    eventForce("say Let's count limbs, then. Hmmmm...");

    if(!sizeof(stumps)) {
	eventForce("say You are not missing any limbs. Go sell this slip back to James.");
	eventForce("give my first slip to "+dude);
	return 1;
    }
    for(i=0;i<sizeof(stumps);i++){
	person->RestoreLimb(stumps[i]);
	tell_object(person,"The doctor regenerates your "+stumps[i]+".");
	return 1;
    }
}

int PerformExcision(string dude){
    string what,whom;
    object person,thing,slug;
    int rifleshot_wounds,firearms_wounds,wounds;

    person = present(dude,environment(this_object()));
    slug=present("firearms_wound",person);
    wounds=0;
    wounds=person->GetLead("gunshot_wounds");
    wounds+=person->GetLead("rifleshot_wounds");
    if(!slug){
	eventForce("say You have no foreign bodies.");
	eventForce("give my first slip to "+dude);
	return 1;
    }

    tell_room(environment(this_object()),"Clepius deftly extracts a lead slug from "+ dude+".", ({person}));
    tell_object(person,"Clepius deftly extracts a lead slug from your body.");
    firearms_wounds=person->GetLead("firearms_wounds");
    rifleshot_wounds=person->GetLead("rifleshot_wounds");
    firearms_wounds=person->GetLead("firearms_wounds");
    rifleshot_wounds=person->GetLead("rifleshot_wounds");
    slug=new("/domains/town/obj/spent");
    if(person->GetLead("gunshot_wounds") > 0) {
	person->AddLead("gunshot_wounds", -1);
	slug->SetShort("a spent pistol slug");
	--wounds;
	slug->eventMove(this_object());
	if(person->GetLead() < 1){                                         
	    slug=present("firearms_wound",person);
	    if(slug) slug->eventDestruct();
	    return 1;
	}
	return 1;
    }
    if(person->GetLead("rifleshot_wounds") > 0){                                 
	person->AddLead("rifleshot_wounds", -1);
	slug->SetShort("a spent rifle slug");                                 
	--wounds;
	slug->eventMove(this_object());                                 
	if(person->GetLead() < 1){
	    if(slug) slug->eventDestruct();
	    slug=present("firearms_wound",person);
	    if(slug) slug->eventDestruct();
	    return 1;
	}
    }
    slug->eventMove(this_object());
    slug=present("firearms_wound",person);
    if(wounds < 1 && slug){                                 
	slug->eventDestruct();
	return 1;                         
    }

    return 1;
}

int DiagPatient(string dude, string problem){
    if(!present(dude,environment())) {
	NextPatient();
	return 1;
    }

    ejectRabble(dude);

    if(problem == "regenerate") {
	PerformRegenerate(dude);
	NextPatient();
	return 1;
    }

    if(problem == "heal"){
	PerformHeal(dude);
	NextPatient();
	return 1;
    }

    if(problem == "excision"){
	PerformExcision(dude);
	NextPatient();
	return 1;
    }

}