Exemplo n.º 1
0
        /// <summary>Sends a npc text update to the character</summary>
        /// <param name="character">recieving character</param>
        /// <param name="text">class holding all info about text</param>
        public static void SendNPCTextUpdate(Character character, IGossipEntry text)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE))
            {
                packet.Write(text.GossipId);
                int index1;
                for (index1 = 0; index1 < text.GossipTexts.Length; ++index1)
                {
                    GossipTextBase gossipText = text.GossipTexts[index1];
                    packet.WriteFloat(gossipText.Probability);
                    string textMale = gossipText.GetTextMale(character.GossipConversation);
                    string str      = !text.IsDynamic ? gossipText.GetTextFemale(character.GossipConversation) : textMale;
                    packet.WriteCString(textMale);
                    packet.WriteCString(str);
                    packet.Write((uint)gossipText.Language);
                    for (int index2 = 0; index2 < 3; ++index2)
                    {
                        packet.Write(0L);
                    }
                }

                for (; index1 < 8; ++index1)
                {
                    packet.WriteFloat(0);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.Fill((byte)0, 28);
                }

                character.Client.Send(packet, false);
            }
        }
Exemplo n.º 2
0
        public void SendRequest(TestCharacter sender, uint minLevel, uint maxLevel, string playerName,
                                string guildName, RaceMask2 raceMask, ClassMask2 classMask, List <ZoneId> zones, List <string> names)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_WHO))
            {
                packet.WriteUInt(minLevel);
                packet.WriteUInt(maxLevel);
                packet.WriteCString(playerName);
                packet.WriteCString(guildName);
                packet.WriteUInt((uint)raceMask);
                packet.WriteUInt((uint)classMask);

                packet.WriteUInt(zones.Count);
                foreach (ZoneId zone in zones)
                {
                    packet.WriteUInt((uint)zone);
                }

                packet.WriteUInt(names.Count);
                foreach (string name in names)
                {
                    packet.WriteCString(name);
                }

                sender.FakeClient.ReceiveCMSG(packet, true);
            }
        }
Exemplo n.º 3
0
        public static void SendPvpData(IPacketReceiver reciever, BattlegroundSide side, Battleground bg)
        {
            bg.EnsureContext();
            using (RealmPacketOut packet =
                       new RealmPacketOut(RealmServerOpCode.MSG_PVP_LOG_DATA, 10 + bg.PlayerCount * 40))
            {
                BattlegroundTeam winner = bg.Winner;
                packet.Write(bg.IsArena);
                if (bg.IsArena)
                {
                    for (int index = 0; index < 2; ++index)
                    {
                        packet.Write(0);
                        packet.Write(3999);
                        packet.Write(0);
                    }

                    packet.WriteCString(string.Empty);
                    packet.WriteCString(string.Empty);
                }

                bool flag = bg.Winner != null;
                packet.Write(flag);
                if (flag)
                {
                    packet.Write((byte)bg.Winner.Side);
                }
                List <Character>         characters = bg.Characters;
                List <BattlegroundStats> listStats  = new List <BattlegroundStats>(characters.Count);
                characters.ForEach(chr => listStats.Add(chr.Battlegrounds.Stats));
                packet.Write(listStats.Count);
                for (int index = 0; index < listStats.Count; ++index)
                {
                    Character character = characters[index];
                    if (character.IsInBattleground)
                    {
                        BattlegroundStats stats = character.Battlegrounds.Stats;
                        packet.Write(character.EntityId);
                        packet.Write(stats.KillingBlows);
                        if (bg.IsArena)
                        {
                            packet.Write(winner != null && character.Battlegrounds.Team == winner);
                        }
                        else
                        {
                            packet.Write(stats.HonorableKills);
                            packet.Write(stats.Deaths);
                            packet.Write(stats.BonusHonor);
                        }

                        packet.Write(stats.TotalDamage);
                        packet.Write(stats.TotalHealing);
                        packet.Write(stats.SpecialStatCount);
                        stats.WriteSpecialStats(packet);
                    }
                }

                reciever.Send(packet, false);
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// Send the "name is not on the channel" reply
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        public static void SendTargetNotOnChannelReply(IPacketReceiver client, string chan, string playerName)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.PlayerNotOnChannel);
                packet.WriteCString(chan);
                packet.WriteCString(playerName);

                client.Send(packet);
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Send the "wrong password" reply
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        public static void SendWrongFaction(IPacketReceiver client, string chan, string invitedName)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.InviteWrongFaction);
                packet.WriteCString(chan);
                packet.WriteCString(invitedName);

                client.Send(packet);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Send the "you have invited ... to channel" reply
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        public static void SendYouInvitedReply(IPacketReceiver client, string chan, string invitedName)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.HaveInvitedToChannel);
                packet.WriteCString(chan);
                packet.WriteCString(invitedName);

                client.Send(packet);
            }
        }
Exemplo n.º 7
0
 /// <summary>Sends result of actions connected with arenas</summary>
 /// <param name="client">the client to send to</param>
 /// <param name="commandId">command executed</param>
 /// <param name="name">name of player event has happened to</param>
 /// <param name="resultCode">The <see cref="T:WCell.Constants.ArenaTeams.ArenaTeamResult" /> result code</param>
 public static void SendResult(IPacketReceiver client, ArenaTeamCommandId commandId, string team, string player,
                               ArenaTeamResult resultCode)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_COMMAND_RESULT))
     {
         packet.WriteUInt((uint)commandId);
         packet.WriteCString(team);
         packet.WriteCString(player);
         packet.WriteUInt((uint)resultCode);
         client.Send(packet, false);
     }
 }
Exemplo n.º 8
0
        /// <summary>
        /// Sends result of actions connected with arenas
        /// </summary>
        /// <param name="client">the client to send to</param>
        /// <param name="commandId">command executed</param>
        /// <param name="name">name of player event has happened to</param>
        /// <param name="resultCode">The <see cref="ArenaTeamResult"/> result code</param>
        public static void SendResult(IPacketReceiver client, ArenaTeamCommandId commandId, string team, string player,
                                      ArenaTeamResult resultCode)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_COMMAND_RESULT))
            {
                packet.WriteUInt((uint)commandId);
                packet.WriteCString(team);
                packet.WriteCString(player);
                packet.WriteUInt((uint)resultCode);

                client.Send(packet);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sends a npc text update to the character
        /// </summary>
        /// <param name="character">recieving character</param>
        /// <param name="text">class holding all info about text</param>
        public static void SendNPCTextUpdate(Character character, IGossipEntry text)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE))
            {
                packet.Write(text.GossipId);

                var i = 0;
                for (; i < text.GossipTexts.Length; i++)
                {
                    var entry = text.GossipTexts[i];
                    packet.WriteFloat(entry.Probability);

                    var    maleText = entry.GetTextMale(character.GossipConversation);
                    string femaleText;
                    if (text.IsDynamic)
                    {
                        // generated dynamically anyway
                        femaleText = maleText;
                    }
                    else
                    {
                        femaleText = entry.GetTextFemale(character.GossipConversation);
                    }
                    packet.WriteCString(maleText);
                    packet.WriteCString(femaleText);


                    packet.Write((uint)entry.Language);

                    for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++)
                    {
                        // TODO: Emotes
                        //packet.Write((uint)entry.Emotes[emoteIndex]);
                        //packet.Write(entry.EmoteDelays[emoteIndex]);
                        packet.Write(0L);
                    }
                }

                for (; i < 8; i++)
                {
                    packet.WriteFloat(0);
                    packet.WriteByte(0);
                    packet.WriteByte(0);
                    packet.Fill(0, 4 * 7);
                }

                character.Client.Send(packet, addEnd: false);
            }
        }
Exemplo n.º 10
0
        private static RealmPacketOut CreateArenaTeamRosterResponsePacket(ArenaTeam team)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_ROSTER, 100);

            packet.WriteUInt(team.Id);
            packet.WriteByte(0);
            packet.WriteUInt(team.MemberCount);
            packet.WriteUInt(team.Type);

            foreach (var member in team.Members.Values)
            {
                packet.WriteULong(member.Character.EntityId.Full);
                var pl = World.GetCharacter(member.Character.EntityId.Low);
                packet.WriteByte((pl != null) ? 1 : 0);
                packet.WriteCString(member.Character.Name);
                packet.WriteByte((team.Leader == member) ? 0 : 1);
                packet.WriteByte((pl != null) ? pl.Level : 0);
                packet.WriteUInt((uint)member.Class);
                packet.WriteUInt(member.GamesWeek);
                packet.WriteUInt(member.WinsWeek);
                packet.WriteUInt(member.GamesSeason);
                packet.WriteUInt(member.WinsSeason);
                packet.WriteUInt(member.PersonalRating);
                packet.WriteFloat(0.0f);
                packet.WriteFloat(0.0f);
            }
            return(packet);
        }
