Exemple #1
0
        public static void ReadSpellTargetData(Packet packet, PacketSpellData spellData, params object[] idx)
        {
            packet.ResetBitReader();

            packet.ReadBitsE <TargetFlag>("Flags", ClientVersion.AddedInVersion(ClientVersionBuild.V6_1_0_19678) ? 23 : 21, idx);
            var hasSrcLoc  = packet.ReadBit("HasSrcLocation", idx);
            var hasDstLoc  = packet.ReadBit("HasDstLocation", idx);
            var hasOrient  = packet.ReadBit("HasOrientation", idx);
            var nameLength = packet.ReadBits(7);

            var targetUnit = packet.ReadPackedGuid128("Unit", idx);

            if (spellData != null)
            {
                spellData.TargetUnit = targetUnit;
            }
            packet.ReadPackedGuid128("Item", idx);

            if (hasSrcLoc)
            {
                ReadLocation(packet, "SrcLocation");
            }

            if (hasDstLoc)
            {
                var dstLocation = ReadLocation(packet, "DstLocation");
                if (spellData != null)
                {
                    spellData.DstLocation = dstLocation;
                }
            }

            if (hasOrient)
            {
                packet.ReadSingle("Orientation", idx);
            }

            packet.ReadWoWString("Name", nameLength, idx);
        }
Exemple #2
0
        public static PacketSpellData ReadSpellCastData(Packet packet, params object[] idx)
        {
            var packetSpellData = new PacketSpellData();

            packet.ReadPackedGuid128("CasterGUID", idx);
            packetSpellData.Caster = packet.ReadPackedGuid128("CasterUnit", idx);

            packetSpellData.CastGuid = packet.ReadPackedGuid128("CastID", idx);
            packet.ReadPackedGuid128("OriginalCastID", idx);

            var spellID = packetSpellData.Spell = packet.ReadUInt32 <SpellId>("SpellID", idx);

            packet.ReadUInt32("SpellXSpellVisualID", idx);

            packetSpellData.Flags    = packet.ReadUInt32("CastFlags", idx);
            packetSpellData.Flags2   = packet.ReadUInt32("CastFlagsEx", idx);
            packetSpellData.CastTime = packet.ReadUInt32("CastTime", idx);

            V6_0_2_19033.Parsers.SpellHandler.ReadMissileTrajectoryResult(packet, idx, "MissileTrajectory");

            packet.ReadByte("DestLocSpellCastIndex", idx);

            V6_0_2_19033.Parsers.SpellHandler.ReadCreatureImmunities(packet, idx, "Immunities");

            V6_0_2_19033.Parsers.SpellHandler.ReadSpellHealPrediction(packet, idx, "Predict");

            packet.ResetBitReader();

            var hitTargetsCount     = packet.ReadBits("HitTargetsCount", 16, idx);
            var missTargetsCount    = packet.ReadBits("MissTargetsCount", 16, idx);
            var missStatusCount     = packet.ReadBits("MissStatusCount", 16, idx);
            var remainingPowerCount = packet.ReadBits("RemainingPowerCount", 9, idx);

            var hasRuneData          = packet.ReadBit("HasRuneData", idx);
            var targetPointsCount    = packet.ReadBits("TargetPointsCount", 16, idx);
            var hasAmmoDisplayId     = packet.ReadBit("HasAmmoDisplayId", idx);
            var hasAmmoInventoryType = packet.ReadBit("HasAmmoInventoryType", idx);

            for (var i = 0; i < missStatusCount; ++i)
            {
                V6_0_2_19033.Parsers.SpellHandler.ReadSpellMissStatus(packet, idx, "MissStatus", i);
            }

            ReadSpellTargetData(packet, packetSpellData, spellID, idx, "Target");

            for (var i = 0; i < hitTargetsCount; ++i)
            {
                packetSpellData.HitTargets.Add(packet.ReadPackedGuid128("HitTarget", idx, i));
            }

            for (var i = 0; i < missTargetsCount; ++i)
            {
                packetSpellData.MissedTargets.Add(packet.ReadPackedGuid128("MissTarget", idx, i));
            }

            for (var i = 0; i < remainingPowerCount; ++i)
            {
                V6_0_2_19033.Parsers.SpellHandler.ReadSpellPowerData(packet, idx, "RemainingPower", i);
            }

            if (hasRuneData)
            {
                V7_0_3_22248.Parsers.SpellHandler.ReadRuneData(packet, idx, "RemainingRunes");
            }

            for (var i = 0; i < targetPointsCount; ++i)
            {
                packetSpellData.TargetPoints.Add(V6_0_2_19033.Parsers.SpellHandler.ReadLocation(packet, idx, "TargetPoints", i));
            }

            if (hasAmmoDisplayId)
            {
                packetSpellData.AmmoDisplayId = packet.ReadInt32("AmmoDisplayId", idx);
            }

            if (hasAmmoInventoryType)
            {
                packetSpellData.AmmoInventoryType = (uint)packet.ReadInt32E <InventoryType>("AmmoInventoryType", idx);
            }

            return(packetSpellData);
        }
