Example #1
0
        /// <summary>
        /// Any spell and ranged damage
        /// </summary>
        /// <param name="totalAmount">Total amount</param>
        /// <returns>The actual amount, with all mali subtracted</returns>
        public static void SendMagicDamage(EntityId caster, WorldObject target, uint spellId, uint amount, DamageType type,
                                           uint absorbed, uint resisted, uint blocked, bool critical)
        {
            /*if (victimState == VICTIMSTATE.DEFLECT) // resist
             *      return MagicResist(target,submitter,spellId);*/
            // TODO: Magic miss, ranged dodge, etc.

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) {
                target.EntityId.WritePacked(packet);
                caster.WritePacked(packet);
                packet.Write(spellId);

                packet.WriteUInt(amount);
                packet.WriteByte((byte)type);
                packet.WriteUInt(absorbed);
                packet.WriteUInt(resisted);
                packet.WriteByte(type == DamageType.Physical ? 1 : 0);                 // pyshical damage?
                packet.WriteByte(0);
                packet.WriteUInt(blocked);
                packet.WriteByte(critical ? 7 : 6);
                packet.Write(0);

                target.PushPacketToSurroundingArea(packet, true, false);
            }
        }
Example #2
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);
            }
        }
Example #3
0
        public static void SendPetitionSignatures(IPacketReceiver client, PetitionCharter charter)
        {
            if (charter.Petition == null)
            {
                return;
            }

            var signs = charter.Petition.SignedIds;

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PETITION_SHOW_SIGNATURES, 8 + 8 + 4 + 1 + signs.Count * 12))
            {
                packet.WriteULong(charter.EntityId.Full);
                packet.WriteULong(charter.Owner.EntityId.Full);
                packet.WriteUInt(charter.EntityId.Low);
                packet.WriteByte(signs.Count);

                foreach (var guid in signs)
                {
                    packet.WriteULong(guid);
                    packet.WriteUInt(0);
                }

                client.Send(packet);
            }
        }
Example #4
0
        /// <summary>
        /// Sends the packet to show the battleground window
        /// </summary>
        /// <param name="client"></param>
        /// <param name="speaker"></param>
        /// <param name="character"></param>
        /// <returns></returns>
        public bool SendBattlegroundWindow(IRealmClient client, NPC speaker, Character character)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_LIST))
            {
                packet.WriteULong(speaker != null ? speaker.EntityId.Full : 0);
                packet.WriteUInt((uint)m_bgqueue.Template.BgID);
                packet.WriteByte(m_battlegroupId); //Battle group
                // TODO: Add sync'ing?
                //m_syncLock.EnterReadLock();
                try
                {
                    packet.WriteUInt(m_battlegrounds.Count); //Count

                    foreach (var bg in m_battlegrounds.Values)
                    {
                        packet.WriteUInt(bg.InstanceId);
                    }
                }
                finally
                {
                    //m_syncLock.ExitReadLock();
                }
                client.Send(packet);
                return(true);
            }
        }
Example #5
0
        public static void SendPetitionSignatures(IPacketReceiver client, PetitionCharter charter)
        {
            if (charter.Petition == null)
            {
                return;
            }
            List <uint> signedIds = charter.Petition.SignedIds;

            using (RealmPacketOut packet =
                       new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_PETITION_SHOW_SIGNATURES,
                                          21 + signedIds.Count * 12))
            {
                packet.WriteULong(charter.EntityId.Full);
                packet.WriteULong(charter.Owner.EntityId.Full);
                packet.WriteUInt(charter.EntityId.Low);
                packet.WriteByte(signedIds.Count);
                foreach (uint val in signedIds)
                {
                    packet.WriteULong(val);
                    packet.WriteUInt(0);
                }

                client.Send(packet, false);
            }
        }
Example #6
0
 public static void SendTitleEarned(Character character, CharacterTitleEntry titleEntry, bool lost)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_TITLE_EARNED, 8))
     {
         packet.WriteUInt((uint)titleEntry.BitIndex);
         packet.WriteUInt(lost ? 0 : 1);
         character.Send(packet, false);
     }
 }
Example #7
0
 public static void SendTitleEarned(Character character, CharacterTitleEntry titleEntry, bool lost)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TITLE_EARNED, 4 + 4))
     {
         packet.WriteUInt((uint) titleEntry.BitIndex);
         packet.WriteUInt(lost ? 0 : 1);
         character.Send(packet);
     }
 }
