inherit "obj/monster";
 
object fellow,grin;   
string fname,cname;
status fol,bur;
object store;
 
reset(arg) {
  ::reset(arg);
  if (arg) return;
  store=find_object("room/store");

  set_short("A little fighting dog");
  set_alias("dog");
  call_out("dest_me",5);
  set_alt_name("fighting dog");

  set_level(8);set_hp(140);set_wc(8); set_ep(4000); set_al(100);
  set_ac(6);set_aggressive(0);set_heart_beat(1);
  set_long("A little fighting dog, looking like a terrier 'type <help dog> to get more information\n");
  load_chat(2,({"WOV WOV WOF KLEFF KLEFF KLEFF\n"}));
  load_a_chat(20,({"GRRRRRR GRRRRR WOOOFF WOOFF\n"}));

}
 query_weight() { return 3; } 
init() {
 ::init();
 add_action("inspect", "inspect");
 add_action("pet", "pet"); 
 add_action("piss","piss");
 add_action("pet","stroke");
 add_action("help","help");
 add_action("name", "name");
}
help(str) {
if(str!="dog") return;
write("+++++++++++++++++++++++++++++++++++++++++++++++++++\n\n"+
      "          THE FIGHTING DOGS HELP/DIR:              \n\n"+
      "commands:                                          \n\n"+
      "get <fighting dog> and it is yours.                \n"+
      "name <fighing dog> to give it a name.              \n"+
      "drop <fighting dog> and it will follow you.        \n"+
      "kick <dog> and it will leave you.         \n"+
      "piss <name> and your dog will piss on the player.  \n\n"+ 
      "This dog helps you during your fights, but it isn't \n"+
      "very strong, therefore no help for high-level players.\n\n"+
      "+++++++++++++++++++++++++++++++++++++++++++++++++++\n");
return 1; }
 
get() {
if (!fol){ fellow=this_player();set_fellow();}  
return 1;
}
  dest_me() {
  if (fellow && fellow->query_linkdeath()) {
    destruct(this_object());
   return 1;
  }
   call_out("dest_me",400);
  }
catch_tell(str) {
string a,b;
object tmp;
  ::catch_tell(str);
  if (sscanf(str,"%s died.",a)==1) { call_out("eat", 3); return; }
  if (  (sscanf(str,"%s cuddles you.",a)==1)
      ||(sscanf(str,"%s fondles you.",a)==1)) {
    tmp=find_living(lower_case(a));
    if (tmp && !fol) { fellow=tmp; set_fellow(); }
    else call_out("purrr",1);
    return;
  }
  if (sscanf(str,"%s kicks you.   OUCH!!",a)==1) {
    tell_room(environment(), "The dog bites "+a+" under the belt JUMMI WOFF WOFF !!\n");
    if (fellow && a==fname) unset_fellow();
    return;
  }
}
 
purrr() { tell_object(fellow, "WOFF WOFF The dog licks your face.\n"); }
 
piss(arg) {
  object ob;
  if(!arg) {
    write("Your dog looks at you questinally.\n");
  return 1;
  }
  if (ob=present(arg,environment())) {
    if (fellow)
    tell_room(environment(),""+fname+"'s dog pisses on "+ob->query_name()+"'s foot !!!!\n");
  return 1;
  write("What ?\n");
  return 1;
 } 
 return 1;
}
 /* no munch
eat() {
object ob;
if (ob=present("corpse",environment())) {
      if (fellow) tell_room(environment(), capitalize(fellow->query_name())+
                                        "'s munches the corpse.\n");
      else tell_room(environment(), "The dog munches the corpse.\n");
      tell_room(environment(), "KLAEFF KLAEFF WUFF WUFF.\n");
      heal_self(random(80));
      destruct(ob);
      if (!bur) { bur=1; call_out("burp",5); }
      return 1;
  } else return 0;
}
   
  */ 

set_fellow() {
  fname=capitalize(fellow->query_name());
  set_name(fname+"'s fighting dog");
  set_long("It is a little terrier.\n");
  load_chat(1,({"WOFF WOFF !!!!\n"}));
  call_out("purrr",1);
  if (!fol) { fol=1; call_out("follow",7); }
}
 
name(str) {
string n;
  if (!str) return 0;
  if (sscanf(str, "fighting dog %s", n)!=1) return 0;
  if (this_player()!=fellow) {
    notify_fail("It is not your fighting dog !\n"); return 0;
  }
  cname=capitalize(n);
  set_name(cname+" ("+fname+"'s fighting dog)");
  set_alt_name(lower_case(n));
  set_long("It is a cute little fighting dog.\n");
  return 1;
}

follow() {
object ec, e;
  ec=environment();
  if (ec==store || !fellow) { unset_fellow(); return; }
  if (!living(ec) && !present(fellow)) {
    e=environment(fellow);
    move_player("", e);
 /*
    if (query_exp()>0) {
      fellow->add_exp(query_exp());
      set_ep(0);
    }
      */
    search();
  } else if (!living(ec)) {
   if ((e=fellow->query_attack()) && (e!=fellow) && (e!=this_object())) 
     attack_object(e);

   else { stop_fight(e);stop_fight(fellow);}

   if ((!living(ec)) && this_object()->query_hp()<=40) {
    write("Your dog hates that fight, it's enemie is too strong\n");
    move_object(this_object(),this_player());write("Your dog jumps into your arms\n");}
  }
  call_out("follow",7);
  }
 
  drop() { call_out("search",3); return 0; }
  search() { /* if (eat()) call_out("search",1); */ } 
  burp() {
  tell_room(environment(), fname+"'s dog barks happily.\n");
  bur=0;
  }
 
unset_fellow() {
  fellow=0;
  set_name("dog");
  set_short("A little fighting dog");
  set_alt_name("fighting dog");
  set_long("It is a cute fighting dog, looking like a terrier.\n");
  fol=0;
}
 
 inspect(str) {
   object ob;
   if (!str) { notify_fail("Inspect what?\n"); return 0; }
   if (ob=present(str,environment())) {
      if (fellow->query_hp() > ob->query_hp()) 
       tell_room(environment(),fname+"'s dog barks loudly.\n");
      else 
       tell_room(environment(),fname+"'s dog whines silently.\n");
    return 1;
    }
   write("Thats no living object.\n");
 return 1;
 }
 
 pet(str) {
  object tmp;

   if (!str) { notify_fail("Pet what?\n"); return 0; }
   if (present(str,environment())!=this_object()) return 0;
      tmp=this_player();
    if (tmp) say(tmp->query_name()+" "+query_verb()+"s fighting dog.\n",this_player());
    if (tmp && !fol) { fellow=tmp; set_fellow(); }
    else call_out("purrr",1);
   return 1;
 }
 
query_value() {
object env;
  store=find_object("room/store");
  env=environment();
  if (living(env)) {
    if (env!=fellow) return 0;
    env=environment(env);
  }
  if (find_object("room/main_shop")==env) return 50;
  else if (store==env) return 500;
  else return 0;
 }
 
query_real_name() {
  return query_name();
}
