inherit "obj/monster";
string master, short;
int follow_mode;
string what;
int fight;

reset(arg) {
 ::reset(arg);
 if(arg) return;
 set_level(50);
 set_exp(1);
 set_name("dragon");
 set_alias("dragon");
}

 // Maaritellaan masteri
string masteri() {
 master = "/wizards/rimber/test/room2.c"->master();
 tell_room(environment(this_player()), "Dragon booms: 'You called Master "+master+"?\n");
 short = master+"'s pet dragon";
 return master;
}  

short() { return short; }


long() { write("This is "+master+"'s pet dragon. Dragonmaster's usually command these beasts\n"+
 "simply saying what the beast must to do.\nWord 'help' will give you more instructions.\n");
}

 // Dragon's stats
query_str() { return 200; }
query_con() { return 200; }
query_dex() { return 100; }
query_wis() { return 150; }
query_int() { return 250; }
query_max_hp() { return 5000; }
query_hp() { return 5000; }
query_max_sp() { return 3000; }
query_sp() { return 3000; }
query_max_ep() { return 500; }
query_ep() { return 500; }

get() { return 0; }  // Ei mahu taskuun

init() {
 add_action("dragon", "dragon");
}


status dragon(string str) {
 if(!str) { write("Use 'dragon help' to see commands.\n");
  return 1;
 }
 if(str == "fight with me") {
  tell_room(environment(this_player()), "Dragon booms: 'As you wish Master.'\n");
 fight = 1;
  return 1;
 }
 if(str == "help") {
  write("Dragon's commands:\n 'follow' Makes dragon to follow "+
 "you.\n 'stay' makes it stop following.\n 'eat corpse' Dragon eats corpse.\n "+
 "'attack <target>' Makes dragon to attack given target.\n 'dismiss' The dragon "+
 "leaves.\n\n");
  return 1;
 }
 if(str == "follow") {
  tell_room(environment(this_player()), "Dragon booms: 'I will now follow you Master.'\n");
  follow_mode = 1;
  return 1;
 }
 if(str == "stay") {
  tell_room(environment(this_player()), "Dragon booms: 'I won't follow you now Master.'\n");
  follow_mode = 0;
  return 1;
 }
 if(str == "dismiss") {
 object mi = this_object();
 tell_room(environment(this_player()), "Dragon booms: 'If that's your command Master.\n");
 tell_room(environment(this_player()), "Dragon disappears.\n");
 destruct(mi);
 return 1;
 }
 else { write("Use 'dragon help' to see commands.\n");
 return 1;
 }
 return 1;
}

catch_tell(str) {
 string who, what, dir;
 object kuka;
 if(sscanf(str, "%s leaves %s.", who, dir) == 2) {
 kuka = find_player(lower_case(who));
 if(!kuka) { return 1; }
  if(follow_mode == 0) { return 1; }
 if(who != master) { return 1; }
 init_command(dir);
 }
 if(sscanf(str, "%s is in vigorous combat with %s", who, what) == 2) {
  who = find_player(lower_case(who));
if((lower_case(who) == master) && (fight == 1)) {
 object ob = present(lower_case(what), environment(this_object()));
  this_object()->attack_object(ob);
   }
 }
}

