Esempio n. 1
0
        public static void HandlePetSpells(Packet packet)
        {
            WowGuid guid = packet.ReadGuid("GUID");

            // Equal to "Clear spells" pre cataclysm
            if (guid.IsEmpty())
            {
                return;
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
            {
                packet.ReadUInt16E <CreatureFamily>("Pet Family"); // vehicles -> 0
            }
            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
            {
                packet.ReadUInt16("Unk UInt16");
            }

            packet.ReadUInt32("Expiration Time");

            ReadPetFlags(packet);

            bool      isPet             = guid.GetHighType() == HighGuidType.Pet;
            bool      isVehicle         = guid.GetHighType() == HighGuidType.Vehicle;
            bool      isMinion          = guid.GetHighType() == HighGuidType.Creature;
            const int maxCreatureSpells = 10;
            var       spells            = new List <uint?>(maxCreatureSpells);

            for (int i = 0; i < maxCreatureSpells; i++) // Read pet/vehicle spell ids
            {
                ushort spell16 = packet.ReadUInt16();
                byte   spell8  = packet.ReadByte();
                int    spellId = spell16 + (spell8 << 16);
                byte   slot    = packet.ReadByte("Slot", i);

                if (spellId <= 4)
                {
                    packet.AddValue("Action", spellId, i);
                }
                else
                {
                    packet.AddValue("Spell", StoreGetters.GetName(StoreNameType.Spell, spellId), i);
                }

                // Spells for pets are on DBCs; also no entry in guid
                // We don't need the actions sent for minions (slots lower than 8)
                if (!isPet && (isVehicle || (isMinion && slot >= 8)))
                {
                    spells.Add((uint)spellId);
                }
            }

            if (spells.Count != 0)
            {
                if (!Storage.SpellsX.ContainsKey(guid.GetEntry()))
                {
                    Storage.SpellsX.Add(guid.GetEntry(), spells);
                }
            }

            byte spellCount = packet.ReadByte("Spell Count"); // vehicles -> 0, pets -> != 0. Could this be auras?

            for (int i = 0; i < spellCount; i++)
            {
                packet.ReadUInt16 <SpellId>("Spell", i);
                packet.ReadInt16("Active", i);
            }

            byte cdCount = packet.ReadByte("Cooldown count");

            for (int i = 0; i < cdCount; i++)
            {
                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767))
                {
                    packet.ReadUInt32 <SpellId>("Spell", i);
                }
                else
                {
                    packet.ReadUInt16 <SpellId>("Spell", i);
                }

                packet.ReadUInt16("Category", i);
                packet.ReadUInt32("Cooldown", i);
                packet.ReadUInt32("Category Cooldown", i);
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309))
            {
                byte unkLoopCounter = packet.ReadByte("Unk count");
                for (int i = 0; i < unkLoopCounter; i++)
                {
                    packet.ReadUInt32("Unk UInt32 1", i);
                    packet.ReadByte("Unk Byte", i);
                    packet.ReadUInt32("Unk UInt32 2", i);
                }
            }
        }