Exemple #1
0
        [PacketHandler(RealmServerOpCode.NormalChat)] //5084
        public static void NormalChatRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position -= 2;
            var msg = packet.ReadAsciiString(client.Locale); //default :

            if (msg.Length < 1 ||
                RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg,
                                                  client.ActiveCharacter.Target as Character))
            {
                return;
            }
            if (client.ActiveCharacter.ChatBanned)
            {
                client.ActiveCharacter.SendInfoMsg("Your chat is banned.");
                return;
            }
            var isPrueEnglish = client.Locale == Locale.En || Asda2EncodingHelper.IsPrueEnglish(msg);

            var locale = isPrueEnglish ? Locale.Any : client.Locale;

            if (client.ActiveCharacter.PlaceInRating <= 50)
            {
                client.ActiveCharacter.SendPacketToArea(CreateGlobalChatMessage(
                                                            CreateSenderName(client.ActiveCharacter), msg, GetChatColor(client.ActiveCharacter), locale), locale: locale);
            }
            else
            {
                client.ActiveCharacter.SendPacketToArea(
                    CreateNormalChatMessagePacket(CreateSenderName(client.ActiveCharacter), msg, client.Locale), true, false, locale);
            }
        }
Exemple #2
0
        /// <summary>Sends a message to this channel.</summary>
        /// <param name="sender">the chatter saying the message</param>
        public void SendMessage(IChatter sender, string message)
        {
            ChannelMember channelMember;

            if (!this.Members.TryGetValue(sender.EntityId.Low, out channelMember))
            {
                ChannelHandler.SendNotOnChannelReply((IPacketReceiver)sender, this.m_name);
            }
            else if (channelMember.IsMuted)
            {
                ChannelHandler.SendMutedReply((IPacketReceiver)sender, this.m_name);
            }
            else if (this.IsModerated && !channelMember.IsModerator)
            {
                ChannelHandler.SendNotOnChannelReply((IPacketReceiver)sender, this.m_name);
            }
            else
            {
                if (sender is IUser &&
                    RealmCommandHandler.HandleCommand((IUser)sender, message, (IGenericChatTarget)this))
                {
                    return;
                }
                ChannelHandler.SendPacketToChannel(this,
                                                   ChatMgr.CreateNormalChatMessagePacket(sender.Name, message, Locale.Start, (Character)null));
            }
        }
Exemple #3
0
        /// <summary>
        /// Sends a message to this channel.
        /// </summary>
        /// <param name="sender">the chatter saying the message</param>
        public void SendMessage(IChatter sender, string message)
        {
            ChannelMember mi;

            if (!Members.TryGetValue(sender.EntityId.Low, out mi))
            {
                ChannelHandler.SendNotOnChannelReply(sender, m_name);
                return;
            }

            if (mi.IsMuted)
            {
                ChannelHandler.SendMutedReply(sender, m_name);
                return;
            }

            bool isMod = mi.IsModerator;

            if (IsModerated && !isMod)
            {
                ChannelHandler.SendNotOnChannelReply(sender, m_name);
                return;
            }

            if (sender is IUser)
            {
                if (RealmCommandHandler.HandleCommand((IUser)sender, message, this))
                {
                    return;
                }
            }
            ChannelHandler.SendPacketToChannel(this, ChatMgr.CreateNormalChatMessagePacket(sender.Name, message, Locale.En));

            /*using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
             * {
             *      packet.Write((byte)ChatMsgType.Channel);
             *      packet.Write((uint)sender.SpokenLanguage);
             *      packet.Write(sender.EntityId);
             *      packet.Write(0);			// unknown
             *      packet.WriteCString(Name);
             *      packet.Write(sender.EntityId);
             *      packet.WriteUIntPascalString(message);
             *      packet.Write((byte)sender.ChatTag); // chat tag
             *
             *      if (isMod)
             *      {
             *              ChannelHandler.SendPacketToChannel(this, packet);
             *      }
             *      else
             *      {
             *              ChannelHandler.SendPacketToChannel(this, packet, sender.EntityId);
             *      }
             *
             *      ChatMgr.ChatNotify(sender, message, sender.SpokenLanguage, ChatMsgType.Channel, this);
             * }*/
        }