Exemplo n.º 11
0
        /// <summary>
        /// Sends the specified character relation lists to the specified character
        /// </summary>
        /// <param name="character">The character to send the list</param>
        /// <param name="flag">Flag indicating which lists should be sent to the character</param>
        internal void SendRelationList(Character character, RelationTypeFlag flag)
        {
            Dictionary <uint, RelationListEntry> flatRelations =
                GetFlatRelations(character.EntityId.Low, flag);

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CONTACT_LIST))
            {
                packet.WriteUInt((uint)flag);
                packet.WriteUInt((uint)flatRelations.Count);
                foreach (RelationListEntry relationListEntry in flatRelations.Values)
                {
                    packet.Write(EntityId.GetPlayerId(relationListEntry.RelatedCharacterId));
                    packet.WriteUInt((uint)relationListEntry.Flag);
                    packet.WriteCString(relationListEntry.Note);
                    if (relationListEntry.Flag.HasFlag(RelationTypeFlag.Friend))
                    {
                        Character character1 = World.GetCharacter(relationListEntry.RelatedCharacterId);
                        if (character1 != null)
                        {
                            packet.WriteByte((byte)character1.Status);
                            packet.Write(character1.Zone != null ? (int)character1.Zone.Id : 0);
                            packet.Write(character1.Level);
                            packet.Write((int)character1.Class);
                        }
                        else
                        {
                            packet.WriteByte((byte)0);
                        }
                    }
                }

                character.Client.Send(packet, false);
            }
        }
Exemplo n.º 12
0
        private static RealmPacketOut CreateArenaTeamRosterResponsePacket(ArenaTeam team)
        {
            RealmPacketOut realmPacketOut =
                new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_ROSTER, 100);

            realmPacketOut.WriteUInt(team.Id);
            realmPacketOut.WriteByte(0);
            realmPacketOut.WriteUInt(team.MemberCount);
            realmPacketOut.WriteUInt(team.Type);
            foreach (ArenaTeamMember arenaTeamMember in team.Members.Values)
            {
                realmPacketOut.WriteULong(arenaTeamMember.Character.EntityId.Full);
                Character character = World.GetCharacter(arenaTeamMember.Character.EntityId.Low);
                realmPacketOut.WriteByte(character != null ? 1 : 0);
                realmPacketOut.WriteCString(arenaTeamMember.Character.Name);
                realmPacketOut.WriteByte(team.Leader == arenaTeamMember ? 0 : 1);
                realmPacketOut.WriteByte(character != null ? character.Level : 0);
                realmPacketOut.WriteUInt((uint)arenaTeamMember.Class);
                realmPacketOut.WriteUInt(arenaTeamMember.GamesWeek);
                realmPacketOut.WriteUInt(arenaTeamMember.WinsWeek);
                realmPacketOut.WriteUInt(arenaTeamMember.GamesSeason);
                realmPacketOut.WriteUInt(arenaTeamMember.WinsSeason);
                realmPacketOut.WriteUInt(arenaTeamMember.PersonalRating);
                realmPacketOut.WriteFloat(0.0f);
                realmPacketOut.WriteFloat(0.0f);
            }

            return(realmPacketOut);
        }
Exemplo n.º 13
0
        /// <summary>
        /// Sends a "name query" reply to the client.
        /// </summary>
        /// <param name="client">the client to send to</param>
        /// <param name="entity">the character information to be sent</param>
        public static void SendNameQueryReply(IPacketReceiver client, ILivingEntity entity)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NAME_QUERY_RESPONSE))
            {
                entity.EntityId.WritePacked(packet);
                packet.Write((byte)0);                 // new in 3.1.0 - this is a type, ranging from 0-3
                packet.WriteCString(entity.Name);
                packet.Write((byte)0);                 // cross realm bg name? (256 bytes max)
                packet.Write((byte)entity.Race);
                packet.Write((byte)entity.Gender);
                packet.Write((byte)entity.Class);

                packet.Write((byte)0);                 // hasDeclinedNames

                //if (hasDeclinedNames)
                //{
                //    for (int i=0;i<4;i++)
                //    {
                //        packet.WriteCString("");
                //    }
                //}


                client.Send(packet, addEnd: false);
            }
        }
Exemplo n.º 14
0
        public static void SendInvitePacket(TestCharacter inviter, string inviteeName)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.CMSG_GROUP_INVITE);

            packet.WriteCString(inviteeName);

            inviter.FakeClient.ReceiveCMSG(packet, true);
        }
Exemplo n.º 15
0
 /// <summary>
 /// Sends group invitation decline
 /// </summary>
 /// <param name="client">the client to send to</param>
 /// <param name="decliner">player who has declined your request</param>
 public static void SendGroupDecline(IPacketReceiver client, string decliner)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GROUP_DECLINE, decliner.Length + 1))
     {
         packet.WriteCString(decliner);
         client.Send(packet, addEnd: false);
     }
 }
Exemplo n.º 16
0
 /// <summary>Flashes a message in the middle of the screen.</summary>
 public static void SendNotification(IPacketReceiver client, string msg)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_NOTIFICATION))
     {
         packet.WriteCString(msg);
         client.Send(packet, false);
     }
 }
Exemplo n.º 17
0
 /// <summary>
 /// Sends a message that the whisper target wasn't found.
 /// </summary>
 /// <param name="client">the client to send to</param>
 /// <param name="recipient">the name of the target player</param>
 public static void SendChatPlayerNotFoundReply(IPacketReceiver client, string recipient)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAT_PLAYER_NOT_FOUND))
     {
         packet.WriteCString(recipient);
         client.Send(packet);
     }
 }
Exemplo n.º 18
0
 public static void SendLeaderChanged(GroupMember leader)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_GROUP_SET_LEADER))
     {
         packet.WriteCString(leader.Name);
         leader.SubGroup.Group.SendAll(packet);
     }
 }
Exemplo n.º 19
0
 public static void SendCharacterRenameSuccess(RealmClient client, EntityId guid, string newName)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 10 + newName.Length))
     {
         packet.WriteByte((byte)AccountCharacterErrorCodes.ACCNT_MANIP_OK);
         packet.Write(guid.Full);
         packet.WriteCString(newName);
         client.Send(packet);
     }
 }
Exemplo n.º 20
0
        public static void SendItemNameQueryResponse(RealmClient client, ItemTemplate item)
        {
            using (RealmPacketOut outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.Name.Length))
            {
                outPacket.WriteInt(item.Id);
                outPacket.WriteCString(item.Name);

                client.Send(outPacket);
            }
        }
Exemplo n.º 21
0
        private static void SendCreatureQueryResponse(IRealmClient client, NPCEntry entry)
        {
            var name  = entry.Names.Localize(client);
            var title = entry.Titles.Localize(client);

            using (
                var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_CREATURE_QUERY_RESPONSE,
                                             48 + name.Length + title.Length))
            {
                pkt.WriteUInt(entry.Id);
                pkt.WriteCString(name);
                pkt.Write((byte)0);                 // Name2
                pkt.Write((byte)0);                 // Name3
                pkt.Write((byte)0);                 // Name4
                pkt.WriteCString(title);
                pkt.WriteCString(entry.InfoString);
                pkt.Write((uint)entry.EntryFlags);
                pkt.Write((uint)entry.Type);
                pkt.Write((uint)entry.FamilyId);
                pkt.Write((uint)entry.Rank);
                var i = 0;
                for (; i < entry.KillCreditIds.Length; i++)
                {
                    pkt.Write(entry.KillCreditIds[i]);
                }
                for (i = 0; i < entry.DisplayIds.Length; i++)
                {
                    pkt.Write(entry.DisplayIds[i]);
                }

                pkt.Write(entry.ModHealth);                                                             // hp mod?
                pkt.Write(entry.ModMana);                                                               // mana mod?
                pkt.Write(entry.IsLeader);

                for (i = 0; i < 6; i++)
                {
                    pkt.Write(entry.QuestItems[i]);
                }
                pkt.Write(entry.MovementId);                 // id from CreatureMovementInfo.dbc

                client.Send(pkt);
            }
        }
