Exemplo n.º 1
0
 public MovementPackets(MovementPacket movPacket)
 {
     movementPackets.Enqueue(movPacket);
 }
Exemplo n.º 2
0
        public static void HandleMonsterMove(Packet packet)
        {
            Guid mover = packet.ReadPackedGuid("GUID");

            if (packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_MONSTER_MOVE_TRANSPORT))
            {
                packet.ReadPackedGuid("Transport GUID");

                if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) // no idea when this was added exactly
                    packet.ReadByte("Transport Seat");
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) // no idea when this was added exactly
                packet.ReadBoolean("Toggle AlwaysAllowPitching");

            var pos = packet.ReadVector3("Position");

            packet.ReadInt32("Move Ticks");

            var type = packet.ReadEnum<SplineType>("Spline Type", TypeCode.Byte);

            switch (type)
            {
                case SplineType.FacingSpot:
                {
                    packet.ReadVector3("Facing Spot");
                    break;
                }
                case SplineType.FacingTarget:
                {
                    packet.ReadGuid("Facing GUID");
                    break;
                }
                case SplineType.FacingAngle:
                {
                    packet.ReadSingle("Facing Angle");
                    break;
                }
                case SplineType.Stop:
                    return;
            }

            if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545))
            {
                // Not the best way
                ReadSplineMovement422(ref packet, pos);
                return;
            }

            var flags = packet.ReadEnum<SplineFlag>("Spline Flags", TypeCode.Int32);

            if (flags.HasAnyFlag(SplineFlag.AnimationTier))
            {
                packet.ReadEnum<MovementAnimationState>("Animation State", TypeCode.Byte);
                packet.ReadInt32("Asynctime in ms"); // Async-time in ms
            }

            if (flags.HasAnyFlag(SplineFlag.Falling)) // Could be SplineFlag.UsePathSmoothing
            {
                packet.ReadInt32("Unknown");
                packet.ReadInt16("Unknown");
                packet.ReadInt16("Unknown");
            }

            packet.ReadInt32("Move Time");

            if (flags.HasAnyFlag(SplineFlag.Trajectory))
            {
                packet.ReadSingle("Vertical Speed");
                packet.ReadInt32("Unk Int32 2");
            }

            var waypoints = packet.ReadInt32("Waypoints");
            var waypointsList = new List<string>();
            if (flags.HasAnyFlag(SplineFlag.Flying | SplineFlag.CatmullRom))
            {
                for (var i = 0; i < waypoints; i++)
                    waypointsList.Add(packet.ReadVector3("[" + i + "] Waypoint - Flying Or CatmullRom", i).ToString());
            }
            else
            {
                var newpos = packet.ReadVector3("Waypoint Endpoint");

                waypointsList.Add("New position: " + newpos.ToString());

                var mid = new Vector3();
                mid.X = (pos.X + newpos.X) * 0.5f;
                mid.Y = (pos.Y + newpos.Y) * 0.5f;
                mid.Z = (pos.Z + newpos.Z) * 0.5f;

                for (var i = 1; i < waypoints; i++)
                {
                    var vec = packet.ReadPackedVector3();
                    vec.X += mid.X;
                    vec.Y += mid.Y;
                    vec.Z += mid.Z;

                    string output = "[" + i + "]" + " Waypoint: " + vec;
                    packet.Writer.WriteLine(output);
                    waypointsList.Add(output);
                }
            }

            // Is this check really needed?
            if (mover.HasEntry() && mover.GetObjectType() == ObjectType.Unit)
            {
                MovementPacket movPacket = new MovementPacket(packet.Number, packet.Time, waypointsList);

                if (packet.SniffFileInfo.Stuffing.Waypoints.ContainsKey(mover))
                    packet.SniffFileInfo.Stuffing.Waypoints[mover].movementPackets.Enqueue(movPacket);
                else
                    packet.SniffFileInfo.Stuffing.Waypoints.TryAdd(mover, new MovementPackets(movPacket));
            }
        }