Exemple #4
0
        [PacketHandler(RealmServerOpCode.WishperChatRequest)] //5088
        public static void WishperChatRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position -= 24;
            var isSoulmate = packet.ReadByte();                    //default : 0Len : 1
            var target     = packet.ReadAsdaString(20, Locale.En); //default : Len : 20
            var index      = target.IndexOf('|');

            if (index >= 0)
            {
                target = target.Substring(index + 1, target.Length - index - 1);
            }
            var msg = packet.ReadAsciiString(client.Locale); //default : Len : 0

            if (msg.Length > 100)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Can't send wishper to {0} cause it's length more than 100 symbols.", target));
                return;
            }
            if (msg.Length < 1 ||
                RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg,
                                                  client.ActiveCharacter.Target as Character))
            {
                return;
            }
            var targetChar = World.GetCharacter(target, false);

            if (targetChar == null)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Can't send wishper to {0} cause can't found it.", target));
                return;
            }
            if (!targetChar.EnableWishpers && !client.ActiveCharacter.Role.IsStaff)
            {
                client.ActiveCharacter.SendSystemMessage(string.Format(
                                                             "Sorry, but {0} rejects all wishpers.", target));
                return;
            }
            //if (client.ActiveCharacter.ChatBanned)
            //{
            //    client.ActiveCharacter.SendInfoMsg("Your chat is banned.");
            //    return;
            //}

            SendWishperChatResponse(client, isSoulmate, targetChar.SessionId,
                                    client.ActiveCharacter.SessionId, CreateSenderName(client.ActiveCharacter), msg);
            SendWishperChatResponse(targetChar.Client, isSoulmate, client.ActiveCharacter.SessionId,
                                    targetChar.SessionId, CreateSenderName(client.ActiveCharacter), msg, client);
            Asda2TitleChecker.OnWishperChat(client.ActiveCharacter);
        }
Exemple #5
0
        public static void SayGroup(this Character sender, ChatLanguage language, string msg)
        {
            if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character))
            {
                return;
            }

            var group = sender.Group;

            if (group != null)
            {
                using (var packetOut =
                           CreateCharChatMessage(ChatMsgType.Party, ChatLanguage.Universal, sender, sender, null, msg, sender.ChatTag))
                {
                    group.SendAll(packetOut);
                }
            }
        }
Exemple #6
0
        /// <summary>
        /// Parses any incoming channel messages.
        /// </summary>
        /// <param name="type">the type of chat message indicated by the client</param>
        /// <param name="language">the chat language indicated by the client</param>
        /// <param name="packet">the actual chat message packet</param>
        private static void ChannelParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet)
        {
            var channel = packet.ReadCString();
            var message = packet.ReadCString();

            if (RealmCommandHandler.HandleCommand(sender, message, sender.Target as Character))
            {
                return;
            }

            var chan = ChatChannelGroup.RetrieveChannel(sender, channel);

            if (chan == null)
            {
                return;
            }

            chan.SendMessage(sender, message);
        }
        public static void WarChatRequestRequest(IRealmClient client, RealmPacketIn packet)
        {
            int num1 = (int)packet.ReadInt16();
            int num2 = (int)packet.ReadInt16();

            packet.Position += 20;
            string str = packet.ReadAsdaString(200, client.Locale);

            if (str.Length < 1 ||
                RealmCommandHandler.HandleCommand((IUser)client.ActiveCharacter, str,
                                                  (IGenericChatTarget)(client.ActiveCharacter.Target as Character)) ||
                !client.ActiveCharacter.IsAsda2BattlegroundInProgress)
            {
                return;
            }
            Locale locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, str);

            Asda2BattlegroundHandler.SendWarChatResponseResponse(client.ActiveCharacter.CurrentBattleGround,
                                                                 client.ActiveCharacter.Name, str, (int)client.ActiveCharacter.Asda2FactionId, locale);
        }
