bool check_social( CHAR_DATA * ch, const char *command, const char *argument ) { char arg[MAX_INPUT_LENGTH]; CHAR_DATA *victim, *victim_next; SOCIALTYPE *social; CHAR_DATA *removed[128]; /* What are the chances of more than 128? */ ROOM_INDEX_DATA *room; int i = 0, k = 0; if( ( social = find_social( command ) ) == NULL ) return FALSE; if( !IS_NPC( ch ) && xIS_SET( ch->act, PLR_NO_EMOTE ) ) { send_to_char( "You are anti-social!\r\n", ch ); return TRUE; } switch ( ch->position ) { case POS_DEAD: send_to_char( "Lie still; you are DEAD.\r\n", ch ); return TRUE; case POS_INCAP: case POS_MORTAL: send_to_char( "You are hurt far too bad for that.\r\n", ch ); return TRUE; case POS_STUNNED: send_to_char( "You are too stunned to do that.\r\n", ch ); return TRUE; case POS_SLEEPING: /* * I just know this is the path to a 12" 'if' statement. :( * But two players asked for it already! -- Furey */ if( !str_cmp( social->name, "snore" ) ) break; send_to_char( "In your dreams, or what?\r\n", ch ); return TRUE; } /* * Search room for chars ignoring social sender and * remove them from the room until social has been * completed */ room = ch->in_room; for( victim = ch->in_room->first_person; victim; victim = victim_next ) { if( i == 127 ) break; victim_next = victim->next_in_room; if( is_ignoring( victim, ch ) ) { if( !IS_IMMORTAL( ch ) || get_trust( victim ) > get_trust( ch ) ) { removed[i] = victim; i++; UNLINK( victim, room->first_person, room->last_person, next_in_room, prev_in_room ); } else { set_char_color( AT_IGNORE, victim ); ch_printf( victim, "You attempt to ignore %s," " but are unable to do so.\r\n", ch->name ); } } } one_argument( argument, arg ); victim = NULL; if( arg[0] == '\0' ) { act( AT_SOCIAL, social->others_no_arg, ch, NULL, victim, TO_ROOM ); act( AT_SOCIAL, social->char_no_arg, ch, NULL, victim, TO_CHAR ); } else if( ( victim = get_char_room( ch, arg ) ) == NULL ) { /* * If they aren't in the room, they may be in the list of * people ignoring... */ if( i != 0 ) { for( k = 0, victim = removed[0]; k < i; k++, victim = removed[k] ) { if( nifty_is_name( victim->name, arg ) || nifty_is_name_prefix( arg, victim->name ) ) { set_char_color( AT_IGNORE, ch ); ch_printf( ch, "%s is ignoring you.\r\n", victim->name ); break; } } } if( !victim ) send_to_char( "They aren't here.\r\n", ch ); } else if( victim == ch ) { act( AT_SOCIAL, social->others_auto, ch, NULL, victim, TO_ROOM ); act( AT_SOCIAL, social->char_auto, ch, NULL, victim, TO_CHAR ); } else { act( AT_SOCIAL, social->others_found, ch, NULL, victim, TO_NOTVICT ); act( AT_SOCIAL, social->char_found, ch, NULL, victim, TO_CHAR ); act( AT_SOCIAL, social->vict_found, ch, NULL, victim, TO_VICT ); if( !IS_NPC( ch ) && IS_NPC( victim ) && !IS_AFFECTED( victim, AFF_CHARM ) && IS_AWAKE( victim ) && !HAS_PROG( victim->pIndexData, ACT_PROG ) ) { switch ( number_bits( 4 ) ) { case 0: if( IS_EVIL( ch ) && !is_safe( victim, ch, TRUE ) ) /* was IS_EVIL(ch) ||.... didn't make sense to me - FB */ multi_hit( victim, ch, TYPE_UNDEFINED ); else if( IS_NEUTRAL( ch ) ) { act( AT_ACTION, "$n slaps $N.", victim, NULL, ch, TO_NOTVICT ); act( AT_ACTION, "You slap $N.", victim, NULL, ch, TO_CHAR ); act( AT_ACTION, "$n slaps you.", victim, NULL, ch, TO_VICT ); } else { act( AT_ACTION, "$n acts like $N doesn't even exist.", victim, NULL, ch, TO_NOTVICT ); act( AT_ACTION, "You just ignore $N.", victim, NULL, ch, TO_CHAR ); act( AT_ACTION, "$n appears to be ignoring you.", victim, NULL, ch, TO_VICT ); } break; case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: act( AT_SOCIAL, social->others_found, victim, NULL, ch, TO_NOTVICT ); act( AT_SOCIAL, social->char_found, victim, NULL, ch, TO_CHAR ); act( AT_SOCIAL, social->vict_found, victim, NULL, ch, TO_VICT ); break; case 9: case 10: case 11: case 12: act( AT_ACTION, "$n slaps $N.", victim, NULL, ch, TO_NOTVICT ); act( AT_ACTION, "You slap $N.", victim, NULL, ch, TO_CHAR ); act( AT_ACTION, "$n slaps you.", victim, NULL, ch, TO_VICT ); break; } } } /* * Replace the chars in the ignoring list to the room * note that the ordering of the players in the room * might change */ if( i != 0 ) { for( k = 0, victim = removed[0]; k < i; k++, victim = removed[k] ) { LINK( victim, room->first_person, room->last_person, next_in_room, prev_in_room ); } } return TRUE; }
void broadcast_channel(struct char_data *sender, const CHANNEL_DEFINITION const *channel, struct char_data *target, const char *argument) { if (sender != NULL) { if (CHAN_DENIED(sender, channel->flag)) { send_to_char("You may not use that channel.", sender); return; } ENABLE_CHAN(sender, channel->flag); } if (channel->broadcaster == NULL) { if (sender != NULL) { send_to_char("Bug logged.", sender); } log_bug("No broadcaster for channel %s (%ul).", channel->name, channel->flag); return; } switch (channel->target_requirement) { case CHANNEL_TARGET_NONE: { if (target != NULL) { log_bug("Ignored target provided for channel %s (%ul).", channel->name, channel->flag); } channel->broadcaster(channel, sender, argument); return; } case CHANNEL_TARGET_OPTIONAL: { if (target == NULL) { channel->broadcaster(channel, sender, argument); } else { channel->targeted_broadcaster(channel, sender, target, argument); } return; } case CHANNEL_TARGET_REQUIRED: { if (target == NULL) { if (sender != NULL) { send_to_char("Bug logged.", sender); } log_bug("Target is required and not provided for channel %s (%ul).", channel->name, channel->flag); return; } if (is_ignoring(sender, target)) { act_new("$N seems to be ignoring you.", sender, NULL, target, TO_CHAR, POS_DEAD, false); return; } if (!(IS_IMMORTAL(sender) && sender->level > LEVEL_IMMORTAL) && !IS_AWAKE(target)) { act_new("$E can't hear you.", sender, 0, target, TO_CHAR, POS_DEAD, false); return; } channel->targeted_broadcaster(channel, sender, target, argument); return; } } }
/* Duplicate of to_channel from act_comm.c modified for dynamic channels */ void send_tochannel( char_data * ch, mud_channel * channel, string & argument ) { int speaking = -1; for( int lang = 0; lang < LANG_UNKNOWN; ++lang ) { if( ch->speaking == lang ) { speaking = lang; break; } } if( ch->isnpc( ) && channel->type == CHAN_GUILD ) { ch->print( "Mobs can't be in clans/guilds.\r\n" ); return; } if( ch->has_pcflag( PCFLAG_SILENCE ) ) { ch->printf( "You can't %s.\r\n", channel->name.c_str( ) ); return; } if( ch->has_aflag( AFF_SILENCE ) ) { ch->print( "You are unable to utter a sound!\r\n" ); return; } if( !ch->IS_PKILL( ) && channel->type == CHAN_PK ) { if( !ch->is_immortal( ) ) { ch->print( "Peacefuls have no need to use PK channels.\r\n" ); return; } } if( ch->in_room->flags.test( ROOM_SILENCE ) || ch->in_room->flags.test( ROOM_NOYELL ) || ch->in_room->area->flags.test( AFLAG_SILENCE ) ) { ch->print( "The room absorbs your words!\r\n" ); return; } if( ch->isnpc( ) && ch->has_aflag( AFF_CHARM ) ) { if( ch->master ) ch->master->print( "I don't think so...\r\n" ); return; } if( argument.empty( ) ) { if( !channel->flags.test( CHAN_KEEPHISTORY ) ) { ch->printf( "%s what?\r\n", capitalize( channel->name ).c_str( ) ); return; } show_channel_history( ch, channel ); return; } // Adaptation of Smaug 1.8b feature. Stop whitespace abuse now! strip_spaces( argument ); string arg, word; char_data *victim = nullptr; social_type *social = nullptr; string socbuf_char, socbuf_vict, socbuf_other; arg = argument; arg = one_argument( arg, word ); if( word[0] == '@' && ( social = find_social( word.substr( 1, word.length( ) ) ) ) != nullptr ) { if( !arg.empty( ) ) { string name; one_argument( arg, name ); if( ( victim = ch->get_char_world( name ) ) ) arg = one_argument( arg, name ); if( !victim ) { socbuf_char = social->char_no_arg; socbuf_vict = social->others_no_arg; socbuf_other = social->others_no_arg; if( socbuf_char.empty( ) && socbuf_other.empty( ) ) social = nullptr; } else if( victim == ch ) { socbuf_char = social->char_auto; socbuf_vict = social->others_auto; socbuf_other = social->others_auto; if( socbuf_char.empty( ) && socbuf_other.empty( ) ) social = nullptr; } else { socbuf_char = social->char_found; socbuf_vict = social->vict_found; socbuf_other = social->others_found; if( socbuf_char.empty( ) && socbuf_other.empty( ) && socbuf_vict.empty( ) ) social = nullptr; } } else { socbuf_char = social->char_no_arg; socbuf_vict = social->others_no_arg; socbuf_other = social->others_no_arg; if( socbuf_char.empty( ) && socbuf_other.empty( ) ) social = nullptr; } } bool emote = false; if( word[0] == ',' ) { emote = true; argument = argument.substr( 1, argument.length( ) ); } if( social ) { act_printf( AT_PLAIN, ch, argument.c_str( ), victim, TO_CHAR, "&W[&[%s]%s&W] &[%s]%s", channel->colorname.c_str( ), capitalize( channel->name ).c_str( ), channel->colorname.c_str( ), socbuf_char.c_str( ) ); } else if( emote ) { ch->printf( "&W[&[%s]%s&W] &[%s]%s %s\r\n", channel->colorname.c_str( ), capitalize( channel->name ).c_str( ), channel->colorname.c_str( ), ch->name, argument.c_str( ) ); } else { if( ch->has_pcflag( PCFLAG_WIZINVIS ) ) ch->printf( "&[%s](%d) You %s '%s'\r\n", channel->colorname.c_str( ), ( !ch->isnpc( ) ? ch->pcdata->wizinvis : ch->mobinvis ), channel->name.c_str( ), argument.c_str( ) ); else ch->printf( "&[%s]You %s '%s'\r\n", channel->colorname.c_str( ), channel->name.c_str( ), argument.c_str( ) ); } if( ch->in_room->flags.test( ROOM_LOGSPEECH ) ) append_to_file( LOG_FILE, "%s: %s (%s)", ch->isnpc( )? ch->short_descr : ch->name, argument.c_str( ), channel->name.c_str( ) ); /* * Channel history. Records the last MAX_CHANHISTORY messages to channels which keep historys */ if( channel->flags.test( CHAN_KEEPHISTORY ) ) update_channel_history( ch, channel, argument, emote ); list < char_data * >::iterator ich; for( ich = pclist.begin( ); ich != pclist.end( ); ++ich ) { char_data *vch = *ich; /* * Hackish solution to stop that damned "someone chat" bug - Matarael 17.3.2002 */ bool mapped = false; int origmap = -1, origx = -1, origy = -1; if( vch == ch || !vch->desc ) continue; if( vch->desc->connected == CON_PLAYING && hasname( vch->pcdata->chan_listen, channel->name ) ) { string sbuf = argument; char lbuf[MIL + 4]; /* invis level string + buf */ if( vch->level < channel->level ) continue; if( vch->in_room->flags.test( ROOM_SILENCE ) || vch->in_room->area->flags.test( AFLAG_SILENCE ) ) continue; if( channel->type == CHAN_ROOM ) { if( vch->in_room != ch->in_room ) continue; /* * Check to see if a player on a map is at the same coords as the recipient */ if( !is_same_char_map( ch, vch ) ) continue; } if( channel->type == CHAN_ZONE && ( vch->in_room->area != ch->in_room->area || vch->in_room->flags.test( ROOM_NOYELL ) ) ) continue; if( channel->type == CHAN_PK && !vch->IS_PKILL( ) && !vch->is_immortal( ) ) continue; if( channel->type == CHAN_GUILD ) { if( vch->isnpc( ) ) continue; if( vch->pcdata->clan != ch->pcdata->clan ) continue; } int position = vch->position; vch->position = POS_STANDING; if( ch->has_pcflag( PCFLAG_WIZINVIS ) && vch->can_see( ch, false ) && vch->is_immortal( ) ) snprintf( lbuf, MIL + 4, "&[%s](%d) ", channel->colorname.c_str( ), ( !ch->isnpc( ) ) ? ch->pcdata->wizinvis : ch->mobinvis ); else lbuf[0] = '\0'; if( speaking != -1 && ( !ch->isnpc( ) || ch->speaking ) ) { int speakswell = UMIN( knows_language( vch, ch->speaking, ch ), knows_language( ch, ch->speaking, vch ) ); if( speakswell < 85 ) sbuf = translate( speakswell, argument, lang_names[speaking] ); } /* * Check to see if target is ignoring the sender */ if( is_ignoring( vch, ch ) ) { /* * If the sender is an imm then they cannot be ignored */ if( !ch->is_immortal( ) || vch->level > ch->level ) { /* * Off to oblivion! */ continue; } } MOBtrigger = false; /* * Hackish solution to stop that damned "someone chat" bug - Matarael 17.3.2002 */ if( ch->has_pcflag( PCFLAG_ONMAP ) ) { mapped = true; origx = ch->mx; origy = ch->my; origmap = ch->wmap; } if( ch->isnpc( ) && ch->has_actflag( ACT_ONMAP ) ) { mapped = true; origx = ch->mx; origy = ch->my; origmap = ch->wmap; } fix_maps( vch, ch ); char buf[MSL]; if( !social && !emote ) { snprintf( buf, MSL, "&[%s]$n %ss '$t&[%s]'", channel->colorname.c_str( ), channel->name.c_str( ), channel->colorname.c_str( ) ); mudstrlcat( lbuf, buf, MIL + 4 ); act( AT_PLAIN, lbuf, ch, sbuf.c_str( ), vch, TO_VICT ); } if( emote ) { snprintf( buf, MSL, "&W[&[%s]%s&W] &[%s]$n $t", channel->colorname.c_str( ), capitalize( channel->name ).c_str( ), channel->colorname.c_str( ) ); mudstrlcat( lbuf, buf, MIL + 4 ); act( AT_PLAIN, lbuf, ch, sbuf.c_str( ), vch, TO_VICT ); } if( social ) { if( vch == victim ) { act_printf( AT_PLAIN, ch, nullptr, vch, TO_VICT, "&W[&[%s]%s&W] &[%s]%s", channel->colorname.c_str( ), capitalize( channel->name ).c_str( ), channel->colorname.c_str( ), socbuf_vict.c_str( ) ); } else { act_printf( AT_PLAIN, ch, vch, victim, TO_THIRD, "&W[&[%s]%s&W] &[%s]%s", channel->colorname.c_str( ), capitalize( channel->name ).c_str( ), channel->colorname.c_str( ), socbuf_other.c_str( ) ); } } vch->position = position; /* * Hackish solution to stop that damned "someone chat" bug - Matarael 17.3.2002 */ if( mapped ) { ch->wmap = origmap; ch->mx = origx; ch->my = origy; if( ch->isnpc( ) ) ch->set_actflag( ACT_ONMAP ); else ch->set_pcflag( PCFLAG_ONMAP ); } else { if( ch->isnpc( ) ) ch->unset_actflag( ACT_ONMAP ); else ch->unset_pcflag( PCFLAG_ONMAP ); ch->wmap = -1; ch->mx = -1; ch->my = -1; } } } }