Esempio n. 1
0
        public static void ReadMovementSpline(Packet packet, Vector3 pos, params object[] indexes)
        {
            PacketMonsterMove monsterMove = packet.Holder.MonsterMove;
            SplineJump        jump        = monsterMove.Jump = new();

            monsterMove.Flags = packet.ReadInt32E <SplineFlag434>("Flags", indexes).ToUniversal();
            packet.ReadByte("AnimTier", indexes);
            packet.ReadUInt32("TierTransStartTime", indexes);
            monsterMove.ElapsedTime = packet.ReadInt32("Elapsed", indexes);
            monsterMove.MoveTime    = packet.ReadUInt32("MoveTime", indexes);
            jump.Gravity            = packet.ReadSingle("JumpGravity", indexes);
            jump.Duration           = packet.ReadUInt32("SpecialTime", indexes);
            var pointsCount = packet.ReadInt32("PointsCount", indexes);

            packet.ReadByte("Mode", indexes);
            packet.ReadByte("VehicleExitVoluntary", indexes);

            monsterMove.TransportGuid = packet.ReadPackedGuid128("TransportGUID", indexes);
            monsterMove.VehicleSeat   = packet.ReadSByte("VehicleSeat", indexes);

            var packedDeltasCount = packet.ReadInt32("PackedDeltasCount", indexes);

            Vector3 endpos = new Vector3();

            for (int i = 0; i < pointsCount; i++)
            {
                var spot = packet.ReadVector3();

                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                monsterMove.Points.Add(spot);
                packet.AddValue("Points", spot, indexes, i);
            }

            var waypoints = new Vector3[packedDeltasCount];

            for (int i = 0; i < packedDeltasCount; i++)
            {
                var packedDeltas = packet.ReadPackedVector3();
                waypoints[i].X = packedDeltas.X;
                waypoints[i].Y = packedDeltas.Y;
                waypoints[i].Z = packedDeltas.Z;
            }

            packet.ResetBitReader();
            var type = packet.ReadBitsE <SplineFacingType>("Face", 2, indexes);
            var monsterSplineFilter = packet.ReadBit("HasMonsterSplineFilter", indexes);

            switch (type)
            {
            case SplineFacingType.Spot:
                monsterMove.LookPosition = packet.ReadVector3("FaceSpot", indexes);
                break;

            case SplineFacingType.Target:
                SplineLookTarget lookTarget = monsterMove.LookTarget = new();
                lookTarget.Orientation = packet.ReadSingle("FaceDirection", indexes);
                lookTarget.Target      = packet.ReadPackedGuid128("FacingGUID", indexes);
                break;

            case SplineFacingType.Angle:
                monsterMove.LookOrientation = packet.ReadSingle("FaceDirection", indexes);
                break;
            }

            if (monsterSplineFilter)
            {
                ReadMonsterSplineFilter(packet, indexes, "MonsterSplineFilter");
            }

            // Calculate mid pos
            var mid = new Vector3
            {
                X = (pos.X + endpos.X) * 0.5f,
                Y = (pos.Y + endpos.Y) * 0.5f,
                Z = (pos.Z + endpos.Z) * 0.5f
            };

            for (var i = 0; i < packedDeltasCount; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                monsterMove.PackedPoints.Add(vec);
                packet.AddValue("WayPoints", vec, indexes, i);
            }
        }
        public static void ReadMovementSpline(Packet packet, Vector3 pos, params object[] indexes)
        {
            PacketMonsterMove monsterMove = packet.Holder.MonsterMove;

            monsterMove.Flags = packet.ReadUInt32E <SplineFlag>("Flags", indexes).ToUniversal();
            if (ClientVersion.RemovedInVersion(ClientType.Shadowlands))
            {
                packet.ReadByte("AnimTier", indexes);
                packet.ReadUInt32("TierTransStartTime", indexes);
            }
            monsterMove.ElapsedTime = packet.ReadInt32("Elapsed", indexes);
            monsterMove.MoveTime    = packet.ReadUInt32("MoveTime", indexes);
            packet.ReadUInt32("FadeObjectTime", indexes);

            packet.ReadByte("Mode", indexes);
            if (ClientVersion.RemovedInVersion(ClientType.Shadowlands))
            {
                packet.ReadByte("VehicleExitVoluntary", indexes);
            }

            monsterMove.TransportGuid = packet.ReadPackedGuid128("TransportGUID", indexes);
            monsterMove.VehicleSeat   = packet.ReadSByte("VehicleSeat", indexes);

            packet.ResetBitReader();

            var type        = packet.ReadBitsE <SplineFacingType>("Face", 2, indexes);
            var pointsCount = packet.ReadBits("PointsCount", 16, indexes);

            if (ClientVersion.AddedInVersion(ClientType.Shadowlands))
            {
                packet.ReadBit("VehicleExitVoluntary", indexes);
                packet.ReadBit("Interpolate", indexes);
            }
            var packedDeltasCount       = packet.ReadBits("PackedDeltasCount", 16, indexes);
            var hasSplineFilter         = packet.ReadBit("HasSplineFilter", indexes);
            var hasSpellEffectExtraData = packet.ReadBit("HasSpellEffectExtraData", indexes);
            var hasJumpExtraData        = packet.ReadBit("HasJumpExtraData", indexes);
            var hasAnimTier             = false;
            var hasUnk901 = false;

            if (ClientVersion.AddedInVersion(ClientType.Shadowlands))
            {
                hasAnimTier = packet.ReadBit("HasAnimTierTransition", indexes);
                hasUnk901   = packet.ReadBit("HasUnknown", indexes);
            }

            if (hasSplineFilter)
            {
                ReadMonsterSplineFilter(packet, indexes, "MonsterSplineFilter");
            }

            switch (type)
            {
            case SplineFacingType.Spot:
                monsterMove.LookPosition = packet.ReadVector3("FaceSpot", indexes);
                break;

            case SplineFacingType.Target:
                SplineLookTarget lookTarget = monsterMove.LookTarget = new();
                lookTarget.Orientation = packet.ReadSingle("FaceDirection", indexes);
                lookTarget.Target      = packet.ReadPackedGuid128("FacingGUID", indexes);
                break;

            case SplineFacingType.Angle:
                monsterMove.LookOrientation = packet.ReadSingle("FaceDirection", indexes);
                break;

            default:
                break;
            }

            Vector3 endpos = new Vector3();

            for (int i = 0; i < pointsCount; i++)
            {
                var spot = packet.ReadVector3();

                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                monsterMove.Points.Add(spot);
                packet.AddValue("Points", spot, indexes, i);
            }

            var waypoints = new Vector3[packedDeltasCount];

            for (int i = 0; i < packedDeltasCount; i++)
            {
                var packedDeltas = packet.ReadPackedVector3();
                waypoints[i].X = packedDeltas.X;
                waypoints[i].Y = packedDeltas.Y;
                waypoints[i].Z = packedDeltas.Z;
            }

            if (hasSpellEffectExtraData)
            {
                ReadMonsterSplineSpellEffectExtraData(packet, indexes, "MonsterSplineSpellEffectExtra");
            }

            if (hasJumpExtraData)
            {
                monsterMove.Jump = ReadMonsterSplineJumpExtraData(packet, indexes, "MonsterSplineJumpExtraData");
            }

            if (hasAnimTier)
            {
                packet.ReadInt32("TierTransitionID", indexes);
                packet.ReadInt32("StartTime", indexes);
                packet.ReadInt32("EndTime", indexes);
                packet.ReadByte("AnimTier", indexes);
            }

            if (hasUnk901)
            {
                for (var i = 0; i < 16; ++i)
                {
                    packet.ReadInt32("Unknown1", indexes, "Unknown901", i);
                    packet.ReadInt32("Unknown2", indexes, "Unknown901", i);
                    packet.ReadInt32("Unknown3", indexes, "Unknown901", i);
                    packet.ReadInt32("Unknown4", indexes, "Unknown901", i);
                }
            }

            // Calculate mid pos
            var mid = new Vector3
            {
                X = (pos.X + endpos.X) * 0.5f,
                Y = (pos.Y + endpos.Y) * 0.5f,
                Z = (pos.Z + endpos.Z) * 0.5f
            };

            for (var i = 0; i < packedDeltasCount; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                monsterMove.PackedPoints.Add(vec);
                packet.AddValue("WayPoints", vec, indexes, i);
            }
        }
