Ejemplo n.º 1
0
        public static void HandleCorpseQueryResponse(Packet packet)
        {
            var pos = new Vector3();
            var guid = new byte[8];

            guid[4] = packet.ReadBit();
            guid[2] = packet.ReadBit();
            guid[5] = packet.ReadBit();
            guid[3] = packet.ReadBit();
            guid[1] = packet.ReadBit();
            guid[6] = packet.ReadBit();
            guid[0] = packet.ReadBit();
            packet.ReadBit("Corpse Found");
            guid[7] = packet.ReadBit();

            packet.ReadXORByte(guid, 3);
            packet.ReadXORByte(guid, 1);
            packet.ReadXORByte(guid, 2);
            packet.ReadInt32<MapId>("Map ID");
            pos.X = packet.ReadSingle();
            packet.ReadXORByte(guid, 6);
            packet.ReadXORByte(guid, 4);
            packet.ReadXORByte(guid, 5);
            packet.ReadInt32<MapId>("Corpse Map ID");
            packet.ReadXORByte(guid, 7);
            pos.Z = packet.ReadSingle();
            packet.ReadXORByte(guid, 0);
            pos.Y = packet.ReadSingle();

            packet.AddValue("Position", pos);
            packet.WriteGuid("Corpse Low GUID", guid);
        }
Ejemplo n.º 2
0
 public void TestConstructor()
 {
     var vect = new Vector3(1.0f, 2.0f, 3.0f);
     Assert.IsNotNull(vect);
     Assert.AreEqual(1.0f, vect.X);
     Assert.AreEqual(2.0f, vect.Y);
     Assert.AreEqual(3.0f, vect.Z);
 }
Ejemplo n.º 3
0
        public void TestToString()
        {
            Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;

            var quat = new Vector3(1.1f, 2.0f, 0f);

            Assert.AreEqual("X: 1.1 Y: 2 Z: 0", quat.ToString());
        }
Ejemplo n.º 4
0
        public void TestGetHashCode()
        {
            var vect1 = new Vector3(1.1f, 2.0f, 0f);
            var vect15 = new Vector3(1.1f, 2.0f, 0f);
            var vect2 = new Vector3(1.1f, 2.0f, 0.0001f);

            Assert.AreEqual(vect1.GetHashCode(), vect15.GetHashCode());
            Assert.AreNotEqual(vect1.GetHashCode(), vect2.GetHashCode());
        }
Ejemplo n.º 5
0
        public static void HandleDeathReleaseLoc(Packet packet)
        {
            var pos = new Vector3();
            pos.Y = packet.ReadSingle();
            pos.Z = packet.ReadSingle();
            pos.X = packet.ReadSingle();
            packet.ReadInt32<MapId>("Map Id");

            packet.AddValue("Position", pos);
        }
Ejemplo n.º 6
0
        public void TestEquals()
        {
            var vect1 = new Vector3(1.1f, 2.0f, 0f);
            var vect15 = new Vector3(1.1f, 2.0f, 0f);
            var vect2 = new Vector3(1.1f, 2.0f, 3.0f);

            Assert.IsTrue(vect1.Equals(vect15));
            Assert.IsTrue(vect1.Equals(vect1));
            Assert.IsFalse(vect1.Equals(vect2));
        }
Ejemplo n.º 7
0
        public static void HandleBindPointUpdate(Packet packet)
        {
            var pos = new Vector3();

            pos.Y = packet.ReadSingle();
            pos.X = packet.ReadSingle();
            pos.Z = packet.ReadSingle();
            packet.ReadInt32<AreaId>("Area Id");
            CoreParsers.MovementHandler.CurrentMapId = (uint)packet.ReadInt32<MapId>("Map");

            packet.AddValue("Position", pos);
        }
Ejemplo n.º 8
0
        public void TestOperators()
        {
            var vect1 = new Vector3(1.1f, 2.0f, 0f);
            var vect15 = new Vector3(1.1f, 2.0f, 0f);
            var vect2 = new Vector3(1.1f, 2.0f, 3.0f);

            Assert.IsTrue(vect1 == vect15);
            #pragma warning disable 1718
            Assert.IsTrue(vect1 == vect1);
            #pragma warning restore 1718
            Assert.IsFalse(vect1 == vect2);
        }
Ejemplo n.º 9
0
        public string GetCommand(Race race, Class clss, int map, int zone, Vector3 pos)
        {
            var builder = new SQLCommandBuilder("playercreateinfo");

            builder.AddColumnValue("race", (int)race);
            builder.AddColumnValue("class", (int)clss);
            builder.AddColumnValue("map", map);
            builder.AddColumnValue("zone", zone);
            builder.AddColumnValue("position_x", pos.X);
            builder.AddColumnValue("position_y", pos.Y);
            builder.AddColumnValue("position_z", pos.Z);

            return builder.BuildInsert();
        }