Exemplo n.º 22
0
        /// <summary>
        /// Send the name of current of the channel
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">the channel</param>
        public static void SendCurrentOwner(IPacketReceiver client, ChatChannel chan)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.CurrentOwner);
                packet.WriteCString(chan.Name);

                if (chan.IsConstant || chan.Owner == null)
                {
                    packet.WriteCString("Nobody");
                }
                else
                {
                    packet.WriteCString(chan.Owner.User.Name);
                }

                client.Send(packet);
            }
        }
Exemplo n.º 23
0
		public static void SendItemNameQueryResponse(IPacketReceiver client, ItemTemplate item)
		{
			using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.DefaultName.Length))
			{
				outPacket.WriteInt(item.Id);
				outPacket.WriteCString(item.DefaultName);

				client.Send(outPacket);
			}
		}
Exemplo n.º 24
0
        /// <summary>
        /// Send the "you are muted" reply
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        public static void SendMutedReply(IPacketReceiver client, string chan)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.YouAreMuted);
                packet.WriteCString(chan);

                client.Send(packet);
            }
        }
Exemplo n.º 25
0
 public static void SendNameInvalid(IPacketReceiver receiver, PetNameInvalidReason reason, string name)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_NAME_INVALID))
     {
         packet.Write((uint)reason);
         packet.WriteCString(name);
         packet.WriteByte(0);
         receiver.Send(packet, false);
     }
 }
Exemplo n.º 26
0
        public static void SendItemNameQueryResponse(IPacketReceiver client, ItemTemplate item)
        {
            using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_NAME_QUERY_RESPONSE, 4 + item.DefaultName.Length))
            {
                outPacket.WriteInt(item.Id);
                outPacket.WriteCString(item.DefaultName);

                client.Send(outPacket, addEnd: false);
            }
        }
Exemplo n.º 27
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;
                }
            }

            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);
            }
        }
Exemplo n.º 28
0
 //SMSG_SERVER_FIRST_ACHIEVEMENT
 public static void SendServerFirstAchievement(AchievementEntryId achievementEntryId, Character chr)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SERVER_FIRST_ACHIEVEMENT, chr.Name.Length + 1 + 8 + 4 + 4))
     {
         packet.WriteCString(chr.Name);
         packet.Write(chr.EntityId);
         packet.WriteUInt((uint)achievementEntryId);
         packet.WriteUInt(0);
         World.Broadcast(packet);
     }
 }
Exemplo n.º 29
0
        /// <summary>
        /// Send a reply to the number of members request
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        public static void SendMemberCountReply(IPacketReceiver client, string channelName, byte channelFlags, uint memberCount)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_MEMBER_COUNT))
            {
                packet.WriteCString(channelName);
                packet.WriteByte(channelFlags);
                packet.WriteUInt(memberCount);

                client.Send(packet);
            }
        }
Exemplo n.º 30
0
        /// <summary>
        /// Send the password changed message to everyone
        /// </summary>
        /// <param name="chan">name of channel</param>
        /// <param name="sender">sender (to check the ignore list)</param>
        public static void SendPasswordChangedToEveryone(ChatChannel chan, EntityId sender)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.PasswordChanged);
                packet.WriteCString(chan.Name);
                packet.Write(sender);

                SendPacketToChannel(chan, packet, sender);
            }
        }
Exemplo n.º 31
0
        /// <summary>
        /// Send the "... has invited you to channel" message
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        /// <param name="sender">entityid of sender</param>
        public static void SendInvitedMessage(IPacketReceiver client, string chan, EntityId sender)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.BeenInvitedToChannel);
                packet.WriteCString(chan);
                packet.Write(sender);

                client.Send(packet);
            }
        }
Exemplo n.º 32
0
 /// <summary>Sends result of actions connected with groups</summary>
 /// <param name="client">the client to send to</param>
 /// <param name="resultType">The result type</param>
 /// <param name="resultCode">The <see cref="T:WCell.Constants.GroupResult" /> result code</param>
 /// <param name="name">name of player event has happened to</param>
 public static void SendResult(IPacketReceiver client, GroupResult resultCode, uint resultType, string name)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PARTY_COMMAND_RESULT))
     {
         packet.Write(resultType);
         packet.WriteCString(name);
         packet.Write((uint)resultCode);
         packet.Write(0U);
         client.Send(packet, false);
     }
 }
Exemplo n.º 33
0
        //public static void SendChannelNotify(IPacketReceiver client, string chan, EntityId targetChr, ChannelNotification notification)
        //{
        //    using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
        //    {
        //        packet.WriteByte((byte)ChannelNotification.AlreadyOnChannel);
        //        packet.WriteCString(chan);
        //        packet.Write(targetChr);

        //        client.Send(packet);
        //    }
        //}

        /// <summary>
        /// Send the "already on channel" reply
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        public static void SendAlreadyOnChannelReply(IPacketReceiver client, string chan, EntityId entityId)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.AlreadyOnChannel);
                packet.WriteCString(chan);
                packet.Write(entityId);

                client.Send(packet);
            }
        }
Exemplo n.º 34
0
		/// <summary>
		/// Sends to the specified client the Who List based on the given characters
		/// </summary>
		/// <param name="client">The client to send the list</param>
		/// <param name="characters">The list of characters that matched the Who List search</param>
		public static void SendWhoList(IPacketReceiver client, ICollection<Character> characters)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_WHO))
			{
				packet.Write(characters.Count);
				packet.Write(characters.Count);

				foreach (Character character in characters)
				{
					packet.WriteCString(character.Name);
                    packet.WriteCString(character.Guild != null ? character.Guild.Name : string.Empty); //TODO: Add Guild name here
					packet.Write(character.Level);
					packet.WriteUInt((byte)character.Class);
					packet.WriteUInt((byte)character.Race);
					packet.WriteByte(0); //New in 2.4.x
					packet.Write(character.Zone != null ? (uint)character.Zone.Id : 0);
				}
				client.Send(packet);
			}
		}
Exemplo n.º 35
0
        public void SendRequest(TestCharacter sender, uint minLevel, uint maxLevel, string playerName, 
			string guildName, RaceMask2 raceMask, ClassMask2 classMask, List<ZoneId> zones, List<string> names)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_WHO))
            {
                packet.WriteUInt(minLevel);
                packet.WriteUInt(maxLevel);
                packet.WriteCString(playerName);
                packet.WriteCString(guildName);
                packet.WriteUInt((uint)raceMask);
                packet.WriteUInt((uint)classMask);

                packet.WriteUInt(zones.Count);
                foreach (ZoneId zone in zones)
                    packet.WriteUInt((uint)zone);

                packet.WriteUInt(names.Count);
                foreach (string name in names)
                    packet.WriteCString(name);

                sender.FakeClient.ReceiveCMSG(packet, true);
            }
        }
Exemplo n.º 36
0
		public static void SendRealmStateResponse(IPacketReceiver client, uint realmNo)
		{
			//uint realmSplitState = 0;
			// realmNo = 0;
			const RealmState realmState = RealmState.Normal;
			var splitDate = "01/01/01";
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_REALM_SPLIT, 8 + 1 + splitDate.Length))
			{
				packet.WriteUInt(realmNo);
				packet.WriteUInt((uint)realmState);
				packet.WriteCString(splitDate);

				client.Send(packet);
			}
		}
Exemplo n.º 37
0
        private static RealmPacketOut CreateArenaTeamQueryResponsePacket(ArenaTeam team)
		{
			var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_QUERY_RESPONSE, 4*7+team.Name.Length+1);

            packet.WriteUInt((byte)team.Id);
            packet.WriteCString(team.Name);
            packet.WriteUInt(team.Type);

            /* TO-DO : Implement Emblem
             * packet.WriteUInt(team.Emblem.backgroundColor);
            packet.WriteUInt(team.Emblem.emblemStyle);
            packet.WriteUInt(team.Emblem.emblemColor);
            packet.WriteUInt(team.Emblem.borderStyle);
            packet.WriteUInt(team.Emblem.borderColor);
             */

            return packet;
        }
Exemplo n.º 38
0
		public void SendMessage(string message)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT))
			{
				packet.Write((byte)ChatMsgType.Channel);
				packet.Write((uint)ChatLanguage.Common);
				packet.Write(EntityId.Zero);
				packet.WriteCString("");
				packet.Write(EntityId.Zero);
				packet.WriteUIntPascalString(message);
				packet.Write((byte)ChatTag.None); // chat tag

				ChannelHandler.SendPacketToChannel(this, packet);
			}

			ChatMgr.ChatNotify(null, message, ChatLanguage.Common, ChatMsgType.Channel, this);
		}