Esempio n. 3
0
        public static void ReadMovementSpline(Packet packet, Vector3 pos, params object[] indexes)
        {
            PacketMonsterMove monsterMove = packet.Holder.MonsterMove;
            SplineJump        jump        = monsterMove.Jump = new();

            monsterMove.Flags = packet.ReadInt32E <SplineFlag>("Flags", indexes).ToUniversal();
            packet.ReadByte("AnimTier", indexes);
            packet.ReadUInt32("TierTransStartTime", indexes);
            monsterMove.ElapsedTime = packet.ReadInt32("Elapsed", indexes);
            var moveTime = monsterMove.MoveTime = packet.ReadUInt32("MoveTime", indexes);

            jump.Gravity  = packet.ReadSingle("JumpGravity", indexes);
            jump.Duration = packet.ReadUInt32("SpecialTime", indexes);

            packet.ReadByte("Mode", indexes);
            packet.ReadByte("VehicleExitVoluntary", indexes);

            monsterMove.TransportGuid = packet.ReadPackedGuid128("TransportGUID", indexes);
            monsterMove.VehicleSeat   = packet.ReadSByte("VehicleSeat", indexes);

            packet.ResetBitReader();

            var type                    = packet.ReadBitsE <SplineFacingType>("Face", 2, indexes);
            var pointsCount             = packet.ReadBits("PointsCount", 16, indexes);
            var packedDeltasCount       = packet.ReadBits("PackedDeltasCount", 16, indexes);
            var hasSplineFilter         = packet.ReadBit("HasSplineFilter", indexes);
            var hasSpellEffectExtraData = packet.ReadBit("HasSpellEffectExtraData", indexes);

            if (hasSplineFilter)
            {
                ReadMonsterSplineFilter(packet, indexes, "MonsterSplineFilter");
            }

            switch (type)
            {
            case SplineFacingType.Spot:
                monsterMove.LookPosition = packet.ReadVector3("FaceSpot", indexes);
                break;

            case SplineFacingType.Target:
                SplineLookTarget lookTarget = monsterMove.LookTarget = new();
                lookTarget.Orientation = packet.ReadSingle("FaceDirection", indexes);
                lookTarget.Target      = packet.ReadPackedGuid128("FacingGUID", indexes);
                break;

            case SplineFacingType.Angle:
                monsterMove.LookOrientation = packet.ReadSingle("FaceDirection", indexes);
                break;
            }

            Vector3 endpos = new Vector3();

            for (int i = 0; i < pointsCount; i++)
            {
                var spot = packet.ReadVector3();

                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                monsterMove.Points.Add(spot);
                packet.AddValue("Points", spot, indexes, i);
            }

            var waypoints = new Vector3[packedDeltasCount];

            for (int i = 0; i < packedDeltasCount; i++)
            {
                var packedDeltas = packet.ReadPackedVector3();
                waypoints[i].X = packedDeltas.X;
                waypoints[i].Y = packedDeltas.Y;
                waypoints[i].Z = packedDeltas.Z;
            }

            if (hasSpellEffectExtraData)
            {
                ReadMonsterSplineSpellEffectExtraData(packet, "MonsterSplineSpellEffectExtra");
            }

            // Calculate mid pos
            var mid = new Vector3
            {
                X = (pos.X + endpos.X) * 0.5f,
                Y = (pos.Y + endpos.Y) * 0.5f,
                Z = (pos.Z + endpos.Z) * 0.5f
            };


            List <Vector3> trueWaypoints = new List <Vector3>();

            for (var i = 0; i < packedDeltasCount; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                monsterMove.PackedPoints.Add(vec);
                trueWaypoints.Add(vec);
                packet.AddValue("WayPoints", vec, indexes, i);
            }

            if (endpos.X != 0 && endpos.Y != 0 && endpos.Z != 0)
            {
                double distance = 0;
                if (packedDeltasCount > 0)
                {
                    distance = GetDistance(pos, trueWaypoints[0]);
                    for (var i = 1; i < packedDeltasCount; ++i)
                    {
                        distance += GetDistance(trueWaypoints[i - 1], trueWaypoints[i]);
                    }
                    distance += GetDistance(trueWaypoints[(int)(packedDeltasCount - 1)], endpos);
                }
                else
                {
                    distance = GetDistance(pos, endpos);
                }

                packet.WriteLine("(MovementMonsterSpline) Distance: " + distance.ToString());
                packet.WriteLine("(MovementMonsterSpline) Speed: " + (distance / moveTime * 1000).ToString());
            }
        }