Example #8
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);
        }
Example #9
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);
        }
Example #10
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);
     }
 }
Example #11
0
 //SMSG_ACHIEVEMENT_EARNED
 public static void SendAchievementEarned(uint achievementEntryId, Character chr)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 4))
     {
         chr.EntityId.WritePacked(packet);
         packet.WriteUInt(achievementEntryId);
         packet.WriteDateTime(DateTime.Now);
         packet.WriteUInt(0);
         chr.SendPacketToArea(packet, true);
     }
 }
Example #12
0
        private static RealmPacketOut CreateArenaTeamQueryResponsePacket(ArenaTeam team)
        {
            RealmPacketOut realmPacketOut =
                new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_QUERY_RESPONSE,
                                   28 + team.Name.Length + 1);

            realmPacketOut.WriteUInt((byte)team.Id);
            realmPacketOut.WriteCString(team.Name);
            realmPacketOut.WriteUInt(team.Type);
            return(realmPacketOut);
        }
Example #13
0
 //SMSG_ACHIEVEMENT_EARNED
 public static void SendAchievementEarned(AchievementEntryId achievementEntryId, Character chr)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ACHIEVEMENT_EARNED, 8 + 4 + 4))
     {
         chr.EntityId.WritePacked(packet);
         packet.WriteUInt((uint)achievementEntryId);
         packet.WriteDateTime(DateTime.Now);
         packet.WriteUInt(0);
         chr.SendPacketToArea(packet, true);
     }
 }
Example #14
0
 public static void SendAchievementEarned(uint achievementEntryId, Character chr)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_ACHIEVEMENT_EARNED, 16))
     {
         chr.EntityId.WritePacked((BinaryWriter)packet);
         packet.WriteUInt(achievementEntryId);
         packet.WriteDateTime(DateTime.Now);
         packet.WriteUInt(0);
         chr.SendPacketToArea(packet, true, false, Locale.Any, new float?());
     }
 }
Example #15
0
 //SMSG_SERVER_FIRST_ACHIEVEMENT
 public static void SendServerFirstAchievement(uint 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(achievementEntryId);
         packet.WriteUInt(0);
         World.Broadcast(packet);
     }
 }
Example #16
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);
     }
 }
Example #17
0
        public static void SendRealmStateResponse(IPacketReceiver client, uint realmNo)
        {
            string str = "01/01/01";

            using (RealmPacketOut packet =
                       new RealmPacketOut(RealmServerOpCode.SMSG_REALM_SPLIT, 9 + str.Length))
            {
                packet.WriteUInt(realmNo);
                packet.WriteUInt(0U);
                packet.WriteCString(str);
                client.Send(packet, false);
            }
        }
Example #18
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);
            }
        }
Example #19
0
        /// <summary>
        /// Send the "you have joined channel" reply
        /// </summary>
        /// <param name="client">the client the outdoing packet belongs to</param>
        /// <param name="chan">name of channel</param>
        public static void SendYouJoinedReply(IPacketReceiver client, ChatChannel chan)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHANNEL_NOTIFY))
            {
                packet.WriteByte((byte)ChannelNotification.YouJoined);
                packet.WriteCString(chan.Name);
                packet.Write((byte)chan.Flags);
                packet.WriteUInt(chan.ChannelId);
                packet.WriteUInt(0);

                client.Send(packet);
            }
        }
Example #20
0
        /// <param name="swingFlag">usually 1</param>
        /// <returns>The actual damage (all resistances subtracted)</returns>
        public static uint SendMeleeDamage(WorldObject attacker, WorldObject target, DamageType type, HitInfo hitInfo,
                                           uint totalAmount, uint absorbed, uint resisted, uint blocked, VictimState victimState)
        {
            uint amount = totalAmount - blocked - absorbed - resisted;

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ATTACKERSTATEUPDATE, 70)) {
                packet.WriteUInt((uint)hitInfo);
                attacker.EntityId.WritePacked(packet);
                target.EntityId.WritePacked(packet);

                packet.WriteUInt(totalAmount);
                packet.WriteByte(1);

                packet.WriteByte((uint)type);
                packet.WriteFloat(amount);
                packet.WriteUInt(amount);
                packet.WriteUInt(absorbed);
                packet.WriteUInt(resisted);

                packet.WriteUInt((uint)victimState);
                packet.Write(absorbed == 0 ? 0 : -1);
                packet.WriteUInt(0);
                packet.WriteUInt(blocked);

                target.PushPacketToSurroundingArea(packet, true, false);
            }
            return(amount);
        }
