/
LIB3/
LIB3/D/ADMIN/
LIB3/D/ADMIN/OBJ/
LIB3/D/ADMIN/ROOM/W/
LIB3/D/HOME/
LIB3/D/HOME/CITY/ARENA/
LIB3/D/HOME/CITY/ITEMS/
LIB3/D/HOME/CITY/POSTOFFI/
LIB3/DOC/
LIB3/GLOBAL/SPECIAL/
LIB3/GLOBAL/VIRTUAL/
LIB3/NET/
LIB3/NET/CONFIG/
LIB3/NET/DAEMON/CHARS/
LIB3/NET/GOPHER/
LIB3/NET/INHERIT/
LIB3/NET/OBJ/
LIB3/NET/SAVE/
LIB3/NET/VIRTUAL/
LIB3/OBJ/B_DAY/
LIB3/OBJ/HANDLERS/TERM_TYP/
LIB3/PLAYERS/B/
LIB3/PLAYERS/N/
LIB3/ROOM/
LIB3/SAVE/
LIB3/SAVE/BOARDS/
LIB3/SAVE/ENVIRON/
LIB3/SAVE/POST/
LIB3/STD/COMMANDS/SHADOWS/
LIB3/STD/CREATOR/
LIB3/STD/DOM/
LIB3/STD/EFFECTS/
LIB3/STD/EFFECTS/HEALING/
LIB3/STD/EFFECTS/OTHER/
LIB3/STD/EFFECTS/POISONS/
LIB3/STD/ENVIRON/
LIB3/STD/GUILDS/
LIB3/STD/LIQUIDS/
LIB3/STD/ROOM/
LIB3/STD/TRIGGER/SHADOW/
LIB3/W/
LIB3/W/BANNOR/
LIB3/W/NEWSTYLE/
inherit "std/object";
#define BRIGHTNESS 50 

int amount_of_fuel;
status is_lighted;
 
void setup() {
  amount_of_fuel = 2000; 
  set_name("torch"); 
  set_main_plural("torches");
  set_short("Torch");
  set_long("A small torch.\n");
  is_lighted = 0;
  set_weight(50);
  set_value(50);
} /* setup() */

string short(int i) {
    if (is_lighted)
        return ::short(0) + " (lit)";
    return ::short(0);
} /* short() */
 
string pretty_plural() {
  if (is_lighted)
    return ::pretty_plural() + " (lit)";
  return ::pretty_plural();
} /* pretty_plural() */

void set_fuel(int f) { amount_of_fuel = f; }
 
void init() {
  this_player()->add_command("light", this_object());
  this_player()->add_command("extinguish", this_object());
  this_player()->add_command("dowse", this_object());
} /* init() */
 
int do_light() {
  if (is_lighted) {
/*
    write(capitalize(short(0))+" is already lit.\n");
*/
    return 0;
  }
  if (amount_of_fuel <= 0) {
    write(capitalize(short(0))+" is burnt out.\n");
    return 0;
  }
  is_lighted = 1;
  call_out("out_of_fuel", amount_of_fuel * 2);
  amount_of_fuel = 0;
  set_light(BRIGHTNESS);
  return 1;
} /* do_light() */
 
void out_of_fuel() {
/* perhaps we can something clever here with events. */
  is_lighted = 0;
  set_light(0);
  say("The " + short(0) + " goes out.\n");
  write("The " + short(0) + " goes out.\n");
  set_long("The remains of a torch.  It doesn't look like it has anything "+
"left to burn on it.\n");
} /* out_of_fuel() */
 
int do_extinguish(object *indir, string s1, string s2, string prep) {
  int i;

  if (!is_lighted) {
    write(capitalize(short(0))+" is not lit.\n");
    return 0;
  }
  i = remove_call_out("out_of_fuel");
  amount_of_fuel = i/2;
  is_lighted = 0;
  set_light(0);
  return 1;
} /* do_extenguish() */

void dest_me() {
  set_light(0);
  ::dest_me();
} /* dest_me() */

mixed query_dynamic_auto_load() {
  return ([ "::" : ::query_dynamic_auto_load(),
            "amount of fuel" : amount_of_fuel,
            "is lit" : is_lighted,
          ]);
} /* query_dynamic_auto_load() */

void init_dynamic_arg(mapping arg) {
  amount_of_fuel = arg["amount of fuel"];
  if (arg["is lit"])
    do_light();
} /* init_dynamic_arg() */