SHUT.C
LIB3/OBJ/SHUT.C · 2.6 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
/*
** 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();
}