Exemplo n.º 39
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="client"></param>
		/// <param name="ticket">Can be null</param>
		public static void SendGetTicketResponse(IPacketReceiver client, Ticket ticket)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GMTICKET_GETTICKET))
			{
				if (ticket != null)
				{
					packet.Write((uint)TicketInfoResponse.Pending);
					packet.WriteCString(ticket.Message);
					packet.Write((byte)ticket.Type);
					packet.Write((float)0);
					packet.Write((float)0);
					packet.Write((float)0);
					packet.Write((ushort)0);
					client.Send(packet);
				}
				else
				{
					packet.Write((uint)TicketInfoResponse.NoTicket);
				}
			}
		}
Exemplo n.º 40
0
		public static void SendNameInvalid(IPacketReceiver receiver, PetNameInvalidReason reason, string name)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_NAME_INVALID))
			{
				packet.Write((uint)reason);
				packet.WriteCString(name);
				packet.WriteByte(0);

				receiver.Send(packet);
			}
		}
Exemplo n.º 41
0
		public static void SendName(IPacketReceiver receiver, uint petId, string name, uint timestamp)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_NAME_QUERY_RESPONSE, 9 + name.Length))
			{
				packet.Write(petId);
				packet.WriteCString(name);
				packet.Write(timestamp);
				packet.Write((byte)0);			// 3.2.0

				receiver.Send(packet);
			}
		}
Exemplo n.º 42
0
		/// <summary>
		/// Flashes a message in the middle of the screen.
		/// </summary>
		public static void SendNotification(IPacketReceiver client, string msg)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NOTIFICATION))
			{
				packet.WriteCString(msg);
				client.Send(packet);
			}
		}
Exemplo n.º 43
0
		/// <summary>
		/// Sends the given list of messages as motd (displays as a regular system-msg)
		/// </summary>
		public static void SendMotd(IPacketReceiver client, params string[] messages)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MOTD, 4 + messages.Length * 20))
			{
				packet.Write(messages.Length);
				foreach (var msg in messages)
				{
					packet.WriteCString(msg);
				}

				client.Send(packet);
			}
		}
Exemplo n.º 44
0
        public static void SendPetitionRename(IPacketReceiver client, PetitionCharter petition)
        {
            var name = petition.Petition.Name;
            using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_PETITION_RENAME, 8 + name.Length + 1))
            {
                packet.WriteULong(petition.EntityId.Full);
                packet.WriteCString(name);

                client.Send(packet);
            }
        }
Exemplo n.º 45
0
		/// <summary>
		/// Sends a message that the whisper target wasn't found.
		/// </summary>
		/// <param name="client">the client to send to</param>
		/// <param name="recipient">the name of the target player</param>
		public static void SendChatPlayerNotFoundReply(IPacketReceiver client, string recipient)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAT_PLAYER_NOT_FOUND))
			{
				packet.WriteCString(recipient);
				client.Send(packet);
			}
		}
Exemplo n.º 46
0
		private static void WriteTargets(RealmPacketOut packet, SpellCast cast)
		{
			var flags = cast.TargetFlags;
			if (flags == 0 || flags == SpellTargetFlags.Self)
			{
				var spell = cast.Spell;
				if (cast.Selected is Unit && !spell.IsAreaSpell &&
					(spell.Visual != 0 || spell.IsWeaponAbility))
				{
					flags = SpellTargetFlags.Unit;
				}
			}
			packet.Write((uint)flags);
			if (flags.Has(
				SpellTargetFlags.SpellTargetFlag_Dynamic_0x10000 |
				SpellTargetFlags.Corpse |
				SpellTargetFlags.Object |
				SpellTargetFlags.PvPCorpse |
				SpellTargetFlags.Unit))
			{
				if (cast.Selected == null)
				{
#if DEBUG
					log.Warn("{0} casted Spell {1} with TargetFlags {2} but with nothing Selected",
						cast.Caster, cast.Spell, flags);
#endif
					packet.Write((byte)0);
				}
				else
				{
					cast.Selected.EntityId.WritePacked(packet);
				}
			}
			// 0x1010
			if (flags.Has(SpellTargetFlags.TradeItem | SpellTargetFlags.Item))
			{
				if (cast.UsedItem != null)
				{
					cast.UsedItem.EntityId.WritePacked(packet);
				}
			}
			// 0x20
			if (flags.Has(SpellTargetFlags.SourceLocation))
			{
				if (cast.Selected != null)
				{
					cast.Selected.EntityId.WritePacked(packet);
				}
				else
				{
					packet.Write((byte)0);
				}
				packet.Write(cast.SourceLoc.X);
				packet.Write(cast.SourceLoc.Y);
				packet.Write(cast.SourceLoc.Z);
			}
			// 0x40
			if (flags.Has(SpellTargetFlags.DestinationLocation))
			{
				if (cast.Selected != null)
				{
					cast.Selected.EntityId.WritePacked(packet);
				}
				else
				{
					packet.Write((byte)0);
				}
				packet.Write(cast.TargetLoc);
			}
			// 0x2000
			if (flags.Has(SpellTargetFlags.String))
			{
				packet.WriteCString(cast.StringTarget);
			}
		}
Exemplo n.º 47
0
		/// <summary>
		/// Sends the quest giver quest detail.
		/// </summary>
		/// <param name="questGiver">The qg.</param>
		/// <param name="qt">The quest id.</param>
		/// <param name="chr">The client.</param>
		/// <param name="acceptable">if set to <c>true</c> [acceptable].</param>
		public static void SendDetails(IEntity questGiver, QuestTemplate qt, Character chr, bool acceptable)
		{
			var locale = chr.Locale;
			using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_QUEST_DETAILS))
			{
				if (questGiver != null)
				{
					pckt.Write(questGiver.EntityId);
				}
				else
				{
					pckt.Write(EntityId.Zero);
				}

				pckt.Write(EntityId.Zero);		// unknown, wotlk, quest sharing?

				pckt.Write(qt.Id);

				pckt.WriteCString(qt.Titles.Localize(locale));
				pckt.WriteCString(qt.Details.Localize(locale));
				pckt.WriteCString(qt.Instructions.Localize(locale));


				pckt.Write((byte)(acceptable ? 1 : 0));
			    pckt.Write((uint)qt.Flags);
				pckt.Write(qt.SuggestedPlayers);
				pckt.Write((byte)0); // probably some pvp flag

				pckt.Write(qt.RewardChoiceItems.Length);
				for (uint i = 0; i < qt.RewardChoiceItems.Length; i++)
				{
					pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
					pckt.Write(qt.RewardChoiceItems[i].Amount);
					var template = qt.RewardChoiceItems[i].Template;
					if (template != null)
					{
						pckt.Write(template.DisplayId);
					}
					else
					{
						pckt.Write(0);
					}
				}

				pckt.Write(qt.RewardItems.Length);
				for (uint i = 0; i < qt.RewardItems.Length; i++)
				{
					pckt.Write((uint)qt.RewardItems[i].ItemId);
					pckt.Write(qt.RewardItems[i].Amount);

					var template = qt.RewardItems[i].Template;
					if (template != null)
					{
						pckt.Write(template.DisplayId);
					}
					else
					{
						pckt.Write(0);
					}
				}

				if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
				{
					pckt.Write(0);
				}
				else
				{
					pckt.Write(qt.RewMoney);
				}

				pckt.Write(0);						// since 3.3
				pckt.Write(10 * qt.BonusHonor);
				pckt.Write(0f);						// since 3.3
				pckt.Write((uint)qt.RewSpell);
				pckt.Write((uint)qt.CastSpell);
				pckt.Write(qt.RewardTitleId);		// since 2.4.0
				pckt.Write(qt.RewardTalents);

				// #### since 3.3
				pckt.Write(0);						// bonus arena points
				pckt.Write(0);
				for (uint i = 0; i < QuestConstants.MaxReputations; i++)
				{
					pckt.Write(0);
					pckt.Write(0);
					pckt.Write(0);
				}
				// ###########


				// qt.QuestDetailsEmotes
				//TODO FIX UP! and include to quest template
				/*pckt.Write((uint)4); // quantity of emotes, always four
				pckt.Write((uint)1); // emote id 1
				pckt.Write((uint)0); // emote delay or player emote
				pckt.Write((uint)0); // emote id 2
				pckt.Write((uint)0); // emote delay
				pckt.Write((uint)0); // emote id 3
				pckt.Write((uint)0); // emote delay
				pckt.Write((uint)0); // emote id 4
				pckt.Write((uint)0); // emote delay
                */

				pckt.Write(qt.QuestDetailedEmotes.Length);
				for (var i = 0; i < qt.QuestDetailedEmotes.Length; i++)
				{
					var emote = qt.QuestDetailedEmotes[i];
					pckt.Write((int) emote.Type);
					pckt.Write(emote.Delay);
				}
				chr.Client.Send(pckt);
			}
		}