Ejemplo n.º 10
0
        public string GetCommand(uint entry, uint map, int phaseMask, Vector3 pos, float orient)
        {
            var builder = new SQLCommandBuilder("gameobject");

            builder.AddColumnValue("id", entry);
            builder.AddColumnValue("map", map);
            builder.AddColumnValue("spawnMask", 1);
            builder.AddColumnValue("phaseMask", phaseMask);
            builder.AddColumnValue("position_x", pos.X);
            builder.AddColumnValue("position_y", pos.Y);
            builder.AddColumnValue("position_z", pos.Z);
            builder.AddColumnValue("orientation", orient);
            builder.AddColumnValue("rotation0", 0);
            builder.AddColumnValue("rotation1", 0);
            builder.AddColumnValue("rotation2", 0);
            builder.AddColumnValue("rotation3", 0);
            builder.AddColumnValue("spawntimesecs", 120);
            builder.AddColumnValue("animprogress", 0);
            builder.AddColumnValue("state", 1);

            return builder.BuildInsert();
        }
Ejemplo n.º 11
0
        public string GetCommand(uint entry, uint map, int phaseMask, Vector3 position, float orient)
        {
            var builder = new SQLInsert();
            builder.Table = "creature";

            // If map is Eastern Kingdoms, Kalimdor, Outland, Northrend or Ebon Hold use a lower respawn time
            // TODO: Rank and if npc is needed for quest kill should change spawntime aswell
            var spawnTimeSecs = (map == 0 || map == 1 || map == 530 || map == 571 || map == 609) ? 120 : 7200;
            var movementType = 0;
            var spawnDist = (movementType == 1) ? 5 : 0;

            builder.AddValue("guid", "@GUID+X");
            builder.AddValue("id", entry);
            builder.AddValue("map", map);
            builder.AddValue("spawnMask", 1);
            builder.AddValue("phaseMask", "0x" + phaseMask.ToString("X8"));
            builder.AddValue("modelid", 0);
            builder.AddValue("equipment_id", 0);
            builder.AddValue("position_x", position.X);
            builder.AddValue("position_y", position.Y);
            builder.AddValue("position_z", position.Z);
            builder.AddValue("orientation", orient);
            builder.AddValue("spawntimesecs", spawnTimeSecs);
            builder.AddValue("spawndist", spawnDist);
            builder.AddValue("currentwaypoint", 0);
            builder.AddValue("curhealth", 1);
            builder.AddValue("curmana", 0);
            builder.AddValue("MovementType", movementType);
            builder.AddValue("npcflag", 0); // TODO: Check if they match updated creature_template value ?
            builder.AddValue("unit_flags", 0);
            builder.AddValue("dynamicflags", 0);

            builder.AddWhere("guid", "@GUID+X");
            builder.AddWhere("id", entry);

            return builder.Build();
        }