Exemple #8
0
        /// <summary>
        /// Parses any incoming officer message.
        /// </summary>
        /// <param name="sender">The character sending the message</param>
        /// <param name="type">the type of chat message indicated by the client</param>
        /// <param name="language">the chat language indicated by the client</param>
        /// <param name="packet">the actual chat message packet</param>
        private static void OfficerParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet)
        {
            string msg = ReadMessage(packet);

            if (msg.Length == 0)
            {
                return;
            }

            if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character))
            {
                return;
            }

            /*var guild = Guild.CheckPrivs(sender, GuildCommandId.MEMBER, GuildPrivileges.GCHATSPEAK);
             * if (guild != null)
             * {
             *      SendGuildOfficerMessage(sender, guild, msg);
             * }*/
        }
Exemple #9
0
        [PacketHandler(RealmServerOpCode.PartyChat)] //5105
        public static void PartyChatRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position -= 22;                           //nk default : 40Len : 2
            var msg = packet.ReadAsciiString(client.Locale); //default : Len : 0

            if (msg.Length < 1 ||
                RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg,
                                                  client.ActiveCharacter.Target as Character))
            {
                return;
            }
            if (client.ActiveCharacter.ChatBanned)
            {
                client.ActiveCharacter.SendInfoMsg(" You are Banned");
                return;
            }
            if (!client.ActiveCharacter.IsInGroup)
            {
                return;
            }

            SendPartyChatResponse(client.ActiveCharacter, msg);
        }
Exemple #10
0
        [PacketHandler(RealmServerOpCode.GlobalChatWithItem)] //6560
        public static void GlobalChatWithItemRequest(IRealmClient client, RealmPacketIn packet)
        {
            packet.Position -= 24;
            var success = client.ActiveCharacter.Asda2Inventory.UseGlobalChatItem();

            if (!success)
            {
                return;
            }
            //var accId = packet.ReadInt32();//default : 0Len : 4
            packet.Position += 1;                            //nk1 default : 0Len : 1
            var msg = packet.ReadAsciiString(client.Locale); //default : Len : 0

            if (msg.Length < 1 ||
                RealmCommandHandler.HandleCommand(client.ActiveCharacter, msg,
                                                  client.ActiveCharacter.Target as Character))
            {
                return;
            }
            if (msg.Length > 200)
            {
                client.ActiveCharacter.YouAreFuckingCheater("Global chat message more than 200 symbols.", 80);
                return;
            }
            if (client.ActiveCharacter.ChatBanned)
            {
                client.ActiveCharacter.SendInfoMsg("Your chat is banned.");
                return;
            }
            if (GuessEventManager.Started)
            {
                GuessEventManager.TryGuess(msg, client.ActiveCharacter);
            }
            var locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, msg);

            SendGlobalChatWithItemResponseResponse(CreateSenderName(client.ActiveCharacter), msg, client.ActiveCharacter.ChatColor, locale);
        }
Exemple #11
0
        /// <summary>
        /// Parses any incoming party or raid messages.
        /// </summary>
        /// <param name="sender">The character sending the message</param>
        /// <param name="type">the type of chat message indicated by the client</param>
        /// <param name="language">the chat language indicated by the client</param>
        /// <param name="packet">the actual chat message packet</param>
        private static void SubGroupParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet)
        {
            string msg = ReadMessage(packet);

            if (msg.Length == 0)
            {
                return;
            }

            if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character))
            {
                return;
            }

            var group = sender.SubGroup;

            if (group != null)
            {
                using (var packetOut = CreateCharChatMessage(type, ChatLanguage.Universal, sender, sender, null, msg))
                {
                    group.Send(packetOut, null);
                }
            }
        }