Exemplo n.º 48
0
        /// <summary>
        /// Sends the quest giver quest list.
        /// </summary>
        /// <param name="qHolder">The quest giver.</param>
        /// <param name="list">The list.</param>
        /// <param name="chr">The character.</param>
        public static void SendQuestList(IQuestHolder qHolder, List<QuestTemplate> list, Character chr)
        {
            using (var pkt = new RealmPacketOut(new PacketId(RealmServerOpCode.SMSG_QUESTGIVER_QUEST_LIST)))
            {
                pkt.Write(qHolder.EntityId);
                if (qHolder.QuestHolderInfo != null)
                {
                    pkt.Write("Stay a while and listen..."); // TODO need to change to dynamic text, character-dependant
                    pkt.Write((uint)0); // player emote
                    pkt.Write((uint)1); // npc emote

                    var amount = Math.Min(QuestConstants.MaxQuestsPerQuestGiver, list.Count);
                    pkt.Write((byte)amount);

                    foreach (var qt in list)
                    {
                        pkt.Write(qt.Id);
                        var quest = chr.QuestLog.GetActiveQuest(qt.Id);
                        if (quest != null)
                        {
                            if (quest.CompleteStatus == QuestCompleteStatus.Completed)
                            {
                                //status = (uint)qt.GetEndStatus(qHolder.QuestHolderInfo, chr);
                                pkt.Write(4);
                            }
                            else
                            {
                                pkt.Write((uint)QuestStatus.NotCompleted);
                            }
                        }
                        else
                        {
                            var status = (uint)qt.GetAvailability(chr);
                            pkt.Write(status);
                        }
                        pkt.WriteUInt(qt.Level);
                        pkt.WriteUInt((uint)qt.Flags);
                        pkt.Write((byte)0); // 3.3.3 question/exclamation mark
                        pkt.WriteCString(qt.DefaultTitle);
                    }
                    chr.Client.Send(pkt);
                }
            }
        }
Exemplo n.º 49
0
        /// <summary>
        /// Sends the quest giver quest detail.
        /// </summary>
        /// <param name="questGiver">The qg.</param>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        /// <param name="acceptable">if set to <c>true</c> [acceptable].</param>
        public static void SendDetails(IEntity questGiver, QuestTemplate qt, Character chr, bool acceptable)
        {
            var locale = chr.Locale;
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_QUEST_DETAILS))
            {
                pckt.Write(questGiver != null ? questGiver.EntityId : EntityId.Zero);

                pckt.Write(EntityId.Zero);						// unknown, wotlk, quest sharing?

                pckt.Write(qt.Id);

                pckt.WriteCString(qt.Titles.Localize(locale));
                pckt.WriteCString(qt.Details.Localize(locale));
                pckt.WriteCString(qt.Instructions.Localize(locale));


                pckt.Write((byte)(acceptable ? 1 : 0));			// doesn't work
                pckt.WriteUInt((uint)qt.Flags);
                pckt.WriteUInt(qt.SuggestedPlayers);
                pckt.Write((byte)0); // probably some pvp flag
                if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
                {
                    pckt.WriteUInt(0u);		// choice items length
                    pckt.WriteUInt(0u);		// reward items length
                    pckt.WriteUInt(0u);		// money
                    pckt.WriteUInt(0u);		// xp
                }
                else
                {
                    pckt.Write(qt.RewardChoiceItems.Length);
                    for (uint i = 0; i < qt.RewardChoiceItems.Length; i++)
                    {
                        pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
                        pckt.Write(qt.RewardChoiceItems[i].Amount);
                        var template = qt.RewardChoiceItems[i].Template;
                        if (template != null)
                        {
                            pckt.Write(template.DisplayId);
                        }
                        else
                        {
                            pckt.Write(0);
                        }
                    }

                    pckt.Write(qt.RewardItems.Length);
                    for (uint i = 0; i < qt.RewardItems.Length; i++)
                    {
                        pckt.Write((uint)qt.RewardItems[i].ItemId);
                        pckt.Write(qt.RewardItems[i].Amount);

                        var template = qt.RewardItems[i].Template;
                        if (template != null)
                        {
                            pckt.Write(template.DisplayId);
                        }
                        else
                        {
                            pckt.Write(0);
                        }
                    }

                    if (chr.Level >= RealmServerConfiguration.MaxCharacterLevel)
                    {
                        pckt.Write(qt.MoneyAtMaxLevel);
                    }
                    else
                    {
                        pckt.Write(qt.RewMoney);
                    }

                    pckt.Write(qt.CalcRewardXp(chr));						// since 3.3
                }

                pckt.Write(qt.RewHonorAddition);
                pckt.Write(qt.RewHonorMultiplier);						// since 3.3
                if (qt.RewSpell > 0)
                {
                    pckt.Write((uint)qt.RewSpell);
                }
                else
                {
                    pckt.Write((uint)qt.RewSpellCast);
                }
                pckt.Write((uint)qt.CastSpell);
                pckt.Write((uint)qt.RewardTitleId);		// since 2.4.0
                pckt.Write(qt.RewardTalents);

                // #### since 3.3
                pckt.Write(0);						// bonus arena points
                pckt.Write(0);
                for (uint i = 0; i < QuestConstants.MaxReputations; ++i)
                {
                    pckt.Write((uint)qt.RewardReputations[i].Faction);
                }
                for (uint i = 0; i < QuestConstants.MaxReputations; ++i)
                {
                    pckt.Write(qt.RewardReputations[i].ValueId);
                }
                for (uint i = 0; i < QuestConstants.MaxReputations; ++i)
                {
                    pckt.Write(qt.RewardReputations[i].Value);
                }

                pckt.Write(QuestConstants.MaxEmotes);
                for (var i = 0; i < QuestConstants.MaxEmotes; i++)
                {
                    var emote = qt.QuestDetailedEmotes[i];
                    pckt.Write((int)emote.Type);
                    pckt.Write(emote.Delay);
                }
                chr.Client.Send(pckt);
            }
        }
