/
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/function/
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/
/*
 * This is a shut down deamon, that will take care of shutting down
 * the game.
 * Call the function "shut" with a number of seconds as an
 * argument.
 * Don't clone this object.
 */

#include <mudlib.h>
inherit MONSTER;

#ifdef NATIVE_MODE
void create() {
  ::create();
#else
reset(arg) {
    ::reset(arg);
    if (arg)
	return;
#endif /* native */
    set_name("armageddon");
    set_level(19);
    set_wc(40);
    set_ac(20);
    set_short("Armageddon the game crasher");
    set_long("He looks like he enjoys to stop the game.\n");
    set_alias("shut");
    set_magic_resist(100);
    mmsgin = "Arrives in a puff of smoke";
    move_player("in a puff of smoke#room/city/square");
}

shut(int seconds) {
    int i;

    if(!"obj/master"->valid_player_call(previous_object())) {
      write("Use: shutdown <reason>\n");
      return 1;
    }
    if(!seconds) {
	write("No time given\n");
	return;
    }
    set_long("He is firmly concentrated on counting.\n");
    i = remove_call_out("cont_shutting");
    if (i > 0) {
	i = (i + 10) * 4;
	if (i < seconds) {
	    write("There was already a shutdown in process, " + i +
		  " seconds.\n");
	    seconds = i;
	}
    }
    call_out("cont_shutting", 0, seconds * 60);
}

int transport_offer;

cont_shutting(int seconds) {
    string delay;
    int new_delay;

    if (seconds <= 0) {
	shout(query_name() + " shouts: I will reboot now.\n");
	shutdown();
	return;
    }
    if (seconds <= 240 && !transport_offer) {
	shout(query_name() +
	    " shouts: Tell me if you want a trip to the shop !\n");
	transport_offer = 1;
    }
    new_delay = seconds * 3 / 4 - 10;
    call_out("cont_shutting", seconds - new_delay, new_delay);
    delay = "";
    if (seconds > 59) {
	delay = seconds / 60 + " minutes ";
	seconds = seconds % 60;
    }
    if (seconds != 0)
	delay += seconds + " seconds";
    shout(query_name() + " shouts: Game reboot in " + delay + ".\n");
}

catch_tell(str) {
    string who, what;
    object ob;

    if (!transport_offer)
	return;
    if (sscanf(str, "%s tells you: %s", who, what) != 2)
	return;
    this_player()->move_player("X#room/shop");
}

shouting(string str) {
  object obj;
  int j;

  obj = users();
  for(j=0; j<sizeof(obj); j++) {
    if(!obj[j] -> query_edit())
        tell_object(obj[j], str);
  }
}