Example #21
0
        public static RealmPacketOut CreateAchievementEarnedToGuild(uint achievementEntryId, Character chr)
        {
            RealmPacketOut realmPacketOut = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);

            realmPacketOut.WriteByte((byte)48);
            realmPacketOut.WriteUInt(0U);
            realmPacketOut.Write((ulong)chr.EntityId);
            realmPacketOut.WriteUInt(5);
            realmPacketOut.Write((ulong)chr.EntityId);
            realmPacketOut.WriteUIntPascalString("|Hplayer:$N|h[$N]|h has earned the achievement $a!");
            realmPacketOut.WriteByte(0);
            realmPacketOut.WriteUInt(achievementEntryId);
            return(realmPacketOut);
        }
Example #22
0
 /// <summary>Used for any PeriodicAura (repeating ticks)</summary>
 /// <param name="extra">Always seems to be one</param>
 public static void SendPeriodicAuraLog(IPacketReceiver client, WorldObject caster, WorldObject target,
                                        uint spellId, uint extra, AuraTickFlags flags, int amount)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_PERIODICAURALOG, 32))
     {
         caster.EntityId.WritePacked((BinaryWriter)packet);
         target.EntityId.WritePacked((BinaryWriter)packet);
         packet.WriteUInt(spellId);
         packet.WriteUInt(extra);
         packet.WriteUInt((uint)flags);
         packet.WriteUInt(amount);
         target.SendPacketToArea(packet, true, false, Locale.Any, new float?());
     }
 }
Example #23
0
        private static RealmPacketOut CreateArenaTeamStatsResponsePacket(ArenaTeam team)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_STATS, 4*7);

            packet.WriteUInt((byte)team.Id);
            packet.WriteUInt(team.Stats.rating);
            packet.WriteUInt(team.Stats.gamesWeek);
            packet.WriteUInt(team.Stats.winsWeek);
            packet.WriteUInt(team.Stats.gamesSeason);
            packet.WriteUInt(team.Stats.winsSeason);
            packet.WriteUInt(team.Stats.rank);

            return packet;
        }
Example #24
0
 /// <summary>Used for Periodic leech effects, mostly Cannibalism</summary>
 /// <returns></returns>
 public static void SendPeriodicDamage(WorldObject caster, WorldObject target, uint spellId, AuraTickFlags type,
                                       int amount)
 {
     using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_PERIODICAURALOG, 32))
     {
         caster.EntityId.WritePacked((BinaryWriter)packet);
         target.EntityId.WritePacked((BinaryWriter)packet);
         packet.WriteUInt(spellId);
         packet.WriteUInt(1);
         packet.WriteUInt((uint)type);
         packet.WriteUInt(amount);
         target.SendPacketToArea(packet, true, false, Locale.Any, new float?());
     }
 }
Example #25
0
        public static bool BuildAuctionPacket(Auction auction, RealmPacketOut packet)
        {
            var item = AuctionMgr.Instance.AuctionItems[auction.ItemLowId];

            if (item == null)
            {
                return(false);
            }

            var timeleft = auction.TimeEnds - DateTime.Now;

            if (timeleft.TotalMilliseconds < 0)
            {
                return(false);
            }

            packet.Write(auction.ItemLowId);
            packet.Write(item.Template.Id);

            for (var i = 0; i < 7; i++)
            {
                if (item.EnchantIds != null)
                {
                    packet.Write(item.EnchantIds[i]);
                    packet.Write(i);                                                            // enchant duration
                    packet.Write(item.GetEnchant((EnchantSlot)i).Charges);                      // TODO: Fix enchant charges
                }
                else
                {
                    packet.Write(0);
                    packet.Write(0);
                    packet.Write(0);
                }
            }

            packet.Write(item.RandomProperty);
            packet.Write(item.RandomSuffix);
            packet.Write(item.Amount);
            packet.Write((uint)item.Charges);
            packet.WriteUInt(0);                                             //Unknown
            packet.WriteULong(auction.OwnerLowId);
            packet.Write(auction.CurrentBid);                                //auction start bid
            packet.WriteUInt(AuctionMgr.GetMinimumNewBidIncrement(auction)); //amount required to outbid
            packet.Write(auction.BuyoutPrice);
            packet.Write((int)timeleft.TotalMilliseconds);
            packet.WriteULong(auction.BidderLowId);
            packet.Write(auction.CurrentBid);
            return(true);
        }