Ejemplo n.º 12
0
        public static void HandleMonsterMove(Packet packet)
        {
            var pos = new Vector3();

            var guid2 = new byte[8];
            var factingTargetGUID = new byte[8];
            var ownerGUID = new byte[8];

            pos.Z = packet.ReadSingle();        // +6
            pos.X = packet.ReadSingle();        // +4
            packet.ReadInt32("Move Ticks");     // +10
            pos.Y = packet.ReadSingle();        // +5
            packet.ReadSingle("Float12");       // +12
            packet.ReadSingle("Float13");       // +13
            packet.ReadSingle("Float11");       // +11

            var bit21 = !packet.ReadBit();      // +21
            ownerGUID[0] = packet.ReadBit();    // +32 - 0

            var splineType = (int)packet.ReadBits(3);   // +68
            if (splineType == 3)
                packet.StartBitStream(factingTargetGUID, 6, 4, 3, 0, 5, 7, 1, 2);

            var bit19 = !packet.ReadBit();       // +19
            var bit69 = !packet.ReadBit();       // +69
            var bit120 = !packet.ReadBit();      // +120

            var splineCount = (int)packet.ReadBits(20); // +92

            var bit16 = !packet.ReadBit();      // +16

            ownerGUID[3] = packet.ReadBit();    // +35 - 3
            var bit108 = !packet.ReadBit();     // +108
            var bit22 = !packet.ReadBit();      // +22
            var bit109 = !packet.ReadBit();     // +109
            var bit20 = !packet.ReadBit();      // +20
            ownerGUID[7] = packet.ReadBit();    // +39 - 7
            ownerGUID[4] = packet.ReadBit();    // +36 - 4
            var bit18 = !packet.ReadBit();      // +18
            ownerGUID[5] = packet.ReadBit();    // +37 - 5

            var bits124 = (int)packet.ReadBits(22); // +124

            ownerGUID[6] = packet.ReadBit();    // +38 - 6
            packet.ReadBit();                   // fake bit

            packet.StartBitStream(guid2, 7, 1, 3, 0, 6, 4, 5, 2);

            var bit176 = packet.ReadBit();      // +176
            var bits84 = 0u;
            if (bit176)
            {
                packet.ReadBits("bits74", 2);
                bits84 = packet.ReadBits(22);
            }

            packet.ReadBit("bit56");            // +56
            ownerGUID[2] = packet.ReadBit();    // +38 - 2
            ownerGUID[1] = packet.ReadBit();    // +33 - 1

            var waypoints = new Vector3[bits124];
            for (var i = 0; i < bits124; ++i)
            {
                var vec = packet.ReadPackedVector3();
                waypoints[i].X = vec.X;
                waypoints[i].Y = vec.Y;
                waypoints[i].Z = vec.Z;
            }

            packet.ReadXORByte(ownerGUID, 1);   // +33 - 1

            packet.ParseBitStream(guid2, 6, 4, 1, 7, 0, 3, 5, 2);

            var endpos = new Vector3();
            for (var i = 0; i < splineCount; ++i)
            {
                var spot = new Vector3
                {
                    Y = packet.ReadSingle(),
                    X = packet.ReadSingle(),
                    Z = packet.ReadSingle()
                };
                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                packet.AddValue("Spline Waypoint", spot, i);
            }

            if (bit18)
                packet.ReadInt32("Int18");   // +18

            if (splineType == 3)
            {
                packet.ParseBitStream(factingTargetGUID, 5, 7, 0, 4, 3, 2, 6, 1);
                packet.WriteGuid("Facting Target GUID", factingTargetGUID);
            }

            packet.ReadXORByte(ownerGUID, 5);   // +37 - 5

            if (bit21)
                packet.ReadSingle("Float21");   // +21

            if (bit176)
            {
                for (var i = 0; i < bits84; ++i)
                {
                    packet.ReadInt16("short36+4", i);
                    packet.ReadInt16("short36+0", i);
                }

                packet.ReadSingle("Float42");   // +42
                packet.ReadInt16("Int82");      // +82
                packet.ReadInt16("Int86");      // +86
                packet.ReadSingle("Float40");   // +40
            }

            if (bit19)
                packet.ReadInt32("Int19");      // +19

            if (splineType == 4)
                packet.ReadSingle("Facing Angle");  // +45

            packet.ReadXORByte(ownerGUID, 3);   // +35 - 3

            if (bit16)
                packet.ReadInt32E<SplineFlag>("Spline Flags"); // +16

            if (bit69)
                packet.ReadByte("Byte69");      // +69

            packet.ReadXORByte(ownerGUID, 6);   // +38 - 6

            if (bit109)
                packet.ReadByte("Byte109");     // +109

            if (splineType == 2)
            {
                packet.ReadSingle("Float48");   // +48
                packet.ReadSingle("Float49");   // +49
                packet.ReadSingle("Float50");   // +50
            }

            packet.ReadXORByte(ownerGUID, 0);   // +32 - 0

            if (bit120)
                packet.ReadByte("Byte120");     // +120

            if (bit108)
                packet.ReadByte("Byte108");     // +108

            packet.ReadXORByte(ownerGUID, 7);   // +39 - 7
            packet.ReadXORByte(ownerGUID, 2);   // +34 - 2

            if (bit22)
                packet.ReadInt32("Int22");      // +22

            packet.ReadXORByte(ownerGUID, 4);   // +36 - 4

            if (bit20)
                packet.ReadInt32("Move Time");      // +20

            // Calculate mid pos
            var mid = new Vector3();
            mid.X = (pos.X + endpos.X) * 0.5f;
            mid.Y = (pos.Y + endpos.Y) * 0.5f;
            mid.Z = (pos.Z + endpos.Z) * 0.5f;
            for (var i = 0; i < bits124; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                packet.AddValue("Waypoint", vec, i);
            }

            packet.WriteGuid("Owner GUID", ownerGUID);
            packet.WriteGuid("GUID2", guid2);
            packet.AddValue("Position", pos);
        }
