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>
#include <daemons.h>

inherit LIB_LEADER;
int JoinGuild(object ob, string verb, string what);
int TeachSpell(object who, string verb, string spell);

string *spells;
mapping AvailableSpells;

int WieldStaff(){
    if(!present("staff",this_object())){
	new("/domains/town/weap/leostaff")->eventMove(this_object());
	tell_room(environment(),"Herkimer claps his hands and a large "+
	  "wooden staff materializes.");
	this_object()->eventForce("wield staff");
	this_object()->eventForce("say you poor fool!");
	this_object()->eventForce("cast buffer");
    }
    return 1;
}

static void create() {
    leader::create();
    SetKeyName("herkimer");
    SetId(({"archwizard","wizard","herkermer","herkirmer"}));
    SetAdjectives(({"old","gentle","kindly"}));
    SetShort("Herkimer the kind wizard");
    SetLong("This kindly old wizard is the master of the "+
      "local magic shop, which doubles as the Mages' Guild. "+
      "You can ask Herkimer to teach you a spell, and if "+
      "you're capable of learning it, he will teach you, "+
      "for a fee. His penetrating blue eyes seem to "+
      "see right through you, but the smile from beneath "+
      "his white beard is reassuring.");
    SetLevel(300);
    SetUnique(0);
    SetRace("human");
    SetGender("male");
    SetClass("mage");
    SetInventory(([
	"/domains/town/armor/robe":"wear robe",
	"/domains/town/armor/wizard_hat":"wear hat",

      ]));
    SetSpellBook( ([ "buffer" : 100, "meditate" : 100, "missile" : 100, "fireball" : 100 ]) );
    SetAction(25, ({
	"Herkimer scratches his beard thoughtfully.",
	"Herkimer seems to be trying to remember something.", "Herkimer ponders.",
	"Herkimer thinks.", "Herkimer thinks carefully.",
	"Herkimer says, \"%^BOLD%^CYAN%^You don't have to be a mage to learn a spell, but it sure helps.%^RESET%^\"",
	"Herkimer says, \"%^BOLD%^CYAN%^The more you use your magic skills, the more proficient you become.%^RESET%^\"",
	"Herkimer says, \"%^BOLD%^CYAN%^Casting spells costs you mana points. Make sure you don't run out unexpectedly!%^RESET%^\"",
	"Herkimer says, \"%^BOLD%^CYAN%^If you join us and then leave the guild, you will not be alowed to become a mage again.%^RESET%^\"",
	"Herkimer says, \"%^BOLD%^CYAN%^Some spells require total concentration. If you move or if you are attacked, it may interrupt the casting.%^RESET%^\"",
	"Herkimer says, \"%^BOLD%^CYAN%^All magical training is free of charge to guild members, of course.%^RESET%^\"",
      }));
    SetCombatAction(50, ({ (: WieldStaff :), "say what is your deal?",
	"say don't make me destroy you","cast fireball", "cast missile", "cast buffer"}) );
    SetCommandResponses( ([
	"join": (: JoinGuild :),
	"teach" : (: TeachSpell :),
	"learn" : "I have much to learn, young one, but not from you.",
      ]) );
    AvailableSpells = ( ([
	"fireball" : 1000,
	"missile" : 500,
	"buffer" : 200,
	"meditate" : 500,
	"inner strength" : 500,
      ]) );
}

void init(){
    string key;
    int val;
    ::init();
    spells = ({});
    foreach(key,val in AvailableSpells){
	spells += ({ key });
    }
}

int JoinGuild(object ob, string verb, string what){
    if(ob->GetClass() == "mage") {
	eventForce("say You're already in, doofus.");
	return 1;
    }
    eventForce("say Hmm...want to join our guild, do you?");

    if(!this_player()->GetQuest("Orc Slayer Quest")){
	eventForce("say First you must prove yourself worthy. Help my brother Leo find the Orcslayer and I will happily welcome you into our family. Until then, you may not join the mages.");
	return 1;
    }
    if(ob->GetClass() == "explorer" || !ob->GetClass()){
	eventForce("say very well, "+ob->GetName()+".");
	eventForce("say Welcome to the mages' guild! You are now officially a mage. You must practice your magic often, since you are now physically weaker than before. The stronger your magic, the stronger you are!");
	ob->ChangeClass("mage");
	eventForce("say you have been demoted to a Level 1 player. However, you still retain your experience and your questing history, so just ask Dirk to promote you again a few times.");
	return 1;
    }
    eventForce("say I'm sorry, it looks to me like you have already chosen your specialty. As a member of the Guildmasters' Guild, I am forbidden from removing you from the "+capitalize(ob->GetClass())+"'s Guild.");
    return 1;
}

int TeachSpell(object who, string verb, string spell){
    int cost, onhand;
    mapping myspells;
    if(!spell || spell == ""){
	eventForce("say Please ask again, but this time specify the spell you'd like to learn.");
	return 1;
    }
    if(!SPELLS_D->GetSpell(spell)){
	eventForce("say I'm sorry, that is not a spell I can teach you.");
	return 1;
    }
    if(member_array(spell,spells) == -1){
	eventForce("say That spell is not available right now.");
	eventForce("say The spells I can teach you are "+implode(spells,", ")+".");
	return 1;
    }
    myspells = who->GetSpellBook();
    if(myspells[spell]){
	eventForce("say You already know that spell.");
	return 1;
    }
    cost = AvailableSpells[spell];
    onhand = who->GetCurrency("silver");
    if(who->GetClass() != "mage" && onhand < cost) {
	eventForce("say You lack enough silver coins to pay for that spell.");
	eventForce("say "+spell+" costs "+cost+" silver and you "+
	  "only have "+onhand+".");
	eventForce("say I can only accept silver. It's a magic thing. If you want, you can try to exchange your other currency for silver at the bank across the street.");
	return 1;
    }
    tell_room(environment(this_object()),"Herkimer closes his eyes, mutters under his breath, and waves his hands.");
    if(!who->eventLearnSpell(spell)){
	eventForce("shake");
	eventForce("say You do not appear capable of learning that spell right now.");
	return 1;
    }
    eventForce("smile");
    eventForce("say Congratulations. You now possess the mystical knowledge of the "+spell+" spell. Use it wisely.");
    if(who->GetClass() != "mage") who->AddCurrency("silver",-cost);
    return 1;
}

int eventReceiveObject() {
    object ob, player;
    ob = previous_object();
    player = this_player();

    if( !ob || !::eventReceiveObject() ) return 0;
    if( ob->GetKeyName() == "orc slayer" ) {
	eventForce("say I'm sorry, you've got the wrong archwizard.");
	eventForce("say You're looking for Leo. His workroom is the church basement.");
	eventForce("give orcslayer to "+this_player()->GetKeyName());
	return 1;
    }

    AddCarriedMass((int)ob->GetMass());
    return 1;
}