Example #26
0
        /// <summary>
        /// Used for Periodic leech effects, mostly Cannibalism
        /// </summary>
        /// <param name="school">AuraTickFlags.PeriodicHeal</param>
        /// <returns></returns>
        public static void SendPeriodicDamage(WorldObject caster, WorldObject target, uint spellId, Spells.AuraTickFlags type,
                                              uint amount)
        {
            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PERIODICAURALOG, 32)) {
                caster.EntityId.WritePacked(packet);
                target.EntityId.WritePacked(packet);
                packet.WriteUInt(spellId);

                packet.WriteUInt(1);                                            // count
                packet.WriteUInt((uint)type);
                packet.WriteUInt(amount);

                target.PushPacketToSurroundingArea(packet, true, false);
            }
        }
Example #27
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);
			}
		}
Example #28
0
 public static RealmPacketOut CreateAchievementEarnedToGuild(AchievementEntryId achievementEntryId, Character chr)
 {
     // Must be a better way to do this.
     const string msg = "|Hplayer:$N|h[$N]|h has earned the achievement $a!";
     var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);
     packet.WriteByte((byte) ChatMsgType.Achievment);
     packet.WriteUInt((uint) ChatLanguage.Universal);
     packet.Write(chr.EntityId);
     packet.WriteUInt(5);
     packet.Write(chr.EntityId);
     packet.WriteUIntPascalString(msg);
     packet.WriteByte(0);
     packet.WriteUInt((uint) achievementEntryId);
     return packet;
 }
Example #29
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, addEnd: false);
            }
        }
Example #30
0
 public static void SendBootPlayer(IRealmClient client)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_LFG_BOOT_PROPOSAL_UPDATE))
     {
         packet.WriteByte(true);
         packet.WriteByte(false);
         packet.WriteByte(true);
         packet.Write((ulong)EntityId.Zero);
         packet.WriteUInt(0);
         packet.WriteUInt(0);
         packet.WriteUInt(0);
         packet.WriteUInt(0);
         packet.Write("Too noobzor for this l33t grpz");
         client.Send(packet, false);
     }
 }
Example #31
0
		/// <summary>
		/// Used for Periodic leech effects, mostly Cannibalism
		/// </summary>
		/// <returns></returns>
		public static void SendPeriodicDamage(WorldObject caster, WorldObject target, uint spellId, AuraTickFlags type,
											  int amount)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PERIODICAURALOG, 32))
			{
				caster.EntityId.WritePacked(packet);
				target.EntityId.WritePacked(packet);
				packet.WriteUInt(spellId);

				packet.WriteUInt(1);				// count
				packet.WriteUInt((uint)type);
				packet.WriteUInt(amount);

				target.SendPacketToArea(packet, true);
			}
		}
Example #32
0
		/// <summary>
		/// Used for any PeriodicAura (repeating ticks)
		/// </summary>
		/// <param name="extra">Always seems to be one</param>
		public static void SendPeriodicAuraLog(IPacketReceiver client, WorldObject caster, WorldObject target,
			uint spellId, uint extra, AuraTickFlags flags, int amount)
		{
			// TODO: Update struct for 3.0.2
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PERIODICAURALOG, 32))
			{
				caster.EntityId.WritePacked(packet);
				target.EntityId.WritePacked(packet);
				packet.WriteUInt(spellId);
				packet.WriteUInt(extra);
				packet.WriteUInt((uint)flags);
				packet.WriteUInt(amount);

				target.SendPacketToArea(packet, true);
			}
		}