Ejemplo n.º 13
0
        public static void HandleMonsterMove(Packet packet)
        {
            var ownerGUID = new byte[8];
            var guid2 = new byte[8];
            var factingTargetGUID = new byte[8];
            var pos = new Vector3();

            var bitB0 = packet.ReadBit();
            ownerGUID[5] = packet.ReadBit();
            var hasAnimationTime = !packet.ReadBit();
            var hasTime = !packet.ReadBit();
            packet.StartBitStream(ownerGUID, 4, 3);
            var bit4C = !packet.ReadBit();
            var bit78 = packet.ReadBit();
            ownerGUID[2] = packet.ReadBit();
            var hasFlags = !packet.ReadBit();
            ownerGUID[0] = packet.ReadBit();

            var bits8C = 0u;
            if (bitB0)
            {
                packet.ReadBits("bits9C", 2);
                bits8C = packet.ReadBits(22);
            }

            var waypointCount = packet.ReadBits(22);
            var bit6D = !packet.ReadBit();
            ownerGUID[7] = packet.ReadBit();
            packet.ReadBit(); // fake bit
            packet.StartBitStream(guid2, 5, 3, 4, 6, 2, 1, 7, 0);
            var hasAnimationState = !packet.ReadBit();
            var hasParabolicTime = !packet.ReadBit();
            var hasParabolicSpeed = !packet.ReadBit();
            ownerGUID[6] = packet.ReadBit();
            var splineCount = packet.ReadBits(20);
            ownerGUID[1] = packet.ReadBit();
            var bit6C = !packet.ReadBit();
            var splineType = packet.ReadBits(3);

            if (splineType == 3)
                packet.StartBitStream(factingTargetGUID, 4, 6, 5, 1, 0, 7, 3, 2);

            packet.ReadBit("bit38");
            packet.ResetBitReader();

            if (bitB0)
            {
                packet.ReadSingle("floatA8");
                packet.ReadSingle("floatA0");
                packet.ReadInt16("shortAC");
                for (var i = 0; i < bits8C; ++i)
                {
                    packet.ReadInt16("short94+2", i);
                    packet.ReadInt16("short94+0", i);
                }
                packet.ReadInt16("shortA4");
            }

            packet.ReadXORBytes(guid2, 0, 1, 2, 7, 3, 4, 6, 5);
            if (splineType == 3)
            {
                packet.ParseBitStream(factingTargetGUID, 2, 1, 7, 0, 5, 3, 4, 6);
                packet.WriteGuid("Facting Target GUID", factingTargetGUID);
            }

            pos.Y = packet.ReadSingle();
            packet.ReadXORByte(ownerGUID, 7);
            if (hasAnimationTime)
                packet.ReadInt32("Asynctime in ms"); // Async-time in ms

            var waypoints = new Vector3[waypointCount];
            for (var i = 0; i < waypointCount; ++i)
            {
                var vec = packet.ReadPackedVector3();
                waypoints[i].X = vec.X;
                waypoints[i].Y = vec.Y;
                waypoints[i].Z = vec.Z;
            }

            packet.ReadSingle("Float2C");
            pos.Z = packet.ReadSingle();
            packet.ReadSingle("Float30");

            if (splineType == 2)
            {
                var spot = new Vector3
                {
                    Y = packet.ReadSingle(),
                    Z = packet.ReadSingle(),
                    X = packet.ReadSingle()
                };
                packet.AddValue("Facing Spot", spot);
            }

            Vector3 endpos = new Vector3();
            for (var i = 0; i < splineCount; ++i)
            {
                var spot = new Vector3
                {
                    Y = packet.ReadSingle(),
                    Z = packet.ReadSingle(),
                    X = packet.ReadSingle()
                };
                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                packet.AddValue("Spline Waypoint", spot, i);
            }

            packet.ReadXORByte(ownerGUID, 5);
            packet.ReadInt32("Move Ticks");

            if (hasFlags)
                packet.ReadInt32E<SplineFlag434>("Spline Flags");

            if (hasAnimationState)
                packet.ReadByteE<MovementAnimationState>("Animation State");

            packet.ReadXORByte(ownerGUID, 0);
            if (bit6D)
                packet.ReadByte("byte6D");

            if (hasParabolicTime)
                packet.ReadInt32("Async-time in ms");

            pos.X = packet.ReadSingle();
            if (hasTime)
                packet.ReadInt32("Move Time in ms");

            packet.ReadXORByte(ownerGUID, 4);
            if (hasParabolicSpeed)
                packet.ReadSingle("Vertical Speed");

            if (!bit78)
                packet.ReadByte("byte78");

            if (splineType == 4)
                packet.ReadSingle("Facing Angle");

            if (bit6C)
                packet.ReadByte("byte6C");

            packet.ReadSingle("Float34");
            if (bit4C)
                packet.ReadInt32("int4C");

            packet.ReadXORBytes(ownerGUID, 6, 2, 3, 1);

            // Calculate mid pos
            var mid = new Vector3();
            mid.X = (pos.X + endpos.X) * 0.5f;
            mid.Y = (pos.Y + endpos.Y) * 0.5f;
            mid.Z = (pos.Z + endpos.Z) * 0.5f;
            for (var i = 0; i < waypointCount; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                packet.AddValue("Waypoint", vec, i);
            }

            packet.WriteGuid("Owner GUID", ownerGUID);
            packet.WriteGuid("GUID2", guid2);
            packet.AddValue("Position", pos);
        }
Ejemplo n.º 14
0
        public static void ReadMovementMonsterSpline(Packet packet, Vector3 pos, params object[] indexes)
        {
            packet.ReadUInt32("Id", indexes);
            packet.ReadVector3("Destination", indexes);

            ReadMovementSpline(packet, pos, indexes, "MovementSpline");

            packet.ResetBitReader();

            packet.ReadBit("CrzTeleport", indexes);
            packet.ReadBits("UnkBit", 2, indexes);
        }
