#include <lib.h>
inherit LIB_ITEM;
inherit LIB_PRESS;

int check_environs();
int vanish_count;
static void create() {
    item::create();
    SetKeyName("omni");
    SetId(({"omni","Omni","device"}));
    SetShort("an omni");
    SetLong("This is a small, round metal device, copper in color, "+
      "and similar in appearance to a pocket watch. There is a blinking red light "+
      "next to the tiny metal button at its top.");
    SetMass(10);
    SetDollarCost(300);
    AddItem("button", "A button on the omni.");
}
void init() {
    ::init();
    vanish_count=500;
    check_environs();
}
mixed CanPress(object who, string target) {
    if(!present(this_object()->GetKeyName(),who ) && target == "button"){
	return "You do not have the Omni!";
    }
    if(this_object()->GetId() == target){
	return "You cannot push that.";
    }
    return 1;
}
mixed eventPress(object who, string target) {
    say(this_player()->GetName()+" turns multicolored and disappears.\n");
    write("You feel momentarily disoriented and find yourself back in the lab.\n");
    this_player()->eventMove("/domains/campus/room/u_lab");
    this_player()->eventForce("look");
    return 1;
}
void heart_beat(){
    vanish_count--;
    if(vanish_count < 0){
	tell_object(environment(),"The omni glows brightly and disappears!");
	this_object()->eventDestruct();
    }
    if(vanish_count == 5){
	tell_object(environment(),"The omni begins to glow a dull red.");
	this_object()->SetLong("This is a small, round metal device, copper in color, "+
	  "and similar in appearance to a pocket watch. There is a blinking red light "+
	  "next to the tiny metal button at its top. It is glowing a dull red.");
	this_object()->SetShort("an omni (glowing)");
    }
}
int check_environs(){
    if( interactive(environment()) ){
	set_heart_beat(1);
	return 1;
    }
    return 1;
}