Example #33
0
        public static RealmPacketOut CreateAchievementEarnedToGuild(uint achievementEntryId, Character chr)
        {
            // Must be a better way to do this.
            const string msg    = "|Hplayer:$N|h[$N]|h has earned the achievement $a!";
            var          packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT);

            packet.WriteByte((byte)ChatMsgType.Achievment);
            packet.WriteUInt((uint)ChatLanguage.Universal);
            packet.Write(chr.EntityId);
            packet.WriteUInt(5);
            packet.Write(chr.EntityId);
            packet.WriteUIntPascalString(msg);
            packet.WriteByte(0);
            packet.WriteUInt(achievementEntryId);
            return(packet);
        }
Example #34
0
        /// <summary>
        /// Used for any PeriodicAura (repeating ticks)
        /// </summary>
        /// <param name="extra">Always seems to be one</param>
        public static void SendPeriodicAuraLog(IPacketReceiver client, WorldObject caster, WorldObject target,
                                               uint spellId, uint extra, AuraTickFlags flags, int amount)
        {
            // TODO: Update struct
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PERIODICAURALOG, 32))
            {
                caster.EntityId.WritePacked(packet);
                target.EntityId.WritePacked(packet);
                packet.WriteUInt(spellId);
                packet.WriteUInt(extra);
                packet.WriteUInt((uint)flags);
                packet.WriteUInt(amount);

                target.SendPacketToArea(packet, true, false);
            }
        }
Example #35
0
        /// <summary>
        /// item1 and item2 can be null, but item1 must be set in case of YOU_MUST_REACH_LEVEL_N.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="item1"></param>
        /// <param name="item2"></param>
        /// <param name="error"></param>
        public static void SendInventoryError(IPacketReceiver client, Item item1, Item item2, InventoryError error)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_INVENTORY_CHANGE_FAILURE,
                                                   error == InventoryError.YOU_MUST_REACH_LEVEL_N ? 22 : 18))
            {
                packet.WriteByte((byte)error);

                if (item1 != null)
                {
                    packet.Write(item1.EntityId.Full);
                }
                else
                {
                    packet.Write((long)0);
                }

                if (item2 != null)
                {
                    packet.Write(item2.EntityId.Full);
                }
                else
                {
                    packet.Write((long)0);
                }

                packet.Write((byte)0);

                if (error == InventoryError.YOU_MUST_REACH_LEVEL_N && item1 != null)
                {
                    packet.WriteUInt(item1.Template.RequiredLevel);
                }

                client.Send(packet, addEnd: false);
            }
        }
Example #36
0
        /// <summary>
        /// Sends the packet to show the battleground window
        /// </summary>
        /// <param name="client"></param>
        /// <param name="speaker"></param>
        /// <param name="character"></param>
        /// <returns></returns>
        public bool SendBattlegroundWindow(IRealmClient client, NPC speaker, Character character)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_LIST))
            {
                packet.WriteULong(speaker != null ? speaker.EntityId.Full : 0);
                packet.WriteUInt((uint)m_bgqueue.Template.BgID);
                packet.WriteByte(m_battlegroupId); //Battle group
				// TODO: Add sync'ing?
                //m_syncLock.EnterReadLock();
                try
                {
                    packet.WriteUInt(m_battlegrounds.Count); //Count

                    foreach (var bg in m_battlegrounds.Values)
                    {
                        packet.WriteUInt(bg.InstanceId);
                    }
                }
                finally
                {
                    //m_syncLock.ExitReadLock();
                }
                client.Send(packet);
                return true;
            }
        }
Example #37
0
 public static void SendPlaySoundToMap(Map map, uint sound)
 {
     using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_PLAY_SOUND, 4))
     {
         packet.WriteUInt(sound);
         map.SendPacketToMap(packet);
     }
 }
Example #38
0
 public static void SendPetitionTurnInResults(IPacketReceiver client, PetitionTurns result)
 {
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TURN_IN_PETITION_RESULTS, 4))
     {
         packet.WriteUInt((uint)result);
         client.Send(packet);
     }
 }
Example #39
0
 public static void SendBootPlayer(IRealmClient client)
 {
     // SMSG_LFG_BOOT_PLAYER
     using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LFG_BOOT_PROPOSAL_UPDATE))
     {
         packet.WriteByte(true);                                         // Vote in progress
         packet.WriteByte(false);                                        // Did player Vote
         packet.WriteByte(true);                                         // Did player pass the motion
         packet.Write(EntityId.Zero);                                    // EntityID of player being voted on
         packet.WriteUInt(0);                                            // Total votes
         packet.WriteUInt(0);                                            // Count of votes to boot
         packet.WriteUInt(0);                                            // Time left in seconds
         packet.WriteUInt(0);                                            // Needed Votes
         packet.Write("Too noobzor for this l33t grpz");                 // Kick reason
         client.Send(packet, addEnd: false);
     }
 }