Exemplo n.º 50
0
        public static void SendItemQueryResponse(IRealmClient client, ItemTemplate item)
        {
            var locale = client.Info.Locale;
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630))
            {
                packet.Write(item.Id);
                packet.Write((uint)item.Class);
                packet.Write((uint)item.SubClass);
                packet.Write(item.Unk0); // unknown

                packet.WriteCString(item.Names.Localize(locale));
                packet.Write((byte)0);// name2
                packet.Write((byte)0);// name3
                packet.Write((byte)0);// name4

                packet.Write(item.DisplayId);
                packet.Write((uint)item.Quality);
                packet.Write((uint)item.Flags);
                packet.Write((uint)item.Flags2);		// new 3.2.0
                packet.Write(item.BuyPrice);
                packet.Write(item.SellPrice);
                packet.Write((uint)item.InventorySlotType);
                packet.Write((uint)item.RequiredClassMask);
                packet.Write((uint)item.RequiredRaceMask);
                packet.Write(item.Level);
                packet.Write(item.RequiredLevel);
                packet.Write(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0);
                packet.Write(item.RequiredSkillValue);
                packet.Write(item.RequiredProfession != null ? item.RequiredProfession.Id : 0);
                packet.Write(item.RequiredPvPRank);
                packet.Write(item.UnknownRank);// PVP Medal
                packet.Write(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0);
                packet.Write((uint)item.RequiredFactionStanding);
                packet.Write(item.UniqueCount);
                packet.Write(item.MaxAmount);
                packet.Write(item.ContainerSlots);

                packet.Write(item.Mods.Length);
                for (var m = 0; m < item.Mods.Length; m++)
                {
                    packet.Write((uint)item.Mods[m].Type);
                    packet.Write(item.Mods[m].Value);
                }

                packet.Write(item.ScalingStatDistributionId);// NEW 3.0.2 ScalingStatDistribution.dbc
                packet.Write(item.ScalingStatValueFlags);// NEW 3.0.2 ScalingStatFlags

                // In 3.1 there are only 2 damages instead of 5
                for (var i = 0; i < ItemConstants.MaxDmgCount; i++)
                {
                    if(i >= item.Damages.Length)
                    {
                        packet.WriteFloat(0f);
                        packet.WriteFloat(0f);
                        packet.WriteUInt(0u);
                        continue;
                    }

                    var dmg = item.Damages[i];

                    packet.Write(dmg.Minimum);
                    packet.Write(dmg.Maximum);
                    packet.Write((uint)dmg.School);
                }

                for (var i = 0; i < ItemConstants.MaxResCount; i++)
                {
                    var res = item.Resistances[i];
                    packet.Write(res);
                }

                packet.Write(item.AttackTime);
                packet.Write((uint)item.ProjectileType);
                packet.Write(item.RangeModifier);

                for (var s = 0; s < ItemConstants.MaxSpellCount; s++)
                {
                    ItemSpell spell;
                    if(s < item.Spells.Length && (spell = item.Spells[s]) != null)
                    {
                        packet.Write((uint)spell.Id);
                        packet.Write((uint)spell.Trigger);
                        packet.Write((uint)Math.Abs(spell.Charges));
                        packet.Write(spell.Cooldown);
                        packet.Write(spell.CategoryId);
                        packet.Write(spell.CategoryCooldown);
                    }
                    else
                    {
                        packet.WriteUInt(0u);
                        packet.WriteUInt(0u);
                        packet.WriteUInt(0u);
                        packet.Write(-1);
                        packet.WriteUInt(0u);
                        packet.Write(-1);
                    }
                }

                packet.Write((uint)item.BondType);
                packet.WriteCString(item.Descriptions.Localize(locale));

                packet.Write(item.PageTextId);
                packet.Write((uint)item.LanguageId);
                packet.Write((uint)item.PageMaterial);
                packet.Write(item.QuestId);
                packet.Write(item.LockId);
                packet.Write((int)item.Material);
                packet.Write((uint)item.SheathType);
                packet.Write(item.RandomPropertiesId);
                packet.Write(item.RandomSuffixId);
                packet.Write(item.BlockValue);
                packet.Write((uint)item.SetId);
                packet.Write(item.MaxDurability);
                packet.Write((uint)item.ZoneId);
                packet.Write((uint)item.MapId);
                packet.Write((uint)item.BagFamily);
                packet.Write((uint)item.ToolCategory);

                for (var i = 0; i < ItemConstants.MaxSocketCount; i++)
                {
                    packet.Write((uint)item.Sockets[i].Color);
                    packet.Write(item.Sockets[i].Content);
                }

                packet.Write(item.SocketBonusEnchantId);
                packet.Write(item.GemPropertiesId);
                packet.Write(item.RequiredDisenchantingLevel);
                packet.Write(item.ArmorModifier);

                packet.Write(item.Duration);// Exisiting duration in seconds
                packet.Write(item.ItemLimitCategoryId);// NEW 3.0.2 ItemLimitCategory.dbc

                packet.Write(item.HolidayId); // NEW 3.1.0 Holidays.dbc

                client.Send(packet);
            }
        }
Exemplo n.º 51
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;
			}

			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);
			}
		}
Exemplo n.º 52
0
        public void TestParsedSegment()
        {
            PacketDefinition def = new PacketDefinition(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT, PacketSender.Client,
                new PacketSegmentStructure(SimpleType.UInt, "SpellAttributes", typeof(SpellAttributes)),
                new ListPacketSegmentStructure(SimpleType.Byte, "Members",
                    new PacketSegmentStructure(SimpleType.Guid, "MemberId"),
                    new PacketSegmentStructure(SimpleType.CString, "Name")
                ),

                new SwitchPacketSegmentStructure("Attribute Switch", "SpellAttributes",
                    new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat,
                        new PacketSegmentStructure(SimpleType.CString, "NoCombatString")
                    ),
                    new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat | SpellAttributes.CastableWhileMounted,
                        new PacketSegmentStructure(SimpleType.CString, "NoCombatNoDismountString")
                    )
                ),

                new SwitchPacketSegmentStructure("List Switch", "Members",
                    new SwitchCase(ComparisonType.Equal, (byte)0,
                        new PacketSegmentStructure(SimpleType.Byte, "Status", "CharacterStatus"),
                        new SwitchPacketSegmentStructure("Nested Switch", "Status",
                            new SwitchCase(ComparisonType.AndNot, CharacterStatus.OFFLINE,
                                new PacketSegmentStructure(SimpleType.UInt, "NumX")
                            )
                        )
                    ),
                    new SwitchCase(ComparisonType.GreaterThan, (byte)0,
                        new PacketSegmentStructure(SimpleType.CString, "Info")
                    )
                ),

                new StaticListPacketSegmentStructure(1, "StaticList1",
                    new PacketSegmentStructure(SimpleType.Int, "Number1")
                ),

                new StaticListPacketSegmentStructure(2, "StaticList2",
                    new PacketSegmentStructure(SimpleType.Int, "Number2")
                ),

                new PacketSegmentStructure(SimpleType.Byte, "ListLength"),

                new ListPacketSegmentStructure("SomeList3", "ListLength",
                    new PacketSegmentStructure(SimpleType.Int, "SomeListEle")
                )
            );

            def.Init();

            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
            {
                packet.WriteUInt((uint)(SpellAttributes.CastableWhileMounted | SpellAttributes.CannotBeCastInCombat));
                packet.WriteByte(2);

                packet.Write(EntityId.Zero);
                packet.WriteCString("Member1Name");

                packet.Write(new EntityId(10));
                packet.WriteCString("Member2Name");

                packet.WriteCString("NoCombat");
                packet.WriteCString("NoCombatNoDismount");

                packet.WriteCString("lotsofinfo");

                // StaticList1
                packet.WriteInt(10);

                // StaticList2
                packet.WriteInt(20);
                packet.WriteInt(30);

                // SomeList3's length
                packet.WriteByte(2);
                // SomeList3
                packet.WriteInt(5);
                packet.WriteInt(7);

                var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);

                Assert.AreEqual("NoCombat", parsedPacket["NoCombatString"].StringValue);
                Assert.AreEqual("NoCombatNoDismount", parsedPacket["NoCombatNoDismountString"].StringValue);

                var members = parsedPacket["Members"];
                Assert.AreEqual(EntityId.Zero, members[0]["MemberId"].EntityIdValue);
                Assert.AreEqual("Member1Name", members[0]["Name"].StringValue);
                Assert.AreEqual("Member2Name", members[1]["Name"].StringValue);
                Assert.AreEqual("lotsofinfo", parsedPacket["Info"].StringValue);
                CheckRemainder(parsedPacket);
            }

            using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT))
            {
                packet.WriteUInt((uint)SpellAttributes.None);
                packet.WriteByte(0);

                packet.Write((byte)CharacterStatus.ONLINE);
                packet.Write((uint)1234);

                packet.WriteInt(10);

                packet.WriteInt(20);
                packet.WriteInt(30);

                // SomeList3's length
                packet.WriteByte(2);
                // SomeList3
                packet.WriteInt(5);
                packet.WriteInt(7);

                var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def);

                Assert.IsNull(parsedPacket.GetByName("Info"));

                Assert.AreEqual(CharacterStatus.ONLINE, parsedPacket["Status"].Value);
                Assert.AreEqual((uint)1234, parsedPacket["NumX"].Value);

                CheckRemainder(parsedPacket);
            }
        }
Exemplo n.º 53
0
 public static void SendLeaderChanged(GroupMember leader)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GROUP_SET_LEADER))
     {
         packet.WriteCString(leader.Name);
         leader.SubGroup.Group.SendAll(packet);
     }
 }
Exemplo n.º 54
0
		public static void SendPetitionQueryResponse(IPacketReceiver client, PetitionCharter charter)
		{
            string name = charter.Petition.Name;
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PETITION_QUERY_RESPONSE, 4 + 8 + name.Length + 1 + 1 + 4 * 12 + 2 + 10))
			{
                packet.WriteUInt(charter.EntityId.Low);
                packet.WriteULong(charter.Owner.EntityId.Full);
                packet.WriteCString(name);
                packet.WriteByte(0);

                var type = (uint)charter.Petition.Type;
                if(type == (uint)PetitionType.Guild)
                {
                    packet.WriteUInt(type);
                    packet.WriteUInt(type);
                    packet.WriteUInt(0);
                }
                else
                {
                    packet.WriteUInt(type-1);
                    packet.WriteUInt(type-1);
                    packet.WriteUInt(type);
                }
                packet.WriteUInt(0);
                packet.WriteUInt(0);
                packet.WriteUInt(0);
                packet.WriteUInt(0);
                packet.WriteUShort(0);
                packet.WriteUInt(0);
                packet.WriteUInt(0);
                packet.WriteUInt(0);

                for(int i = 0; i < 10; ++i)
                    packet.WriteByte(0);

                packet.WriteUInt(0);

                if(type == (uint)PetitionType.Guild)
                    packet.WriteUInt(0);
                else
                    packet.WriteUInt(1);

                client.Send(packet);
			}
		}