Ejemplo n.º 15
0
        public static void HandleMonsterMove(Packet packet)
        {
            var ownerGUID = new byte[8];
            var guid2 = new byte[8];
            var factingTargetGUID = new byte[8];
            var pos = new Vector3();

            packet.ReadSingle("Float34");
            packet.ReadInt32("Move Ticks");
            pos.X = packet.ReadSingle();
            pos.Z = packet.ReadSingle();
            packet.ReadSingle("Float30");
            packet.ReadSingle("Float2C");
            pos.Y = packet.ReadSingle();

            packet.ReadBit("bit38");
            packet.ReadBit(); // fake bit
            var bit6C = !packet.ReadBit();
            ownerGUID[4] = packet.ReadBit();
            var hasTime = !packet.ReadBit();
            ownerGUID[1] = packet.ReadBit();
            var bit6D = !packet.ReadBit();
            ownerGUID[2] = packet.ReadBit();
            var bit4C = !packet.ReadBit();

            packet.StartBitStream(guid2, 6, 1, 3, 5, 2, 7, 4, 0);
            var bit8C = packet.ReadBit();
            ownerGUID[3] = packet.ReadBit();
            var hasFlags = !packet.ReadBit();
            var waypointCount = packet.ReadBits(22);
            packet.StartBitStream(ownerGUID, 5, 0);
            var hasAnimationTime = !packet.ReadBit();
            var hasParabolicTime = !packet.ReadBit();
            ownerGUID[6] = packet.ReadBit();

            var bits90 = 0u;
            if (bit8C)
            {
                bits90 = packet.ReadBits(22);
                packet.ReadBits("bitsA0", 2);
            }

            var hasAnimationState = !packet.ReadBit();
            var splineType = packet.ReadBits(3);
            var splineCount = packet.ReadBits(20);

            if (splineType == 3)
                packet.StartBitStream(factingTargetGUID, 5, 3, 6, 2, 1, 4, 7, 0);

            var hasParabolicSpeed = !packet.ReadBit();
            ownerGUID[7] = packet.ReadBit();
            var bit78 = packet.ReadBit();

            packet.ResetBitReader();
            packet.ReadXORByte(ownerGUID, 2);
            if (splineType == 3)
            {
                packet.ParseBitStream(factingTargetGUID, 1, 0, 6, 5, 3, 4, 7, 2);
                packet.WriteGuid("Facting Target GUID", factingTargetGUID);
            }

            if (bit6D)
                packet.ReadByte("byte6D");

            if (hasParabolicTime)
                packet.ReadInt32("Async-time in ms");

            if (hasAnimationState)
                packet.ReadByteE<MovementAnimationState>("Animation State");

            if (hasTime)
                packet.ReadInt32("Move Time in ms");

            packet.ReadXORBytes(ownerGUID, 7, 1);

            if (hasParabolicSpeed)
                packet.ReadSingle("Vertical Speed");

            packet.ReadXORByte(ownerGUID, 0);
            if (bit8C)
            {
                for (var i = 0; i < bits90; ++i)
                {
                    packet.ReadInt16("short94+2", i);
                    packet.ReadInt16("short94+0", i);
                }

                packet.ReadInt16("shortA8");
                packet.ReadInt16("shortB0");
                packet.ReadSingle("floatAC");
                packet.ReadSingle("floatA4");
            }

            if (hasFlags)
                packet.ReadInt32E<SplineFlag434>("Spline Flags");

            if (splineType == 2)
                packet.ReadVector3("Facing Spot");

            if (bit6C)
                packet.ReadByte("byte6C");

            packet.ReadXORBytes(guid2, 4, 1, 0, 7, 5, 6, 3, 2);

            Vector3 endpos = new Vector3();
            for (var i = 0; i < splineCount; ++i)
            {
                // client always taking first point
                if (i == 0)
                    endpos = packet.ReadVector3("Spline Waypoint", i);
                else
                    packet.ReadVector3("Spline Waypoint", i);
            }

            packet.ReadXORBytes(ownerGUID, 6, 3, 5);
            if (bit4C)
                packet.ReadInt32("int4C");

            if (splineType == 4)
                packet.ReadSingle("Facing Angle");

            if (!bit78)
                packet.ReadByte("byte78");

            packet.ReadXORByte(ownerGUID, 4);
            if (hasAnimationTime)
                packet.ReadInt32("Asynctime in ms"); // Async-time in ms

            // Calculate mid pos
            var mid = new Vector3();
            mid.X = (pos.X + endpos.X) * 0.5f;
            mid.Y = (pos.Y + endpos.Y) * 0.5f;
            mid.Z = (pos.Z + endpos.Z) * 0.5f;
            for (var i = 0; i < waypointCount; ++i)
            {
                // sub_7D11B4(result& wp, int32(from packet), mid)
                var vec = packet.ReadPackedVector3();
                vec.X = mid.X - vec.X;
                vec.Y = mid.Y - vec.Y;
                vec.Z = mid.Z - vec.Z;
                packet.AddValue("Waypoint", vec, i);
            }

            packet.WriteGuid("Owner GUID", ownerGUID);
            packet.WriteGuid("GUID2", guid2);
            packet.AddValue("Position", pos);
        }