Exemple #3
0
        public static PacketSpellData ReadSpellCastData(Packet packet, params object[] idx)
        {
            var packetSpellData = new PacketSpellData();

            packet.ReadPackedGuid128("CasterGUID", idx);
            packetSpellData.Caster = packet.ReadPackedGuid128("CasterUnit", idx);

            packetSpellData.CastId = packet.ReadByte("CastID", idx);

            packetSpellData.Spell = (uint)packet.ReadInt32 <SpellId>("SpellID", idx);

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173))
            {
                packet.ReadUInt32("SpellXSpellVisualID", idx);
            }

            packetSpellData.Flags    = packet.ReadUInt32("CastFlags", idx);
            packetSpellData.CastTime = packet.ReadUInt32("CastTime", idx);

            var hitTargetsCount  = packet.ReadUInt32("HitTargetsCount", idx);
            var missTargetsCount = packet.ReadUInt32("MissTargetsCount", idx);
            var missStatusCount  = packet.ReadUInt32("MissStatusCount", idx);

            ReadSpellTargetData(packet, packetSpellData, idx, "Target");

            var remainingPowerCount = packet.ReadUInt32("RemainingPowerCount", idx);

            ReadMissileTrajectoryResult(packet, idx, "MissileTrajectory");

            ReadSpellAmmo(packet, idx, "Ammo");

            packet.ReadByte("DestLocSpellCastIndex", idx);

            var targetPointsCount = packet.ReadUInt32("TargetPointsCount", idx);

            ReadCreatureImmunities(packet, idx, "Immunities");

            ReadSpellHealPrediction(packet, idx, "Predict");

            for (var i = 0; i < hitTargetsCount; ++i)
            {
                packetSpellData.HitTargets.Add(packet.ReadPackedGuid128("HitTarget", idx, i));
            }

            for (var i = 0; i < missTargetsCount; ++i)
            {
                packetSpellData.MissedTargets.Add(packet.ReadPackedGuid128("MissTarget", idx, i));
            }

            for (var i = 0; i < missStatusCount; ++i)
            {
                ReadSpellMissStatus(packet, idx, "MissStatus", i);
            }

            for (var i = 0; i < remainingPowerCount; ++i)
            {
                ReadSpellPowerData(packet, idx, "RemainingPower", i);
            }

            for (var i = 0; i < targetPointsCount; ++i)
            {
                packetSpellData.TargetPoints.Add(ReadLocation(packet, idx, "TargetPoints", i));
            }

            packet.ResetBitReader();

            packetSpellData.Flags2 = packet.ReadBits("CastFlagsEx", ClientVersion.AddedInVersion(ClientVersionBuild.V6_2_0_20173) ? 20 : 18, idx);

            var hasRuneData         = packet.ReadBit("HasRuneData", idx);
            var hasProjectileVisual = ClientVersion.RemovedInVersion(ClientVersionBuild.V6_2_0_20173) && packet.ReadBit("HasProjectileVisual", idx);

            if (hasRuneData)
            {
                ReadRuneData(packet, idx, "RemainingRunes");
            }

            if (hasProjectileVisual)
            {
                ReadProjectileVisual(packet, idx, "ProjectileVisual");
            }

            return(packetSpellData);
        }
        public static void ReadSpellTargetData(Packet packet, PacketSpellData packetSpellData, uint spellID, params object[] idx)
        {
            packet.ResetBitReader();

            packet.ReadBitsE <TargetFlag>("Flags", ClientVersion.AddedInVersion(ClientVersionBuild.V8_1_5_29683) ? 26 : 25, idx);
            var hasSrcLoc  = packet.ReadBit("HasSrcLocation", idx);
            var hasDstLoc  = packet.ReadBit("HasDstLocation", idx);
            var hasOrient  = packet.ReadBit("HasOrientation", idx);
            var hasMapID   = packet.ReadBit("hasMapID ", idx);
            var nameLength = packet.ReadBits(7);

            var targetUnit = packet.ReadPackedGuid128("Unit", idx);

            if (packetSpellData != null)
            {
                packetSpellData.TargetUnit = targetUnit;
            }
            packet.ReadPackedGuid128("Item", idx);

            if (hasSrcLoc)
            {
                V6_0_2_19033.Parsers.SpellHandler.ReadLocation(packet, "SrcLocation");
            }

            Vector3?dstLocation = null;

            if (hasDstLoc)
            {
                dstLocation = V6_0_2_19033.Parsers.SpellHandler.ReadLocation(packet, "DstLocation");
                if (packetSpellData != null)
                {
                    packetSpellData.DstLocation = dstLocation;
                }
            }

            if (hasOrient)
            {
                packet.ReadSingle("Orientation", idx);
            }

            int mapID = -1;

            if (hasMapID)
            {
                mapID = packet.ReadInt32("MapID", idx);
            }

            if (Settings.UseDBC && dstLocation != null && mapID != -1)
            {
                for (uint i = 0; i < 32; i++)
                {
                    var tuple = Tuple.Create(spellID, i);
                    if (DBC.SpellEffectStores.ContainsKey(tuple))
                    {
                        var effect = DBC.SpellEffectStores[tuple];
                        if ((Targets)effect.ImplicitTarget[0] == Targets.TARGET_DEST_DB || (Targets)effect.ImplicitTarget[1] == Targets.TARGET_DEST_DB)
                        {
                            string effectHelper = $"Spell: { StoreGetters.GetName(StoreNameType.Spell, (int)spellID) } Efffect: { effect.Effect } ({ (SpellEffects)effect.Effect })";

                            var spellTargetPosition = new SpellTargetPosition
                            {
                                ID           = spellID,
                                EffectIndex  = (byte)i,
                                PositionX    = dstLocation.Value.X,
                                PositionY    = dstLocation.Value.Y,
                                PositionZ    = dstLocation.Value.Z,
                                MapID        = (ushort)mapID,
                                EffectHelper = effectHelper
                            };

                            if (!Storage.SpellTargetPositions.ContainsKey(spellTargetPosition))
                            {
                                Storage.SpellTargetPositions.Add(spellTargetPosition);
                            }
                        }
                    }
                }
            }

            packet.ReadWoWString("Name", nameLength, idx);
        }
        public static PacketSpellData ReadSpellCastData(Packet packet, params object[] idx)
        {
            var     packetSpellData = new PacketSpellData();
            bool    isSpellGo       = packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_SPELL_GO, Direction.ServerToClient);
            WowGuid targetGUID      = new WowGuid64();

            var casterGUID = packet.ReadPackedGuid("CasterGUID", idx);

            packetSpellData.Caster = packet.ReadPackedGuid("CasterUnit", idx);
            packetSpellData.CastId = packet.ReadByte("CastID", idx);
            var      spellId = packetSpellData.Spell = (uint)packet.ReadInt32 <SpellId>("SpellID", idx);
            CastFlag flags   = packet.ReadInt32E <CastFlag>("CastFlags", idx);

            packetSpellData.Flags    = (uint)flags;
            packetSpellData.Flags2   = packet.ReadUInt32("CastFlagsEx", idx);
            packetSpellData.CastTime = packet.ReadUInt32("CastTime", idx);

            if (isSpellGo)
            {
                var hitTargetsCount = packet.ReadByte("HitTargetsCount", idx);
                for (var i = 0; i < hitTargetsCount; ++i)
                {
                    packetSpellData.HitTargets.Add(packet.ReadGuid("HitTarget", idx, i));
                }

                var missCount = packet.ReadByte("MissStatusCount", idx);
                for (var i = 0; i < missCount; ++i)
                {
                    packetSpellData.MissedTargets.Add(ReadSpellMissStatus(packet, idx, "MissStatus", i));
                }
            }

            TargetFlag targetFlags = TargetFlag.Self;

            ReadSpellTargetData(packet, ref targetFlags, targetGUID, idx, "Target");

            if (flags.HasAnyFlag(CastFlag.PredictedPower))
            {
                packet.ReadUInt32("RemainingPower");
            }

            if (flags.HasAnyFlag(CastFlag.RuneInfo))
            {
                ReadRuneData(packet, idx, "RemainingRunes");
            }

            if (isSpellGo)
            {
                if (flags.HasAnyFlag(CastFlag.AdjustMissile))
                {
                    ReadMissileTrajectoryResult(packet, idx, "MissileTrajectory");
                }
            }

            if (flags.HasAnyFlag(CastFlag.Projectile))
            {
                ReadSpellAmmo(packet, packetSpellData, idx, "Ammo");
            }

            if (isSpellGo)
            {
                if (flags.HasAnyFlag(CastFlag.VisualChain))
                {
                    ReadProjectileVisual(packet, idx, "ProjectileVisual");
                }

                if (targetFlags.HasAnyFlag(TargetFlag.DestinationLocation))
                {
                    packet.ReadByte("DestLocSpellCastIndex", idx);
                }

                if (targetFlags.HasAnyFlag(TargetFlag.ExtraTargets))
                {
                    var targetPointsCount = packet.ReadInt32("TargetPointsCount", idx);
                    for (var i = 0; i < targetPointsCount; ++i)
                    {
                        ReadTargetLocation(packet, idx, "TargetPoints", i);
                    }
                }
            }
            else
            {
                if (flags.HasAnyFlag(CastFlag.Immunity))
                {
                    ReadCreatureImmunities(packet, idx, "Immunities");
                }

                if (flags.HasAnyFlag(CastFlag.HealPrediction))
                {
                    ReadSpellHealPrediction(packet, idx, "Predict");
                }
            }

            if (flags.HasAnyFlag(CastFlag.Unknown21) && !isSpellGo)
            {
                NpcSpellClick spellClick = new NpcSpellClick
                {
                    SpellID    = spellId,
                    CasterGUID = casterGUID,
                    TargetGUID = targetGUID
                };

                Storage.SpellClicks.Add(spellClick, packet.TimeSpan);
            }

            if (isSpellGo)
            {
                packet.AddSniffData(StoreNameType.Spell, (int)spellId, "SPELL_GO");
            }

            return(packetSpellData);
        }
 public static void ReadSpellAmmo(Packet packet, PacketSpellData packetSpellData, params object[] idx)
 {
     packetSpellData.AmmoDisplayId     = (int)packet.ReadUInt32("DisplayID", idx);
     packetSpellData.AmmoInventoryType = (uint)packet.ReadByteE <InventoryType>("InventoryType", idx);
 }