#pragma save_binary /* ** Optimised by Newstyle, 93/08/31 ** Say mannerisms added, Newstyle, 93/10/04 ** Inter-cre emote added, Newstyle, 93/10/07 ** Tell mannerisms added, Newstyle, 93/10/11 ** Shout mannerisms added, Newstyle, 93/10/11 */ #include "drinks.h" #include "inet.h" #include "player.h" #define BEEP sprintf( "%c", 7 ) int social_points, max_social_points; string *languages, cur_lang; static object converse_ob; static string my_file_name; string drunk_speech( string str ); string expand_nickname( string str ); void communicate_commands() { add_action( "converse", "converse" ); add_action( "do_say", "'*" ); add_action( "do_say", "say" ); add_action( "do_whisper", "whi*sper" ); add_action( "do_shout", "sh*out" ); add_action( "do_shout", "shout!" ); add_action( "do_tell", "t*ell" ); add_action( "do_emote", ":*" ); add_action( "do_emote", "em*ote" ); add_action( "do_echo", "ec*ho" ); add_action( "do_emote_all", "emoteall" ); add_action( "do_echo_to", "echoto" ); add_action( "do_write", "echome" ); add_action( "do_creator_tell", "cre*" ); add_action( "do_lord_tell", "lord*" ); add_action( "do_inter_creator_tell", "intercre*" ); add_action( "set_language", "sp*eak" ); } void set_max_social_points( int num ) { max_social_points = num; } int query_max_social_points() { return max_social_points; } void set_social_points( int num ) { social_points = num; } int query_social_points() { return social_points; } int adjust_social_points( int num ) { social_points += num; if( social_points > max_social_points ) social_points = max_social_points; if( social_points < 0 ) social_points = 0; return social_points; } void my_mess( string prep, string text ) { if( !interactive() ) return; printf( "%s%-=*s\n", prep, (int)this_player()->query_cols() - strlen( prep ), this_object()->fix_string( text ) ); } int do_write( string arg ) { if( !arg ) { notify_fail( "Syntax: " + query_verb() + " <string>\n" ); return 0; } write( arg + "\n" ); this_player()->adjust_time_left( -DEFAULT_TIME ); return 1; } int do_say( string str, int no_echo ) { string prep1, prep2, junk; if( !str ) { notify_fail( "Syntax: say [@manner] <something>\n" ); return 0; } if( !LANGUAGE_HAND->query_language_spoken( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not a spoken language.\n" ); return 0; } if( sscanf( str, "%s!%s", prep1, prep2 ) == 2 ) prep1 = "exclaim"; else if( sscanf( str, "%s?%s", prep1, prep2 ) == 2 ) prep1 = "ask"; else prep1 = "say"; while( str[ 0 ] == ' ' ) sscanf( str, " %s", str ); if( sscanf( str, "@%s %s", prep2, junk ) == 2 ) { prep2 = " " + prep2; str = junk; } else prep2 = ""; if( cur_lang != "common" ) prep2 += " in " + cur_lang; if( this_object()->query_volume( D_ALCOHOL ) ) str = drunk_speech( str ); event( environment(), "person_say", this_object()->query_cap_name() + " " + prep1 + "s" + prep2 + ": ", str, cur_lang ); if( !no_echo ) my_mess( "You " + prep1 + prep2 + ": ", str ); this_player()->adjust_time_left( -5 ); return 1; } int do_tell( string arg, object ob, int no_echo ) { string str, rest, prep1, prep2, prep3, prep4; if( !arg && !ob ) { notify_fail( "Syntax: tell person <message>\n" ); return 0; } if( sscanf( arg, "%s @%s %s", str, prep4, rest ) == 3 ) { arg = str + " " + rest; prep4 = " " + prep4; } else prep4 = ""; if( !ob ) { if( sscanf( arg, "%s %s", str, rest ) != 2 ) { notify_fail( "Syntax: tell <name> [@manner] something\n" ); return 0; } } else rest = arg; if( !LANGUAGE_HAND->query_language_spoken( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not a spoken language.\n" ); return 0; } if( !LANGUAGE_HAND->query_language_distance( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not able to spoken at a " + "distance.\n" ); return 0; } if( !ob ) { str = lower_case( str ); str = (string)this_object()->expand_nickname( str ); ob = find_player( str ); if( !ob ) ob = find_living( str ); if( !ob ) { if( this_object()->query_creator() && sscanf( str, "%s@%s", arg, arg ) == 2 ) { "/net/daemon/out_tell"->do_tell( str + " " + rest ); return 1; } if( "/secure/master"->test_user( str ) ) notify_fail( capitalize( str ) + " is not logged in.\n" ); else notify_fail( "Cannot find " + str + ".\n" ); return 0; } } if( ob == this_player() ) { notify_fail( "Talking to yourself again. I just don't know...\n" ); return 0; } if( ob->query_property( "player" ) && !interactive( ob ) ) { notify_fail( ob->query_cap_name() + " is net dead.\n" ); return 0; } if( my_file_name == "/global/player" && adjust_social_points( -TELL_COST ) < 0 ) { notify_fail( NO_POWER ); return 0; } if( sscanf( rest, "%s!%s", prep1, prep2 ) == 2 ) { prep1 = "exclaim to "; prep2 = " exclaims to"; } else if( sscanf( rest, "%s?%s", prep1, prep2 ) == 2 ) { prep1 = "ask "; prep2 = " asks"; } else { prep1 = "tell "; prep2 = " tells"; } if( this_object()->query_volume( D_ALCOHOL ) ) arg = drunk_speech( arg ); if( cur_lang != "common" ) prep3 = " in " + cur_lang; else prep3 = ""; ob->event_person_tell( this_object(), this_object()->query_cap_name() + prep2 + " you" + prep4 + prep3 + ": ", rest, cur_lang ); if( !no_echo ) my_mess( "You " + prep1 + ob->query_cap_name() + prep4 + prep3 + ": ", rest ); this_player()->adjust_time_left( -5 ); return 1; } int do_emote( string arg ) { if( my_file_name == "/global/player" && !this_player()->query_property( "emote" ) ) { notify_fail( NOT_ALLOWED ); return 0; } if( !arg ) { notify_fail( "Syntax: emote <whatever>\n" ); return 0; } if( my_file_name == "/global/player" && adjust_social_points( -EMOTE_COST ) < 0 ) { notify_fail( NO_POWER ); return 0; } this_player()->adjust_time_left( -5 ); if( this_object()->query_volume( D_ALCOHOL ) ) arg = drunk_speech( arg ); arg = (string)this_object()->query_cap_name() + " " + arg + "%^RESET%^\n"; write( arg ); say( arg ); return 1; } int do_shout( string str ) { string s1, s2, prep1; int i; if( !str ) { notify_fail( "Syntax : shout [@manner] <text>\n" ); return 0; } if( this_object()->check_earmuffs( "shout" ) ) { notify_fail( "Why shout when you can't hear people shout back?\n" ); return 0; } if( !LANGUAGE_HAND->query_language_spoken( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not a spoken language.\n" ); return 0; } if( !LANGUAGE_HAND->query_language_distance( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " cannot be spoken at a " + "distance.\n" ); return 0; } if( sscanf( str, "%s@%s %s", s1, prep1, s2 ) == 3 ) { str = s1 + s2; prep1 = " " + prep1; } else prep1 = ""; if( my_file_name == "/global/player" && adjust_social_points( -SHOUT_COST * ((strlen( str ) / 10) + 1) ) < 0 ) { notify_fail( NO_POWER ); return 0; } if( sscanf( str, "%s!%s", s1, s2 ) == 2 ) { s1 = "yell"; s2 = " yells"; } else if( sscanf( str, "%s?%s", s1, s2 ) == 2 ) { s1 = "shout asking"; s2 = " shouts asking"; } else { s1 = "shout"; s2 = " shouts"; } if( this_object()->query_volume( D_ALCOHOL ) ) str = drunk_speech( str ); str = replace( str, BEEP, "" ); if( cur_lang != "common" ) prep1 += " in " + cur_lang; my_mess( "You " + s1 + prep1 + ": ", str ); event( users(), "person_shout", this_object()->query_cap_name() + s2 + prep1, str, cur_lang ); return 1; } int do_creator_tell( string mess ) { int forced; string s1, s2; if( !this_object()->query_creator() ) return 0; if( !mess ) { notify_fail( "Syntax: cre <text>\n" ); return 0; } if( mess[ 0..0 ] == "?" ) { int i; object *people, *off_line; people = users(); off_line = ({ }); for( i = 0; i < sizeof( people ); i++ ) if( !people[ i ]->query_creator() ) { people = delete( people, i, 1 ); i--; } else if( people[ i ]->check_earmuffs( "creator-tell" ) ) { off_line += people[ i..i ]; people = delete( people, i, 1 ); } if( sizeof( people ) ) printf( "On line: %-=*s\n", ( int ) this_player()->query_cols() - 10, query_multiple_short( people ) ); if( sizeof( off_line ) ) printf( "Off line: %-=*s\n", ( int ) this_player()->query_cols() - 11, query_multiple_short( off_line ) ); return 1; } if( mess[ 0..0 ] == "@" ) { sscanf( mess[ 1..1000 ], "%s %s", s1, s2 ); if( !s1 ) s1 = mess[ 1..1000 ]; if( !"/obj/handlers/soul"->query_soul_command( s1 ) ) { notify_fail( "Useage : cre@soul\n" ); return 0; } command( mess[ 1..1000 ] + " creators" ); return 1; } if( mess[ 0..0 ] == "!" ) { forced = 1; mess = mess[ 1..1000 ]; } if( mess == "" ) { notify_fail( "Syntax: cre <text>\n" ); return 0; } if( this_object()->check_earmuffs( "creator-tell" ) ) { write( "Why use creator-tell when you can't hear a response?\n" ); return 1; } mess = replace( mess, BEEP, "" ); this_player()->adjust_time_left( -DEFAULT_TIME ); if( mess[ 0..0 ] == ":" ) { mess = mess[ 1..1000 ]; event( users(), "creator_tell", "(cre) " + (string)this_object()->query_cap_name() + " ", mess, forced ); my_mess( "(cre) " + this_object()->query_cap_name() + " ", mess ); return 1; } mess = mess[ 1..1000 ]; event( users(), "creator_tell", (string)this_object()->query_cap_name() + ": ", mess, forced ); my_mess( "You creator-tell: ", mess ); return 1; } int do_lord_tell( string mess ) { int forced, emoted; if( !this_object()->query_lord() ) return 0; if( !mess ) { notify_fail( "Syntax: lord <text>\n" ); return 0; } if( mess[ 0..0 ] == "?" ) { int i; object *people, *off_line; people = users(); off_line = ({ }); for( i = 0; i < sizeof( people ); i++ ) if( !people[ i ]->query_lord() ) { people = delete( people, i, 1 ); i--; } else if( people[ i ]->check_earmuffs( "lord-tell" ) ) { off_line += people[ i..i ]; people = delete( people, i, 1 ); } if( sizeof( people ) ) printf( "On line: %-=*s\n", ( int ) this_player()->query_cols() - 10, query_multiple_short( people ) ); if( sizeof( off_line ) ) printf( "Off line: %-=*s\n", ( int ) this_player()->query_cols() - 11, query_multiple_short( off_line ) ); return 1; } if( mess[ 0..0 ] == "!" ) forced = 1; else if( mess[ 0..0 ] == "@" || mess[ 0..0 ] == ":" ) emoted = 1; mess = mess[ 1..1000 ]; if( mess == "" ) { notify_fail( "Syntax: lord <text>\n" ); return 0; } if( this_object()->check_earmuffs( "lord-tell" ) ) { write( "Well, you've earmuffed your lord-tell, so why bother?\n" ); return 1; } mess = replace( mess, BEEP, "" ); this_player()->adjust_time_left( -DEFAULT_TIME ); if( emoted ) { event( users(), "lord_tell", "(L) " + (string)this_object()->query_cap_name() + " ", mess, forced ); my_mess( "(L) " + this_object()->query_cap_name() + " ", mess ); return 1; } event( users(), "lord_tell", "(L) " + (string)this_object()->query_cap_name() + ": ", mess, forced ); my_mess( "You lord-tell: ", mess ); return 1; } int do_echo( string str ) { if( my_file_name == "/global/player" && !this_player()->query_property( "echo" ) ) { notify_fail( NOT_ALLOWED ); return 0; } if( !str ) { notify_fail( "Syntax : echo <text>\n" ); return 0; } if( my_file_name == "/global/player" && adjust_social_points( -ECHO_COST ) < 0 ) { notify_fail( NO_POWER ); return 0; } if( this_object()->query_volume( D_ALCOHOL ) ) str = drunk_speech( str ); log_file( "ECHOS", ctime( time() ) + " " + this_player()->query_name() + " echo's: " + str + "\n" ); str += "%^RESET%^"; my_mess( "You echo: ", str ); event( environment(), "player_echo", str + "\n" ); return 1; } int do_echo_to( string str ) { string who, what; object ob; if( my_file_name == "/global/player" && !this_player()->query_property( "echoto" ) ) { notify_fail( NOT_ALLOWED ); return 0; } if( !str ) { notify_fail( "Syntax : echoto <player> <text>\n" ); return 0; } if( sscanf( str, "%s %s", who, what ) != 2 ) { notify_fail( "Syntax : echoto <player> <text>\n" ); return 0; } who = lower_case( who ); who = (string)this_object()->expand_nickname( who ); if( my_file_name == "/global/player" && adjust_social_points( -ECHOTO_COST ) < 0 ) { notify_fail( NO_POWER ); return 0; } if( !ob = find_player( who ) ) { notify_fail( capitalize( who ) + " not found.\n" ); return 0; } if( this_object()->query_volume( D_ALCOHOL ) ) what = drunk_speech( what ); log_file( "ECHOS", ctime( time() ) + " " + this_player()->query_cap_name() + " Echoto's " + who + ": " + what + "\n" ); what += "%^RESET%^"; my_mess( "You echo to " + who + ": ", what ); event( ob, "player_echo_to", what + "\n" ); return 1; } int do_emote_all( string str ) { if( my_file_name == "/global/player" && !this_player()->query_property( "emoteall" ) ) { notify_fail( NOT_ALLOWED ); return 0; } if( !str ) { notify_fail( "Syntax : emoteall <string>\n" ); return 0; } if( my_file_name == "/global/player" && adjust_social_points( -EMOTEALL_COST * ((strlen( str ) / 10) + 1) + 100 ) < 0 ) { notify_fail( NO_POWER ); return 0; } str = replace( str, BEEP, "" ); if( this_object()->query_volume( D_ALCOHOL ) ) str = drunk_speech( str ); log_file( "ECHOS", ctime( time() ) + " " + this_player()->query_cap_name() + " Emotealls: " + str + "\n" ); str += "%^RESET%^"; my_mess( "You emoteall : ", this_player()->query_cap_name() + " " + str ); event( users(), "player_emote_all", this_player()->query_cap_name() + " " + str + "\n" ); return 1; } int converse( string str ) { if( !LANGUAGE_HAND->query_language_spoken( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not a spoken language.\n" ); return 0; } if( str ) { if( !LANGUAGE_HAND->query_language_distance( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not able to spoken at a " + "distance.\n" ); return 0; } str = lower_case( str ); str = (string)this_object()->expand_nickname( str ); converse_ob = find_player( str ); if( !converse_ob ) converse_ob = find_living( str ); if( !converse_ob ) { notify_fail( "Syntax: converse [player]\n" ); return 0; } if( converse_ob == this_object() ) { notify_fail( "You have a nice conversation with yourself." + " Gee, what fun.\n" ); return 0; } } write( "Give '**' to stop.\n" ); write( "] " ); input_to( "do_converse" ); return 1; } void do_converse( string str ) { if( str == "**" ) { write( "Converse mode ended.\n" ); return; } if( str ) /* if(str[0..0] == '!') command(str[1..strlen(str)-1]); else */ if( !converse_ob ) do_say( str, 1 ); else do_tell( str, converse_ob, 1 ); write( "] " ); input_to( "do_converse" ); } int do_whisper( string str ) { object *obs; string s, s2, *bits, peeps; int i; notify_fail( "Syntax: whisper <string> to <person>\n" ); if( !str ) return 0; if( !LANGUAGE_HAND->query_language_spoken( cur_lang ) ) { notify_fail( capitalize( cur_lang ) + " is not a spoken language.\n" ); return 0; } str = replace( str, " to", " to" ); bits = explode( str, " to " ); if( !bits || sizeof( bits ) < 2 || (sizeof( bits ) == 2 && bits[ 0 ] == "") ) return 0; s2 = replace( implode( bits[ 0..sizeof( bits ) - 2 ], " to " ), " to", " to" ); obs = find_match( expand_nickname( bits[ sizeof( bits ) - 1 ] ), environment() ); if( sizeof( obs ) == 1 && obs[ 0 ] == this_player() ) { say( this_player()->query_cap_name() + " whispers to " + this_player()->query_objective() + "self.\n" ); write( "Whispering to your self!?\n" ); return 1; } obs = obs - ({ this_player() }); for( i = 0; i < sizeof( obs ); i++ ) if( !living( obs[ i ] ) ) obs = delete( obs, i--, 1 ); if( !sizeof( obs ) ) { notify_fail( "Could not find anyone to whisper to.\n" ); return 0; } if( sscanf( s2, "%s!%s", s, s ) == 2 ) s = "urgently "; else if( sscanf( s2, "%s?%s", s, s ) == 2 ) s = "questioningly "; else s = ""; if( this_object()->query_volume( D_ALCOHOL ) ) s2 = drunk_speech( s2 ); s2 += "%^RESET%^"; event( environment(), "whisper", this_object()->query_cap_name() + " whispers " + s, s2, obs, cur_lang ); my_mess( "You whisper " + s + "to " + query_multiple_short( obs ) + ": ", s2 ); this_player()->adjust_time_left( -5 * sizeof( obs ) ); return 1; } string drunk_speech( string str ) { return replace( str, ({ "s", "sh", "r", "rr", "ing", "in'", "x", "xsh", "S", "SH", "R", "RR" }) ); } void add_language( string lang ) { if( !LANGUAGE_HAND->test_language( lang ) ) return; if( member_array( lang, languages ) != -1 ) return; languages += ({ lang }); } void remove_language( string lang ) { int i; if( (i = member_array( lang, languages )) == -1 ) return; languages = delete( languages, i, 1 ); if( lang == cur_lang ) { if( !sizeof( languages ) ) cur_lang = "grunt"; else cur_lang = languages[ 0 ]; tell_object( this_object(), "You just forgot the language you were " + "speaking. You are now speaking " + cur_lang + ".\n" ); } } int set_language( string str ) { if( !str ) { notify_fail( "You are now speaking " + cur_lang + " and can speak any of " + query_multiple_short( languages + ({ "grunt" }) ) + ".\n" ); return 0; } if( member_array( str, languages + ({ "grunt" }) ) == -1 ) { notify_fail( "You do not know " + str + ".\n" ); return 0; } cur_lang = str; write( "Now using " + str + " for speaking and writing.\n" ); return 1; } string query_current_language() { return cur_lang; } string *query_languages() { return languages; } int query_language( string str ) { if( member_array( str, languages ) == -1 ) return 0; return 1; } int do_inter_creator_tell( string str ) { if( !this_object()->query_creator() ) return 0; if( !str || str == "" || str == " " ) { notify_fail( "Sytnax: " + query_verb() + " <mess>\n" ); return 0; } if( this_object()->check_earmuffs( "inter-creator-tell" ) ) { notify_fail( "You cannot intercre with your earmuffs on!.\n" ); return 0; } if( str[ 0..0 ] == "@" || str[ 0..0 ] == ":" ) { str = str[ 1..strlen( str ) - 1 ]; write( "You inter-cre emote:\n" + this_player()->query_cap_name() + " " + str + "\n" ); INTERCREATORD->do_intercreator( str, 1 ); return 1; } INTERCREATORD->do_intercreator( str, 0 ); my_mess( "You inter-cre tell: ", str ); return 1; }