/
lib/banish/
lib/d/
lib/doc/
lib/doc/domains/
lib/doc/efun/
lib/doc/examples/
lib/doc/examples/armour/
lib/doc/examples/contain/
lib/doc/examples/food/
lib/doc/examples/magic/
lib/doc/examples/monster/
lib/doc/examples/room/
lib/doc/examples/weapons/
lib/include/
lib/include/fn_specs/
lib/include/skills/
lib/info/
lib/inherit/base/
lib/log/
lib/manuals/312/
lib/news/
lib/obj/party/
lib/objects/components/
lib/open/
lib/open/library/
lib/open/party/
lib/players/
lib/players/zilanthius/
lib/room/
lib/room/city/arena/
lib/room/city/creator/
lib/room/city/garden/monst/
lib/room/city/obj/
lib/room/city/shop/
lib/room/death/
lib/room/registry/
lib/secure/
lib/secure/UDP_CMD_DIR/
lib/skills/
lib/skills/fighter/
lib/skills/thief/
lib/usr/
lib/usr/creators/
lib/usr/players/
inherit "inherit/treasure";

void reset(status arg) {
  set_name("stethoscope");
  set_short("Stethoscope");
  set_long("The stethoscope has two tubes that plug into your ears.\n"+
           "Maybe you can apply it to something.\n");
  set_weight(1);
  set_value(15);
}
  

object listen_ob, player_ob;

void init() {
  add_action("apply", "apply");
  add_action("apply", "use");
}


status apply(string str) {
  string what;
  object ob;

  if(environment() != this_player()) {
    notify_fail("You have to get it first!\n");
    return 0;
  }
  if(!str) { 
    notify_fail("apply stethoscope to <item>\n");
    return 0;
  }
  if(sscanf(str, "stethoscope to %s", what) != 1) {
    notify_fail("apply stethoscope to what?\n");
    return 0;
  }
  if(!(ob = present(what, this_player()))) {
    if(!(ob = present(what, environment(this_player())))) {
      write("There is no "+ what +" here.\n");
      return 1;
    }
  }
  if(living(ob) || call_other(ob, "use_stethoscope", this_object())) {
    write("You listen to the " + what + ".\n");
    listen_ob = ob;
    player_ob = this_player();
    set_heart_beat(1);
    return 1;
  }
  notify_fail("You can't do that!\n");
  return 0;
}

/*
 * Detect if the player leaves the object.
 */

void heart_beat() {
  if(!(player_ob || listen_ob)) {
    set_heart_beat(0);
    return;
  }
  if(!present(listen_ob,environment(player_ob)) || environment() != player_ob) {
    listen_ob = 0;
    return;
  }
  if(living(listen_ob))  tell_object(player_ob, "Dunk dunk\n");
}

object query_listening() {
    return listen_ob;
}