Exemplo n.º 1
0
 /// <summary>
 /// Sets whether the character is listening to a talk channel.
 /// </summary>
 /// <param name="channel"></param>
 /// <param name="state"></param>
 public void SetListening(TalkChannel channel, bool state)
 {
     if (!state)
     {
         // Set Listening = False: Turn the deaf channel on.
         int value = (int)Deaf | (int)channel;
         Deaf = (TalkChannel)value;
     }
     else
     {
         // Set Listening = True: Turn the deaf channel off.
         int value = (int)Deaf & ~((int)channel);
         Deaf = (TalkChannel)value;
     }
 }
Exemplo n.º 2
0
        /// <summary>
        /// Channel function - sends text to a specific output channel.
        /// </summary>
        /// <param name="ch"></param>
        /// <param name="argument"></param>
        /// <param name="channel"></param>
        /// <param name="verb"></param>
        public static void SendToChannel( CharData ch, string argument, TalkChannel channel, string verb )
        {
            if (ch == null || String.IsNullOrEmpty(argument))
            {
                return;
            }

            string text;
            int position;

            if( String.IsNullOrEmpty(argument) )
            {
                text = String.Format( "{0} what?\r\n", verb );
                ch.SendText( text );
                return;
            }

            if( !ch.IsNPC() && ch.HasActionBit(PC.PLAYER_SILENCE ) )
            {
                text = String.Format( "You can't {0}.\r\n", verb );
                ch.SendText( text );
                return;
            }

            if( !ch.CanSpeak() )
            {
                ch.SendText( "Your lips move but no sound comes out.\r\n" );
                return;
            }

            ch.SetListening(channel, true);

            // Make the words look drunk if needed...
            argument = DrunkSpeech.MakeDrunk( argument, ch );

            switch( channel )
            {
                default:
                    text = String.Format( "You {0} '{1}'\r\n", verb, argument );
                    ch.SendText( text );
                    text = String.Format( "$n&n {0}s '$t'", verb );
                    break;

                case TalkChannel.shout:
                    text = String.Format( "You {0} '{1}'\r\n", verb, argument );
                    ch.SendText( text );
                    text = String.Format( "$n&n {0}s '$t'", verb );
                    break;

                case TalkChannel.yell:
                    text = String.Format( "You {0} '{1}'\r\n", verb, argument );
                    ch.SendText( text );
                    text = String.Format( "$n&n {0}s '$t'", verb );
                    break;

                case TalkChannel.guild:
                    text = String.Format( "&+L[&+C$n&+L]&n&+c $t&n" );
                    Act( text, ch, argument, null, MessageTarget.character );
                    break;

                case TalkChannel.immortal:
                    text = String.Format( "&+L[&+r$n&+L]&n $t" );
                    position = ch.CurrentPosition;
                    ch.CurrentPosition = Position.standing;
                    Act( text, ch, argument, null, MessageTarget.character );
                    ch.CurrentPosition = position;
                    break;
            }

            foreach( SocketConnection socket in Database.SocketList )
            {
                CharData originalChar = socket.Original ? socket.Original : socket.Character;
                CharData targetChar = socket.Character;

                if( socket.ConnectionStatus == ConnectionState.playing && targetChar != ch
                        && !originalChar.IsListening( channel ) && !originalChar.InRoom.HasFlag( RoomTemplate.ROOM_SILENT ) )
                {
                    if( channel == TalkChannel.immortal && !originalChar.IsImmortal() )
                        continue;
                    if( channel == TalkChannel.guild && ( !originalChar.IsGuild() || !ch.IsSameGuild( originalChar ) ) )
                        continue;
                    if( channel == TalkChannel.shout && targetChar.InRoom.Area != ch.InRoom.Area && !targetChar.IsImmortal() )
                        continue;

                    position = targetChar.CurrentPosition;
                    if( channel != TalkChannel.shout && channel != TalkChannel.yell )
                        targetChar.CurrentPosition = Position.standing;
                    if( channel == TalkChannel.shout || channel == TalkChannel.yell )
                    {
                        // TODO: BUG: FIXME: Get rid of this hard-coded mob index number crap!
                        if( ( ch.IsNPC() && ( ch.MobileTemplate.IndexNumber == 9316
                                  || ch.MobileTemplate.IndexNumber == 9748 ) ) || (!targetChar.IsNPC() && targetChar.HasActionBit(PC.PLAYER_SHOUT)))
                        {
                            // Add foreign language filter
                            if( !ch.IsNPC() )
                            {
                                Act( text, ch, TranslateText( argument, ch, originalChar ), targetChar, MessageTarget.victim );
                            }
                            else
                            {
                                Act( text, ch, argument, targetChar, MessageTarget.victim );
                            }
                        }
                    }
                    else
                    {
                        Act( text, ch, argument, targetChar, MessageTarget.victim );
                    }
                    targetChar.CurrentPosition = position;
                }
            }

            return;
        }
Exemplo n.º 3
0
 /// <summary>
 /// Checks whether the character is listening to a talk channel.
 /// </summary>
 /// <param name="channel"></param>
 /// <returns></returns>
 public bool IsListening(TalkChannel channel)
 {
     if (Macros.IsSet((int)Deaf, (int)channel))
     {
         // If they're deaf to the channel, listening = false.
         return false;
     }
     return true;
 }