Example #40
0
        public static bool BuildAuctionPacket(Auction auction, RealmPacketOut packet)
        {
            ItemRecord auctionItem = Singleton <AuctionMgr> .Instance.AuctionItems[auction.ItemLowId];

            if (auctionItem == null)
            {
                return(false);
            }
            TimeSpan timeSpan = auction.TimeEnds - DateTime.Now;

            if (timeSpan.TotalMilliseconds < 0.0)
            {
                return(false);
            }
            packet.Write(auction.ItemLowId);
            packet.Write(auctionItem.Template.Id);
            for (int index = 0; index < 7; ++index)
            {
                if (auctionItem.EnchantIds != null)
                {
                    packet.Write(auctionItem.EnchantIds[index]);
                    packet.Write(index);
                    packet.Write(auctionItem.GetEnchant((EnchantSlot)index).Charges);
                }
                else
                {
                    packet.Write(0);
                    packet.Write(0);
                    packet.Write(0);
                }
            }

            packet.Write(auctionItem.RandomProperty);
            packet.Write(auctionItem.RandomSuffix);
            packet.Write(auctionItem.Amount);
            packet.Write((uint)auctionItem.Charges);
            packet.WriteUInt(0);
            packet.WriteULong(auction.OwnerLowId);
            packet.Write(auction.CurrentBid);
            packet.WriteUInt(AuctionMgr.GetMinimumNewBidIncrement(auction));
            packet.Write(auction.BuyoutPrice);
            packet.Write((int)timeSpan.TotalMilliseconds);
            packet.WriteULong(auction.BidderLowId);
            packet.Write(auction.CurrentBid);
            return(true);
        }
Example #41
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;
        }
Example #42
0
		public static void SendLearnedSpell(IPacketReceiver client, uint spellId)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LEARNED_SPELL, 4))
			{
				packet.WriteUInt(spellId);
				packet.WriteUShort(0); // 3.3.3a

				client.Send(packet);
			}
		}
Example #43
0
        /// <summary>
        /// Creates a packet
        /// </summary>
        public static RealmPacketOut CreateChatPacket(ChatMsgType type, ChatLanguage language, string msg, ChatTag tag)
        {
            var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 23 + msg.Length);
            packet.WriteByte((byte)type);			// 1
            packet.WriteUInt((uint)language);		// 5
            packet.WriteUIntPascalString(msg);			// 22 + msg.Length
            packet.WriteByte((byte)tag);			// 23 + msg.Length

            return packet;
        }
Example #44
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);
			}
		}
Example #45
0
        public static void HandleAuctionListPendingSales(IRealmClient client, RealmPacketIn packet)
        {
            var chr = client.ActiveCharacter;
            var auctioneerId = packet.ReadEntityId();
            var auctioneer = chr.Map.GetObject(auctioneerId) as NPC;

            var count = 1u;
            using (var packetOut = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_PENDING_SALES, 14 * (int)count))
            {
                packetOut.Write(count);
                for (var i = 0; i < count; ++i)
                {
                    packetOut.Write("");
                    packetOut.Write("");
                    packetOut.WriteUInt(0);
                    packetOut.WriteUInt(0);
                    packetOut.WriteFloat(0f);
                    client.Send(packetOut);
                }
            }
        }
Example #46
0
        // Client doesn't seem to be sending this
        //[ClientPacketHandler(RealmServerOpCode.CMSG_EMOTE)]
        //public static void HandleEmote(IRealmClient client, RealmPacketIn packet)
        //{
        //    var emote = (EmoteType)packet.ReadUInt32();

        //    if (emote != EmoteType.None)
        //    {
        //        var chr = client.ActiveCharacter;
        //        if (chr.CanMove && chr.CanInteract)
        //        {
        //            SendEmote(chr, emote);
        //        }
        //    }
        //}

        public static void SendTextEmote(WorldObject obj, TextEmote emote, INamed target)
        {
            var len = (target == null) ? 20 : target.Name.Length + 21;

            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TEXT_EMOTE, len))
            {
                packet.Write(obj.EntityId);
                packet.WriteUInt((uint)emote);
                packet.WriteInt(-1);
                packet.WriteUIntPascalString(target != null ? target.Name : "");

                obj.SendPacketToArea(packet, true);
            }
        }