Ejemplo n.º 16
0
        public static void HandleMonsterMove(Packet packet)
        {
            var pos = new Vector3();

            var guid2 = new byte[8];
            var factingTargetGUID = new byte[8];
            var ownerGUID = new byte[8];

            ownerGUID[4] = packet.ReadBit();

            var bit40 = !packet.ReadBit();
            var hasTime = !packet.ReadBit();

            ownerGUID[3] = packet.ReadBit();

            var bit30 = !packet.ReadBit();

            packet.ReadBit(); // fake bit

            var splineCount = (int)packet.ReadBits(20);
            var bit98 = packet.ReadBit();
            var splineType = (int)packet.ReadBits(3);

            if (splineType == 3)
                packet.StartBitStream(factingTargetGUID, 0, 7, 3, 4, 5, 6, 1, 2);

            var bit55 = !packet.ReadBit();
            var bit60 = !packet.ReadBit();
            var bit54 = !packet.ReadBit();
            var bit34 = !packet.ReadBit();

            ownerGUID[6] = packet.ReadBit();
            ownerGUID[1] = packet.ReadBit();
            ownerGUID[0] = packet.ReadBit();

            packet.StartBitStream(guid2, 1, 3, 4, 5, 6, 0, 7, 2);

            ownerGUID[5] = packet.ReadBit();
            var bit20 = packet.ReadBit();
            ownerGUID[7] = packet.ReadBit();
            var bit2D = !packet.ReadBit();

            var bits84 = 0u;
            if (bit98)
            {
                packet.ReadBits("bits74", 2);
                bits84 = packet.ReadBits(22);
            }

            var hasFlags = !packet.ReadBit();
            ownerGUID[2] = packet.ReadBit();
            var bits64 = (int)packet.ReadBits(22);
            var bit0 = !packet.ReadBit();
            packet.ReadSingle("Float14");

            if (splineType == 3)
            {
                packet.ParseBitStream(factingTargetGUID, 1, 6, 4, 3, 5, 0, 2, 7);
                packet.WriteGuid("Facting Target GUID", factingTargetGUID);
            }

            packet.ReadXORByte(ownerGUID, 5);
            if (bit54)
                packet.ReadByte("Byte54");
            packet.ReadXORByte(ownerGUID, 4);
            if (bit98)
            {
                packet.ReadSingle("Float88");
                for (var i = 0; i < bits84; ++i)
                {
                    packet.ReadInt16("short74+2", i);
                    packet.ReadInt16("short74+0", i);
                }

                packet.ReadInt16("Int8C");
                packet.ReadInt16("Int94");
                packet.ReadSingle("Float90");
            }

            if (hasFlags)
                packet.ReadInt32E<SplineFlag434>("Spline Flags");

            if (bit40)
                packet.ReadInt32("Int40");

            if (bit2D)
                packet.ReadByte("Byte2D");

            Vector3 endpos = new Vector3();
            for (var i = 0; i < splineCount; ++i)
            {
                var spot = new Vector3
                {
                    Y = packet.ReadSingle(),
                    X = packet.ReadSingle(),
                    Z = packet.ReadSingle()
                };
                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                packet.AddValue("Spline Waypoint", spot, i);
            }

            packet.ParseBitStream(guid2, 6, 7, 2, 5, 3, 4, 1, 0);

            if (bit55)
                packet.ReadByte("Byte55");

            packet.ReadInt32("Move Ticks");

            packet.ReadXORByte(ownerGUID, 0);

            if (splineType == 4)
                packet.ReadSingle("Facing Angle");

            pos.Y = packet.ReadSingle();

            if (bit0)
                packet.ReadSingle("Float3C");

            packet.ReadXORByte(ownerGUID, 7);
            packet.ReadXORByte(ownerGUID, 1);

            var waypoints = new Vector3[bits64];
            for (var i = 0; i < bits64; ++i)
            {
                var vec = packet.ReadPackedVector3();
                waypoints[i].X = vec.X;
                waypoints[i].Y = vec.Y;
                waypoints[i].Z = vec.Z;
            }

            if (splineType == 2)
            {
                packet.ReadSingle("FloatA8");
                packet.ReadSingle("FloatAC");
                packet.ReadSingle("FloatB0");
            }

            if (hasTime)
                packet.ReadInt32("Move Time in ms");

            if (bit30)
                packet.ReadInt32("Int30");

            packet.ReadXORByte(ownerGUID, 6);
            packet.ReadSingle("Float1C");
            packet.ReadXORByte(ownerGUID, 3);
            pos.X = packet.ReadSingle();
            packet.ReadXORByte(ownerGUID, 2);

            if (bit34)
                packet.ReadInt32("Int34");

            if (bit60)
                packet.ReadByte("Byte60");

            packet.ReadSingle("Float18");
            pos.Z = packet.ReadSingle();

            // Calculate mid pos
            var mid = new Vector3();
            mid.X = (pos.X + endpos.X) * 0.5f;
            mid.Y = (pos.Y + endpos.Y) * 0.5f;
            mid.Z = (pos.Z + endpos.Z) * 0.5f;
            for (var i = 0; i < bits64; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                packet.AddValue("Waypoint", vec, i);
            }

            packet.WriteGuid("Owner GUID", ownerGUID);
            packet.WriteGuid("GUID2", guid2);
            packet.AddValue("Position", pos);
        }
