/* This is the Monk/Psi Sub-Class skill advancement room.
 * Psionicist as a monk sub-class was originally developed by Zilanthius
 * in his AD&D campaign world of Ivory, and reproduced here for H7.
 * Psi. v1.0 Angel '96
 */
#include <mudlib.h>
#include <linewrap.h>
#define GUILD_OB		"skills/obj/monk"
#define GUILD_STR		"Brotherhood of the Mind"
#define VALID_PSI_POWER	"/skills/psionicist/valid"
inherit GUILD;
void reset(status arg) {
    if(!guild_master) {
     guild_master = clone_object(MONSTER);
     move_object(guild_master,this_object());
     guild_master->set_name("brother mind");
     guild_master->set_alias("brother");
     guild_master->set_alignment(1000);
     guild_master->set_short("Brother Mind");
     guild_master->set_long(
	"Brother Mind is a humble disciple of the order of Contemplation.    \n"+
	"He seeks inner peace, harmony, and above all enlightenment through  \n"+
	"the perfection of his mind, through intense training and discipline.\n"+
	"Brother Mind gladly teaches those who wish to follow his path. \n");
     guild_master->set_gender(1);
     guild_master->set_race("human");
     guild_master->set_level(10000);
     guild_master->add_class("fighter");
     guild_master->add_class("psionicist");
     guild_master->add_class("monk");
     guild_master->add_class("cleric");
     guild_master->load_a_chat(25,({ 
	"Brother Mind says: My mind is superior to your.\n",
	"Brother Mind says: Your weapons can not harm me.\n",
	"Brother Mind says: I shall destroy your body, then your mind.\n",
     }));
     guild_master->set_magic_resist(50);
    }
    if(arg) return;
    set_short("the halls of the brotherhood of the mind");
    set_long(
	);
    set_items(({
    }));
    set_weather(2, 1, 0);
    set_guild_name(GUILD_STR);
    set_exits(({
    }));
    set_races(({ "human", "grey elf", "high elf", "half elf",
      "gray elf", "dark elf", "gnome", "halfling", 
      "forest gnome", "deep gnome",
      "hill dwarf", "moutain dwarf",
    }));
    set_classes(({
     "general",        ({
       "climb", "swim",
     }),
     "primary",        ({
       "strength", "intelligence", "wisdom", "dexterity", 
       "combat",   "constitution", "charisma",
     }),
     "psionicist",        ({
	"clairsentient", "psychokinetic", "psychometabolic",
	"psychoportive", "telepathic", "metapsionic",
      }),
   }));
    set_exp(({
     0,       1014,    1522,    2283,    3425,    5138,
     7707,    11561,   17341,   26012,   39018,   58527,
     87791,   131687,  197530,  296296,  444444,  666666,
     1000000, 1500000, 2000000, 2500000, 3000000, 3500000,
     4000000, 4500000, 5000000, 5500000, 6000000, 6500000,
    }));
    set_skill_exp(({
     30,      50,      75,      100,     175,     250,
     400,     600,     900,     1200,    2000,    3000,
     4500,    6500,    10000,   15000,   20000,   30000,
     50000,   75000,   100000,  125000,  150000,  175000,
     200000,  225000,  250000,  275000,  300000,  325000,
    }));
    set_titles(({ 
     ({}), /* no neuter characters now but possible */
     /* male titles */ 
     ({
      }),
     /* female titles */
     ({
     }),
   }));
    /*** get a new pretitle one in four levels after 30 ***/
    set_pretitles(({
     ({}), /* no neuter pretitles */
     /* male pretitles */
     ({
     }),
     /* female pretitles */
     ({
     }),
   }));
}
void init() {
  if(guild_master) {
    object attacker;
    if((attacker = (object)guild_master->query_primary_attack())) {
      if(present(attacker, this_object())) {
        call_out("no_guild_mess",1,this_player());
        return;
      }
    }
  }
  if((string)this_player()->query_guild_string() ==
     (string)this_object()->query_guild_name()) {
     if(!present("guild_object", this_player()))
       move_object(clone_object(GUILD_OB),this_player());
  }
  add_action("train_mind", "learn");
  ::init();
}
void no_guild_mess(object ob) {
    tell_object(ob,"Brother Mind is busy defending himself.\n");
    tell_object(ob,"He is too busy to train anybody.\n");
}
status train_mind(string str) {
  int i, j;
  if((string)this_player()->query_guild_string() != GUILD_STR){
    notify_fail("Brother Mind says: Sorry, you can't train here.\n");
    return 0;
  }
  
  i = (int)this_player()->query_max_psp(); /* max skill pts for ab. */
  j = (int)this_player()->query_max_psi_skill_points();
  if((i-j) > 0) {
    this_player()->adj_psi_skill_points((i-j));
    this_player()->set_max_psi_skill_points(i);
  }
  if((int)this_player()->query_psi_skill_points()) {
    write("Brother Mind says: You still have skills of the mind to learn.  \n"+
	   "\tDo you wish to learn more? (press 'n' to learn a weapon skill)?\n"+
	   " (y/n) > ");
    input_to("train_mind2");
    return 1;
  }
  ::train_weapon(str);
  return 1;
}
status train_mind2(string str) {
  string *skills, tmp1, tmp2;
  
  skills = (string *)this_player()->query_all_psi_skills();
  if(!str || str == "" || str == "n") {
    writelw("\nBrother Mind says: Very well, perhaps you will like to train "+
	"your mind some other time.\n");
    return ::train_weapon(str);
  }
  write("\n\nBrother Mind says: There are many ways in which to improve "+
	"your mind.\n");
  if(sizeof(skills)) tmp1 = implode(skills, ", ");
  if(tmp1) {
    write("Brother Mind says: You already know the following psionic "+
    "skills: \n\n");
    writelw(tmp1+"\n");
  }
  else {
    write("Brother Mind says: You currently do not know any skills. \n");
    write("\n\tA devotion costs 1 pt to learn, a science 3 pts.\n"+
    "\tYou may learn as many, or as few skills, so long as you have \n"+
    "\tsome points remaining to spend.\n"+
    "\n\tYou should consult your help files to learn what powers are \n"+
    "\tavailable as once you learn a psionic power, you are unable \n"+
    "\tto change it.\n");
  }
  write("Brother Mind says: If you wish to learn more skills, type 'y'.\n"+
        " > ");
  input_to("train_mind3");
  return 1;
}
status train_mind3(string str) {
  if(!str || str == "" || str != "y") {
    write("Brother Mind says: Perhaps another time then.\n");
    return 1;
  }
  write("\n\nBrother Mind says: What new power can I teach you? \n"+
        "Write the name of the skill > ");
  input_to("train_mind4");
  return 1;
}
status train_mind4(string str) {
  int cost;
  if(!str || str == "") {
    write("Brother Mind asks: Perhaps another time then?\n");
    return 1;
  }
  if(this_player()->query_psi_skills(str)) {
    write("Brother Mind says: You already know that power. Choose another.\n"+
          " > ");
    input_to("train_mind4");
    return 1;
  }
  str = lower_case(str);
  if(!cost=VALID_PSI_POWER->valid_power(str)) {
    write("Brother Mind says: I can not teach you that power. Choose another.\n"+
          " > ");
    input_to("train_mind4");
    return 1;
  }
  if((int)this_player()->query_psi_skill_points() < cost) {
    write("Brother Mind says: It is not yet time for you to learn that power.\n"+
    "\tChoose another. > ");
    input_to("train_mind4");
    return 1;
  }
  this_player()->adj_psi_skill_points(-cost);
  this_player()->add_psi_skills(str);
  write("Brother Mind teaches you the power of "+str+"\n");
  write("Your mind feels stronger and enlightened.\n");
  return 1;
}
status leave(string str) {
  object obj;
  if(str != "psi" && str != "monk" && str != "psionicist") {
    write("Brother Mind says: Leave what?\n");
    return 1;
  }
  if(!this_player()->query_class("psi")) {
    write("Brother Mind says: Only members of the brotherhood of the mind \n\t"+
	"can stop their studies here.\n");
    return 1;
  }
  if(query_guild_name() != (string)this_player()->query_guild_string()) {
    write("Brother Mind says: Only the "+query_guild_name()+" can do that here.\n");
    return 1;
  }
  obj = present("guild_object", this_player());
  if(obj) destruct(obj);
  obj = this_player()->query_monk_aura_object();
  if(obj) destruct(obj);
  this_player()->save_me(1);
  ::leave(str);
  return 1;
}