Example #47
0
		// SMSG_CRITERIA_UPDATE
		public static void SendAchievmentStatus(AchievementProgressRecord achievementProgressRecord, Character chr)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CRITERIA_UPDATE, 4*5+8*2))
			{
				packet.WriteUInt((uint)achievementProgressRecord.AchievementCriteriaId);
				packet.WritePackedUInt64(achievementProgressRecord.Counter);					//	amount
				chr.EntityId.WritePacked(packet);
				packet.Write(0);
				packet.WriteDateTime(DateTime.Now);				// start time?
				packet.Write(0);								// Duration
				packet.Write(0);								// Duration left

				chr.Client.Send(packet);
			}
		}
Example #48
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);
            }
        }
Example #49
0
		/// <summary>
		/// Removes a spell from the client's spellbook
		/// </summary>
		public static void SendSpellRemoved(Character chr, uint spellId)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_REMOVED_SPELL, 4))
			{
				packet.WriteUInt(spellId);

				chr.Client.Send(packet);
			}
		}
Example #50
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);
                }
            }
        }
Example #51
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);
            }
        }
Example #52
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);
            }
        }
Example #53
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);
            }
        }
Example #54
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);
            }
        }
Example #55
0
        /// <summary>
        /// item1 and item2 can be null, but item1 must be set in case of YOU_MUST_REACH_LEVEL_N.
        /// </summary>
        /// <param name="client"></param>
        /// <param name="item1"></param>
        /// <param name="item2"></param>
        /// <param name="error"></param>
        public static void SendInventoryError(IPacketReceiver client, Item item1, Item item2, InventoryError error)
        {
            using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_INVENTORY_CHANGE_FAILURE,
                error == InventoryError.YOU_MUST_REACH_LEVEL_N ? 22 : 18))
            {
                packet.WriteByte((byte)error);

                if (item1 != null)
                {
                    packet.Write(item1.EntityId.Full);
                }
                else
                {
                    packet.Write((long)0);
                }

                if (item2 != null)
                {
                    packet.Write(item2.EntityId.Full);
                }
                else
                {
                    packet.Write((long)0);
                }

                packet.Write((byte)0);

                if (error == InventoryError.YOU_MUST_REACH_LEVEL_N && item1 != null)
                {
                    packet.WriteUInt(item1.Template.RequiredLevel);
                }

                client.Send(packet);
            }
        }
Example #56
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);
            }
        }
Example #57
0
        public void TestEmptyStructure()
        {
            var def = new PacketDefinition(RealmServerOpCode.CMSG_SET_CHANNEL_WATCH, PacketSender.Client, new List<PacketSegmentStructure>());
            def.Init();

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

                using (var packetIn = DisposableRealmPacketIn.CreateFromOutPacket(packet))
                {
                    var parsedPacket = PacketParser.Parse(packetIn, PacketSender.Client, def);
                    Assert.AreEqual(0, parsedPacket.SubSegments.Count);
                }
            }
        }
Example #58
0
		/// <summary>
		/// Forces the client to start or update a cooldown timer on the given single spell
		/// (mostly important for certain talents and item spells that don't automatically start cooling down)
		/// </summary>
		public static void SendCooldownUpdate(Character chr, SpellId spellId)
		{
			using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_COOLDOWN_EVENT, 12))
			{
				packet.WriteUInt((uint)spellId);
				chr.EntityId.WritePacked(packet);

				chr.Send(packet);
			}
		}
Example #59
0
		/// <summary>
		/// Clears a single spell's cooldown
		/// </summary>
		public static void SendClearCoolDown(Character chr, SpellId spellId)
		{
			IRealmClient client = chr.Client;

			if (client != null)
			{
				using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CLEAR_COOLDOWN, 12))
				{
					packet.WriteUInt((uint)spellId);
					chr.EntityId.WritePacked(packet);

					client.Send(packet);
				}
			}
		}
Example #60
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);
			}
		}