Ejemplo n.º 17
0
        public static void HandleMonsterMove(Packet packet)
        {
            var guid = packet.ReadPackedGuid("GUID");

            if (Storage.Objects != null && Storage.Objects.ContainsKey(guid))
            {
                var obj = Storage.Objects[guid].Item1;
                UpdateField uf;
                if (obj.UpdateFields != null && obj.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(UnitField.UNIT_FIELD_FLAGS), out uf))
                    if ((uf.UInt32Value & (uint)UnitFlags.IsInCombat) == 0) // movement could be because of aggro so ignore that
                        obj.Movement.HasWpsOrRandMov = true;
            }

            if (packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_MONSTER_MOVE_TRANSPORT, Direction.ServerToClient))
            {
                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.ReadBool("Toggle AnimTierInTrans");

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

            packet.ReadInt32("Move Ticks");

            var type = packet.ReadByteE<SplineType>("Spline Type");

            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;
            }

            var flags = packet.ReadInt32E<SplineFlag>("Spline Flags");

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

            packet.ReadInt32("Move Time");

            if (flags.HasAnyFlag(SplineFlag.Parabolic))
            {
                packet.ReadSingle("Vertical Speed");
                packet.ReadInt32("Async-time in ms");
            }

            var waypoints = packet.ReadInt32("Waypoints");

            if (flags.HasAnyFlag(SplineFlag.UncompressedPath))
            {
                for (var i = 0; i < waypoints; i++)
                    packet.ReadVector3("Waypoint", i);
            }
            else
            {
                var newpos = packet.ReadVector3("Waypoint Endpoint");

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

                if (waypoints != 1)
                {
                    var vec = packet.ReadPackedVector3();
                    vec.X += mid.X;
                    vec.Y += mid.Y;
                    vec.Z += mid.Z;
                    packet.AddValue("Waypoint", vec, 0);

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

                            packet.AddValue("Waypoint", vec, i);
                        }
                    }
                }
            }
        }
Ejemplo n.º 18
0
        public static void ReadMovementSpline(Packet packet, Vector3 pos, params object[] indexes)
        {
            packet.ReadInt32E<SplineFlag434>("Flags", indexes);
            packet.ReadByte("AnimTier", indexes);
            packet.ReadUInt32("TierTransStartTime", indexes);
            packet.ReadInt32("Elapsed", indexes);
            packet.ReadUInt32("MoveTime", indexes);
            packet.ReadSingle("JumpGravity", indexes);
            packet.ReadUInt32("SpecialTime", indexes);
            var pointsCount = packet.ReadInt32("PointsCount", indexes);

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

            packet.ReadPackedGuid128("TransportGUID", indexes);
            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;

                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.ReadBits("Face", 2, indexes);
            var monsterSplineFilter = packet.ReadBit("HasMonsterSplineFilter", indexes);

            switch (type)
            {
                case 1:
                    packet.ReadVector3("FaceSpot", indexes);
                    break;
                case 2:
                    packet.ReadSingle("FaceDirection", indexes);
                    packet.ReadPackedGuid128("FacingGUID", indexes);
                    break;
                case 3:
                    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
                };
                packet.AddValue("WayPoints", vec, indexes, i);
            }
        }