Exemple #12
0
        /// <summary>
        /// Parses any incoming whispers.
        /// </summary>
        /// <param name="type">the type of chat message indicated by the client</param>
        /// <param name="language">the chat language indicated by the client</param>
        /// <param name="packet">the actual chat message packet</param>
        private static void WhisperParser(Character sender, ChatMsgType type, ChatLanguage language, RealmPacketIn packet)
        {
            var recipient = packet.ReadCString();
            var msg       = ReadMessage(packet);

            if (msg.Length == 0)
            {
                return;
            }

            if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character))
            {
                return;
            }

            var targetChr = World.GetCharacter(recipient, false);

            if (targetChr == null)
            {
                SendChatPlayerNotFoundReply(sender.Client, recipient);
                return;
            }

            if (targetChr.Faction.Group != sender.Faction.Group)
            {
                SendChatPlayerWrongTeamReply(sender.Client);
                return;
            }

            if (targetChr.IsIgnoring(sender))
            {
                using (var packetOut = CreateCharChatMessage(ChatMsgType.Ignored, ChatLanguage.Universal, targetChr, sender, null, msg))
                {
                    sender.Send(packetOut);
                }
            }
            else
            {
                using (var packetOut = CreateCharChatMessage(ChatMsgType.Whisper, ChatLanguage.Universal, sender, targetChr, null, msg))
                {
                    targetChr.Send(packetOut);
                }
            }

            using (var packetOut = CreateCharChatMessage(ChatMsgType.MsgReply, ChatLanguage.Universal, targetChr, targetChr, null, msg, sender.ChatTag))
            {
                sender.Send(packetOut);
            }

            // handle afk/dnd situations
            if (targetChr.IsAFK)
            {
                using (var packetOut = CreateCharChatMessage(ChatMsgType.AFK, ChatLanguage.Universal, targetChr, sender, null, targetChr.AFKReason, targetChr.ChatTag))
                {
                    sender.Send(packetOut);
                }
            }

            if (targetChr.IsDND)
            {
                using (var packetOut = CreateCharChatMessage(ChatMsgType.DND, ChatLanguage.Universal, targetChr, sender, null, string.Empty, targetChr.ChatTag))
                {
                    sender.Send(packetOut);
                }
            }
        }
Exemple #13
0
        public static void SayYellEmote(this Character sender, ChatMsgType type, ChatLanguage language, string msg, float radius)
        {
            if (RealmCommandHandler.HandleCommand(sender, msg, sender.Target as Character))
            {
                return;
            }

            if (type != ChatMsgType.WhisperInform && msg.Length == 0)
            {
                return;
            }

            if (GlobalChat)
            {
                using (var packetOut = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, msg, sender.ChatTag))
                {
                    foreach (var chr in World.GetAllCharacters())
                    {
                        chr.Send(packetOut);
                    }
                }
            }
            else
            {
                var            faction = sender.FactionGroup;
                RealmPacketOut pckt = null, scrambledPckt = null;

                var scrambleDefault               = ScrambleChat && sender.Role.ScrambleChat;
                Func <WorldObject, bool> iterator = obj =>
                {
                    if ((obj is Character))
                    {
                        var chr = (Character)obj;
                        if (!scrambleDefault || chr.FactionGroup == faction || !chr.Role.ScrambleChat)
                        {
                            if (pckt == null)
                            {
                                pckt = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null, msg, sender.ChatTag);
                            }
                            chr.Send(pckt);
                        }
                        else
                        {
                            if (scrambledPckt == null)
                            {
                                scrambledPckt = CreateCharChatMessage(type, language, sender.EntityId, sender.EntityId, null,
                                                                      ScrambleMessage(msg), sender.ChatTag);
                            }
                            chr.Send(scrambledPckt);
                        }
                    }
                    return(true);
                };

                if (radius == WorldObject.BroadcastRange)
                {
                    sender.NearbyObjects.Iterate(iterator);
                }
                else
                {
                    sender.IterateEnvironment(radius, iterator);
                }

                if (pckt != null)
                {
                    pckt.Close();
                }
                if (scrambledPckt != null)
                {
                    scrambledPckt.Close();
                }
            }
        }