/
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/
/*
   ** The armageddon man.
   ** Zapped by newstyle, 25/11/93
 */

inherit "/std/object";

int     time_of_crash;

void    setup()
{
    set_name( "armageddon" );
    set_short( "armageddon man" );
    add_adjective( "man" );
    add_alias( ({ "shutdown", "shut", "god", "man" }) );
    set_long( "The armageddon man. Nice guy really, just a bit " +
	      "fixated on shutting the mud down....\n" );

    set_living_name( "armageddon" );
    enable_commands();

    move( "/w/common.c",
	  "Warning, Armageddon on the move!\n",
	  "Warning, Armageddon on the move!\n" );

    reset_get();
    call_out( "check_false_start", 10 );
}

void    tellall( string str )
{
    object *peeps;
    int     i;

    peeps = users();
    if( !sizeof( peeps ) )
	return;
    for( i = 0; i < sizeof( peeps ); i++ )
	tell_object( peeps[ i ], "%^RED%^%^FLASH%^" + str + "%^RESET%^" );
    return;
}

void    check_false_start()
{
    if( (time_of_crash - time()) < 0 )
	destruct( this_object() );
}

void    heart_beat()
{
    int     time_to_crash;

    if( !time_of_crash )
	return;
    time_to_crash = time_of_crash - time();
    if( time_to_crash < 1 )
    {
	call_out( "end_it_all", 0 );
	set_heart_beat( 0 );
	return;
    }
    if( time_to_crash < 10 )
    {
	tellall( "New Moon is shutting down in " + time_to_crash + " seconds.\n" );
	return;
    }
    if( time_to_crash < 60 && time_to_crash % 10 < 2 )
    {
	tellall( "New Moon is shutting down in " + time_to_crash + " seconds.\n" );
	return;
    }
    if( time_to_crash < 900 && time_to_crash % 60 < 2 )
    {
	tellall( "New Moon is shutting down in " + time_to_crash / 60 + " minutes.\n" );
	return;
    }
    return;
}

void    shut( int minutes )
{
    if( minutes < 1 )
    {
	write( "No time given, aborting shutdown.\n" );
	return;
    }
    set_long( "He is firmly concentrating on counting.\n" );
    if( time_of_crash )
	write( "There was already a shutdown in progress, set for " +
	       (time_of_crash - time()) + " seconds.\n" );
    time_of_crash = time() + minutes * 60;
    set_heart_beat( 1 );
}

string long( string str, int dark )
{
    if( time_of_crash )
	return ::long( str, dark ) +
	        "Game shutdown will be in " + (time_of_crash - time()) +
	        " seconds.\n";
    return ::long( str, dark );
}

void    end_it_all()
{
    int     i;
    object *obs;

    tellall( "New Moon shutting down immediately!\n" );
    obs = users();
    for( i = 0; i < sizeof( obs ); i++ )
	call_out( "force_quit", 0, obs[ i ] );
    call_out( "blue", 10 );
}

void    force_quit( object ob )
{
    ob->quit();
}

void    blue()
{
    shutdown( 0 );
}

int     query_time_to_crash()
{
    return time_of_crash - time();
}