Ejemplo n.º 19
0
        public static void HandleMonsterMove(Packet packet)
        {
            var pos = new Vector3();

            var ownerGUID = new byte[8];
            var guid2 = new byte[8];
            var factingTargetGUID = new byte[8];

            packet.ReadSingle("Float30");
            packet.ReadInt32("Int28");
            packet.ReadSingle("Float34");
            packet.ReadSingle("Float2C");
            pos.X = packet.ReadSingle();
            pos.Y = packet.ReadSingle();
            pos.Z = packet.ReadSingle();
            ownerGUID[3] = packet.ReadBit();
            var bit40 = !packet.ReadBit();
            ownerGUID[6] = packet.ReadBit();
            var bit45 = !packet.ReadBit();
            var bit6D = !packet.ReadBit();
            var splineType = packet.ReadBits(3);
            var bit78 = !packet.ReadBit();
            ownerGUID[2] = packet.ReadBit();
            ownerGUID[7] = packet.ReadBit();
            ownerGUID[5] = packet.ReadBit();

            if (splineType == 3)
                packet.StartBitStream(factingTargetGUID, 6, 7, 0, 5, 2, 3, 4, 1);

            var bit58 = !packet.ReadBit();
            ownerGUID[4] = packet.ReadBit();
            var waypointCount = packet.ReadBits(22);
            var bit4C = !packet.ReadBit();
            packet.ReadBit(); // fake bit
            ownerGUID[0] = packet.ReadBit();
            guid2[3] = packet.ReadBit();
            guid2[6] = packet.ReadBit();
            guid2[5] = packet.ReadBit();
            guid2[0] = packet.ReadBit();
            guid2[1] = packet.ReadBit();
            guid2[2] = packet.ReadBit();
            guid2[4] = packet.ReadBit();
            guid2[7] = packet.ReadBit();
            var bit6C = !packet.ReadBit();
            var bit54 = !packet.ReadBit();
            var bit48 = !packet.ReadBit();
            var splineCount = (int)packet.ReadBits(20);
            ownerGUID[1] = packet.ReadBit();
            var bitB0 = packet.ReadBit();

            var bits8C = 0u;
            if (bitB0)
            {
                bits8C = packet.ReadBits(22);
                packet.ReadBits("bits9C", 2);
            }

            var bit38 = packet.ReadBit();
            var bit50 = !packet.ReadBit();
            if (splineType == 3)
            {
                packet.ParseBitStream(factingTargetGUID, 5, 3, 6, 1, 4, 2, 0, 7);
                packet.WriteGuid("Facting Target GUID", factingTargetGUID);
            }

            packet.ReadXORByte(ownerGUID, 3);

            packet.ParseBitStream(guid2, 7, 3, 2, 0, 6, 4, 5, 1);

            if (bitB0)
            {
                packet.ReadSingle("FloatA0");

                for (var i = 0; i < bits8C; ++i)
                {
                    packet.ReadInt16("short74+2", i);
                    packet.ReadInt16("short74+0", i);
                }

                packet.ReadSingle("FloatA8");
                packet.ReadInt16("IntA4");
                packet.ReadInt16("IntAC");
            }

            if (bit6D)
                packet.ReadByte("Byte6D");

            if (splineType == 4)
                packet.ReadSingle("Facing Angle");

            if (bit40)
                packet.ReadInt32("Int40");

            packet.ReadXORByte(ownerGUID, 7);
            if (bit78)
                packet.ReadByte("Byte78");
            if (bit4C)
                packet.ReadInt32("Int4C");
            if (bit45)
                packet.ReadByte("Byte45");

            var waypoints = new Vector3[waypointCount];
            for (var i = 0; i < waypointCount; ++i)
            {
                var vec = packet.ReadPackedVector3();
                waypoints[i].X = vec.X;
                waypoints[i].Y = vec.Y;
                waypoints[i].Z = vec.Z;
            }

            packet.ReadXORByte(ownerGUID, 5);
            packet.ReadXORByte(ownerGUID, 1);
            packet.ReadXORByte(ownerGUID, 2);

            if (bit48)
                packet.ReadInt32("Int48");

            Vector3 endpos = new Vector3();
            for (var i = 0; i < splineCount; ++i)
            {
                var spot = new Vector3
                {
                    X = packet.ReadSingle(),
                    Y = packet.ReadSingle(),
                    Z = packet.ReadSingle()
                };
                // client always taking first point
                if (i == 0)
                {
                    endpos = spot;
                }

                packet.AddValue("Spline Waypoint", spot, i);
            }

            packet.ReadXORByte(ownerGUID, 6);

            if (bit50)
                packet.ReadInt32("Int50");

            if (splineType == 2)
            {
                packet.ReadSingle("FloatC0");
                packet.ReadSingle("FloatC4");
                packet.ReadSingle("FloatC8");
            }

            if (bit54)
                packet.ReadSingle("Float54");

            if (bit6C)
                packet.ReadByte("Byte6C");

            packet.ReadXORByte(ownerGUID, 0);

            if (bit58)
                packet.ReadInt32("Int58");

            packet.ReadXORByte(ownerGUID, 4);

            // Calculate mid pos
            var mid = new Vector3();
            mid.X = (pos.X + endpos.X) * 0.5f;
            mid.Y = (pos.Y + endpos.Y) * 0.5f;
            mid.Z = (pos.Z + endpos.Z) * 0.5f;
            for (var i = 0; i < waypointCount; ++i)
            {
                var vec = new Vector3
                {
                    X = mid.X - waypoints[i].X,
                    Y = mid.Y - waypoints[i].Y,
                    Z = mid.Z - waypoints[i].Z
                };
                packet.AddValue("Waypoint", vec, i);
            }

            packet.WriteGuid("Owner GUID", ownerGUID);
            packet.WriteGuid("Guid2", guid2);
        }