Exemplo n.º 55
0
        /// <summary>
        /// Sends the quest query response.
        /// </summary>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        public static void SendQuestQueryResponse(QuestTemplate qt, Character chr)
        {
            var locale = chr.Client.Info.Locale;
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUEST_QUERY_RESPONSE))
            {
                pckt.Write(qt.Id);
                pckt.Write((uint)qt.IsActive);
                pckt.Write(qt.Level);
                pckt.Write(qt.MinLevel);			// since 3.3
                pckt.Write(qt.Category);			// questsort
                pckt.Write((uint)qt.QuestType);
                pckt.Write(qt.SuggestedPlayers);
                pckt.Write((uint)qt.ObjectiveMinReputation.ReputationIndex);
                pckt.Write(qt.ObjectiveMinReputation.Value);
                pckt.Write((uint)qt.ObjectiveMaxReputation.ReputationIndex);
                pckt.Write(qt.ObjectiveMaxReputation.Value);				//  (#10)

                pckt.Write(qt.FollowupQuestId);
                pckt.Write(qt.CalcRewardXp(chr));										// since 3.3

                if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
                {
                    pckt.Write(0);
                }
                else
                {
                    pckt.Write(qt.RewMoney);
                }
                pckt.Write(qt.MoneyAtMaxLevel);
                pckt.Write((uint)qt.CastSpell);
                if (qt.RewSpell > 0)
                {
                    pckt.Write((uint)qt.RewSpell);
                }
                else
                {
                    pckt.Write((uint)qt.RewSpellCast);
                }

                pckt.Write(qt.RewHonorAddition);
                pckt.WriteFloat(qt.RewHonorMultiplier);										// since 3.3

                pckt.Write((uint)qt.SrcItemId);
                pckt.Write((uint)qt.Flags);
                pckt.Write((uint)qt.RewardTitleId);
                pckt.Write(qt.PlayersSlain);
                pckt.Write(qt.RewardTalents);// NEW 3.0.2 RewardTalentCount (#21)
                pckt.Write(0);										// since 3.3: bonus arena points
                pckt.Write(0);										// since 3.3

                int i;
                if (qt.Flags.HasFlag(QuestFlags.HiddenRewards))
                {
                    for (i = 0; i < QuestConstants.MaxRewardItems; ++i)
                    {
                        pckt.WriteUInt(0u);
                        pckt.WriteUInt(0u);
                    }
                    for (i = 0; i < QuestConstants.MaxRewardChoiceItems; ++i)
                    {
                        pckt.WriteUInt(0u);
                        pckt.WriteUInt(0u);
                    }
                }
                else
                {
                    for (i = 0; i < QuestConstants.MaxRewardItems; i++)
                    {
                        if (i < qt.RewardItems.Length)
                        {
                            pckt.Write((uint)qt.RewardItems[i].ItemId);
                            pckt.Write(qt.RewardItems[i].Amount);
                        }
                        else
                        {
                            pckt.WriteUInt(0u);
                            pckt.WriteUInt(0u);
                        }
                    }

                    for (i = 0; i < QuestConstants.MaxRewardChoiceItems; i++)
                    {
                        if (i < qt.RewardChoiceItems.Length)
                        {
                            pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
                            pckt.Write(qt.RewardChoiceItems[i].Amount);
                        }
                        else
                        {
                            pckt.WriteUInt(0u);
                            pckt.WriteUInt(0u);
                        }
                    }
                }
                // #### since 3.3
                for (i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write((uint)qt.RewardReputations[i].Faction);
                for (i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].ValueId);
                for (i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].Value);

                //     ######

                pckt.Write((uint)qt.MapId);
                pckt.Write(qt.PointX);
                pckt.Write(qt.PointY);
                pckt.Write(qt.PointOpt);

                pckt.WriteCString(qt.Titles.Localize(locale));
                pckt.WriteCString(qt.Instructions.Localize(locale));
                pckt.WriteCString(qt.Details.Localize(locale));
                pckt.WriteCString(qt.EndTexts.Localize(locale));
                pckt.WriteCString(qt.CompletedTexts.Localize(locale));												// since 3.3

                for (i = 0; i < QuestConstants.MaxObjectInteractions; i++)
                {
                    pckt.Write(qt.ObjectOrSpellInteractions[i].RawId);		// Mob or GO entry ID [i]
                    pckt.Write(qt.ObjectOrSpellInteractions[i].Amount);	// amount [i],
                    pckt.Write((uint)qt.CollectableSourceItems[i].ItemId);
                    pckt.Write(qt.CollectableSourceItems[i].Amount);
                }

                for (i = 0; i < QuestConstants.MaxCollectableItems; i++)
                {
                    if (i < qt.CollectableItems.Length)
                    {
                        pckt.Write((uint)qt.CollectableItems[i].ItemId);
                        pckt.Write(qt.CollectableItems[i].Amount);
                    }
                    else
                    {
                        pckt.WriteUInt(0u);
                        pckt.WriteUInt(0u);
                    }
                }

                for (i = 0; i < QuestConstants.MaxObjectiveTexts; i++)
                {
                    var set = qt.ObjectiveTexts[(int)locale];
                    if (set != null)
                    {
                        pckt.Write(set.Texts[i]);
                    }
                    else
                    {
                        pckt.Write("");
                    }
                }
                chr.Client.Send(pckt);
            }
        }
Exemplo n.º 56
0
 /// <summary>
 /// Send Group Invite packet
 /// </summary>
 /// <param name="client">realm client</param>
 /// <param name="inviter">nick of player invited you</param>
 public static void SendGroupInvite(IPacketReceiver client, string inviter)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GROUP_INVITE, inviter.Length + 10))
     {
         packet.Write((byte)1);		// unknown since Wotlk
         packet.WriteCString(inviter);
         packet.Write((uint)0); //333a
         packet.Write((byte)0); //333a
         packet.Write((uint)0); //333a
         client.Send(packet);
     }
 }
Exemplo n.º 57
0
        /// <summary>
        /// Offers the reward of the given Quest to the given Character.
        /// When replying the Quest will be complete.
        /// </summary>
        /// <param name="questGiver">The qg.</param>
        /// <param name="qt">The quest id.</param>
        /// <param name="chr">The client.</param>
        public static void SendQuestGiverOfferReward(IEntity questGiver, QuestTemplate qt, Character chr)
        {
            //if (questGiver.QuestHolderInfo != null)

            //var list = qg.QuestHolderInfo.QuestEnds;
            //if (list != null && list.Contains(qt))

            var locale = chr.Locale;
            using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_OFFER_REWARD))
            {
                pckt.Write(questGiver.EntityId);
                pckt.WriteUInt(qt.Id);
                pckt.WriteCString(qt.Titles.Localize(locale));
                pckt.WriteCString(qt.OfferRewardTexts.Localize(locale));
                pckt.WriteByte((byte)(qt.FollowupQuestId > 0 ? 1 : 0));

                pckt.WriteUInt((uint)qt.Flags);
                pckt.WriteUInt(qt.SuggestedPlayers); // Suggested Group Num

                pckt.Write(qt.OfferRewardEmotes.Length);
                for (uint i = 0; i < qt.OfferRewardEmotes.Length; i++)
                {
                    pckt.Write(qt.OfferRewardEmotes[i].Delay);
                    pckt.Write((uint)qt.OfferRewardEmotes[i].Type);
                }

                pckt.Write(qt.RewardChoiceItems.Length);
                for (var i = 0; i < qt.RewardChoiceItems.Length; i++)
                {
                    pckt.Write((uint)qt.RewardChoiceItems[i].ItemId);
                    pckt.Write(qt.RewardChoiceItems[i].Amount);
                    var template = qt.RewardChoiceItems[i].Template;
                    if (template != null)
                    {
                        pckt.Write(template.DisplayId);
                    }
                    else
                    {
                        pckt.Write(0);
                    }
                }

                pckt.Write(qt.RewardItems.Length);
                for (var i = 0; i < qt.RewardItems.Length; i++)
                {
                    pckt.Write((uint)qt.RewardItems[i].ItemId);
                    pckt.Write(qt.RewardItems[i].Amount);
                    var template = qt.RewardItems[i].Template;
                    if (template != null)
                    {
                        pckt.WriteUInt(template.DisplayId);
                    }
                    else
                    {
                        pckt.Write(0);
                    }
                }

                if (chr.Level >= RealmServerConfiguration.MaxCharacterLevel)
                {
                    pckt.Write(qt.MoneyAtMaxLevel);
                }
                else
                {
                    pckt.Write(qt.RewMoney);
                }

                pckt.Write(qt.CalcRewardXp(chr));
                pckt.Write(qt.CalcRewardHonor(chr)); // honor points
                pckt.Write(qt.RewHonorMultiplier); // since 3.3

                pckt.Write((uint)0x08); // unused by client
                if (qt.RewSpell > 0)
                {
                    pckt.Write((uint)qt.RewSpell);
                }
                else
                {
                    pckt.Write((uint)qt.RewSpellCast);
                }
                pckt.Write((uint)qt.CastSpell);
                pckt.Write((uint)qt.RewardTitleId);
                pckt.Write(qt.RewardTalents); // reward talents
                pckt.Write(0); // since 3.3
                pckt.Write(0); // since 3.3

                // #### since 3.3
                for (uint i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write((uint)qt.RewardReputations[i].Faction);
                for (uint i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].ValueId);
                for (uint i = 0; i < QuestConstants.MaxReputations; i++)
                    pckt.Write(qt.RewardReputations[i].Value);

                //     ######

                chr.Client.Send(pckt);
            }
        }
