FORCE.C
LIB3/STD/LIVING/FORCE.C · 3.8 KB
From the archive nm4dos.zip
Download the archive « Back to the archive contents
#pragma save_binary
/* code to handle forcing. The method used will be to ask the object to
* do the command. While this is similar to the original method of doing this
* it will be used to be more in the style of asking things to do things,
* rather than the making things do things without asking them first. */
/*
** Optimised by Newstyle, 18/11/93
** - I removed a number of 'features' (bugs) too.
*/
#define FORCE_COST 1
#define ILLEGAL_FORCE ({ "alias", "unalias", "history", "finger",\
"mv", "cp", "mkdir", "rm", "rmdir", "cd",\
"grade", "sponsor", "force", "exec", "call",\
"promote", "demote", "new_domain",\
"kill", "drop", "give", "quit", "su",\
"shout", "echoall", "emoteall" })
static string fname;
static int no_force_me;
void force_commands()
{
sscanf( file_name( this_object() ), "%s#", fname );
if( "/obj/handlers/cregrade"->
query_cre_grade( (string)this_object()->query_name() ) > 19 )
add_action( "do_force", "force" );
if( fname == "/global/lord" )
add_action( "no_force", "noforce" );
}
static int no_force( string str )
{
if( fname != "/global/lord" )
return 0;
if( str == "on" )
{
no_force_me = 1;
write( "Okay, you now cannot be forced.\n" );
return 1;
}
if( str == "off" )
{
no_force_me = 0;
write( "Okay, you can now be forced.\n" );
return 1;
}
if( no_force_me )
write( "Forcing you is currently disabled.\n" );
else
write( "Forcing you is currently enabled.\n" );
return 1;
}
int do_force( string str )
{
string who, what;
object *obs, ob;
int i;
if( fname == "/global/player" && !this_player()->query_property( "force" ) )
{
notify_fail( "You do not have the ability to force yet.\n" );
return 0;
}
if( !str || sscanf( str, "%s %s", who, what ) != 2 )
{
notify_fail( "Usage : force <person> <command>\n" );
return 0;
}
if( this_player()->adjust_social_points( -FORCE_COST ) < 0 )
{
notify_fail( "Insufficient social points.\n" );
return 0;
}
who = (string)this_player()->expand_nickname( who );
who = lower_case( who );
obs = find_match( who, environment( this_object() ) );
if( !sizeof( obs ) )
if( !(ob = find_living( who )) )
{
notify_fail( "No such living thing.\n" );
return 0;
}
else
obs += ({ ob });
for( i = 0; i < sizeof( obs ); i++ )
if( obs[ i ]->do_force_on_me( what ) )
write( obs[ i ]->query_cap_name() + " forced sucessfully.\n" );
else
write( obs[ i ]->query_cap_name() + " didn't want to do that.\n" );
return 1;
}
int do_force_on_me( string str )
{
string temp1, temp2;
object forcer;
int i;
if( !(forcer = this_player( 1 )) )
forcer = previous_object();
for( i = 0; i < sizeof( ILLEGAL_FORCE ); i++ )
if( ((sscanf( str, "%s" + ILLEGAL_FORCE[ i ] + "%s", temp1, temp2 ) == 2) ||
no_force_me) &&
!"secure/master"->high_programmer( geteuid( forcer ) ) )
{
tell_object( this_object(), forcer->query_cap_name() +
" fails to force you to " + str + "\n" );
event( users(), "inform", forcer->query_cap_name() + " forces " +
this_object()->query_name() + " to " + str + " (failed)", "force" );
log_file( "FORCE", ctime( time() ) + " " + forcer->query_name() + " " +
this_object()->query_name() + " : " + str + " (failed)\n" );
return 0;
}
tell_object( this_object(), forcer->query_cap_name() +
" forces you to " + str + "\n" );
event( users(), "inform", forcer->query_cap_name() + " forces " +
this_object()->query_name() + " to " + str, "force" );
log_file( "FORCE", ctime( time() ) + " " + forcer->query_name() + " " +
this_object()->query_name() + " : " + str + " (succeeded)\n" );
command( str );
return 1;
}