Exemplo n.º 58
0
 /// <summary>
 /// Sends group invitation decline
 /// </summary>
 /// <param name="client">the client to send to</param>
 /// <param name="decliner">player who has declined your request</param>
 public static void SendGroupDecline(IPacketReceiver client, string decliner)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GROUP_DECLINE, decliner.Length + 1))
     {
         packet.WriteCString(decliner);
         client.Send(packet);
     }
 }
Exemplo n.º 59
0
        public static void SendPvpData(IPacketReceiver reciever, BattlegroundSide side, Battleground bg)
        {
            bg.EnsureContext();

            using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_PVP_LOG_DATA, 10 + bg.PlayerCount * 40))
            {
            	var winner = bg.Winner;

                packet.Write(bg.IsArena);
                if (bg.IsArena)
                {
                    // TODO: Arena
                    for (var i = 0; i < 2; i++)
                    {
                        packet.Write(0); // old rating
                        packet.Write(3999); // new rating (3000 + diff)
                        packet.Write(0); // matchmaking value (lvl group/rank?)
                    }

                    packet.WriteCString(string.Empty); // arena team names
                    packet.WriteCString(string.Empty);
                }

                var isFinished = bg.Winner != null;
                packet.Write(isFinished);
                if (isFinished)
                {
                    packet.Write((byte)bg.Winner.Side);
                }

				var chrs = bg.Characters;

				var chrCount = 0;
            	var chrCountPos = packet.Position;
            	packet.Position += 4;
                for (var i = 0; i < chrCount; i++)
                {
                	var chr = chrs[i];
					if (!chr.IsInBattleground)
					{
						continue;
					}

                	var stats = chr.Battlegrounds.Stats;

                	++chrCount;
                    packet.Write(chr.EntityId); // player guid
					packet.Write(stats.KillingBlows);

                    if (bg.IsArena)
					{
                        packet.Write(winner != null && chr.Battlegrounds.Team == winner); // is on the winning team
                    }
                    else
                    {
						packet.Write(stats.HonorableKills);
						packet.Write(stats.Deaths);
						packet.Write(stats.BonusHonor);
                    }

					packet.Write(stats.TotalDamage);
					packet.Write(stats.TotalHealing);

                    packet.Write(stats.SpecialStatCount);

                	stats.WriteSpecialStats(packet);
                }

            	packet.Position = chrCountPos;
            	packet.Write(chrCount);

                reciever.Send(packet);
            }
        }
Exemplo n.º 60
0
        /// <summary>
        /// Sends the requested party member stats data to the client
        /// </summary>
        /// <param name="client">realm client</param>
        /// <param name="member">The character whose stats is going to be retrieved</param>
        /// <param name="flags">The stats to be retrieved from the <paramref name="member"/></param>
        private static void SendPartyMemberStatsInternal(IPacketReceiver client, GroupMember member, GroupUpdateFlags flags,
                                                         RealmServerOpCode opcode)
        {
            using (var packet = new RealmPacketOut(opcode))
            {
                if (opcode == RealmServerOpCode.SMSG_PARTY_MEMBER_STATS_FULL)
                {
                    packet.Write((byte)0); //arena something
                }

                member.WriteIdPacked(packet);
                if (!member.IsOnline)
                {
                    packet.WriteUShort((ushort)CharacterStatus.OFFLINE);
                    client.Send(packet);
                    return;
                }
                packet.Write((uint)flags);

                var chr = member.Character;
                if (flags.HasFlag(GroupUpdateFlags.Status))
                {
                    packet.Write((ushort)chr.Status);
                }
                if (flags.HasFlag(GroupUpdateFlags.Health))
                {
                    packet.Write(chr.Health);
                }
                if (flags.HasFlag(GroupUpdateFlags.MaxHealth))
                {
                    packet.Write(chr.MaxHealth);
                }
                if (flags.HasFlag(GroupUpdateFlags.PowerType))
                {
                    packet.Write((byte)chr.PowerType);
                }
                if (flags.HasFlag(GroupUpdateFlags.Power))
                {
                    packet.Write((ushort)chr.Power);
                }
                if (flags.HasFlag(GroupUpdateFlags.MaxPower))
                {
                    packet.Write((ushort)chr.MaxPower);
                }
                if (flags.HasFlag(GroupUpdateFlags.Level))
                {
                    packet.Write((ushort)chr.Level);
                }
                if (flags.HasFlag(GroupUpdateFlags.ZoneId))
                {
                    packet.Write((ushort)(chr.Zone != null ? chr.Zone.Id : ZoneId.None));
                }
                if (flags.HasFlag(GroupUpdateFlags.Position))
                {
                    packet.Write((ushort)chr.Position.X);
                    packet.Write((ushort)chr.Position.Y);
                }
                if (flags.HasFlag(GroupUpdateFlags.Auras))
                {
                    ulong auraMask = chr.AuraUpdateMask;
                    packet.Write(auraMask);
                    Aura currAura;

                    for (byte i = 0; i < AuraHandler.MaxAuras; ++i)
                    {
                        if ((auraMask & ((ulong)1 << i)) != 0)
                        {
                            currAura = chr.Auras.GetAt(i);

                            packet.Write(currAura.Spell.Id);
                            packet.Write((byte)currAura.Flags);
                        }
                    }
                }

                NPC targetPet = chr.ActivePet;

                if (targetPet == null) //no pet
                {
                    packet.Write((byte)0); //name
                    packet.Write(0UL); //auras
                    client.Send(packet);
                    return;
                }

                if (flags.HasFlag(GroupUpdateFlags.PetGuid))
                {
                    packet.Write(targetPet.EntityId);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetName))
                {
                    packet.WriteCString(targetPet.Name);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetDisplayId))
                {
                    packet.Write((ushort)targetPet.DisplayId);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetHealth))
                {
                    packet.Write(targetPet.Health);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetMaxHealth))
                {
                    packet.Write(targetPet.MaxHealth);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetPowerType))
                {
                    packet.Write((byte)targetPet.PowerType);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetPower))
                {
                    packet.Write((ushort)targetPet.Power);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetMaxPower))
                {
                    packet.Write((ushort)targetPet.MaxPower);
                }

                if (flags.HasFlag(GroupUpdateFlags.PetAuras))
                {
                    ulong auraMask = targetPet.AuraUpdateMask;
                    packet.Write(auraMask);
                    Aura currAura;

                    for (byte i = 0; i < AuraHandler.MaxAuras; ++i)
                    {
                        if ((auraMask & ((ulong)1 << i)) != 0)
                        {
                            currAura = targetPet.Auras.GetAt(i);//chr.Auras.GetAt(i);

                            packet.Write(currAura.Spell.Id);
                            packet.Write((byte)currAura.Flags);
                        }
                    }
                }
                client.Send(packet);
            }
        }