private static void ReadSplineMovement422(ref Packet packet, Vector3 pos) { var flags = packet.ReadEnum<SplineFlag422>("Spline Flags", TypeCode.Int32); if (flags.HasAnyFlag(SplineFlag422.AnimationTier)) { packet.ReadEnum<MovementAnimationState>("Animation State", TypeCode.Byte); packet.ReadInt32("Asynctime in ms"); // Async-time in ms } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag422.Trajectory)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Unk Int32 2"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag422.UsePathSmoothing)) { for (var i = 0; i < waypoints; i++) packet.ReadVector3("Waypoint", i); } else { var newpos = packet.ReadVector3("Waypoint Endpoint"); 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; packet.WriteLine("[" + i + "]" + " Waypoint: " + vec); } } }
private static void ReadSplineMovement510(Packet packet, Vector3 pos) { var flags = packet.ReadInt32E<SplineFlag434>("Spline Flags"); if (flags.HasAnyFlag(SplineFlag434.Animation)) { packet.ReadByteE<MovementAnimationState>("Animation State"); packet.ReadInt32("Asynctime in ms"); // Async-time in ms } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag434.Parabolic)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Async-time in ms"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag434.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); } } } } var unkLoopCounter = packet.ReadUInt16("Unk UInt16"); if (unkLoopCounter > 1) { packet.ReadSingle("Unk Float 1"); packet.ReadUInt16("Unk UInt16 1"); packet.ReadUInt16("Unk UInt16 2"); packet.ReadSingle("Unk Float 2"); packet.ReadUInt16("Unk UInt16 3"); for (var i = 0; i < unkLoopCounter; i++) { packet.ReadUInt16("Unk UInt16 1", i); packet.ReadUInt16("Unk UInt16 2", i); } } }
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)) { 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 AnimTierInTrans"); 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_3_4_15595)) { // Not the best way ReadSplineMovement434(ref packet, pos); 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("Async-time in ms"); } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag.Trajectory)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Async-time in ms"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag.Flying | SplineFlag.CatmullRom)) { for (var i = 0; i < waypoints; i++) packet.ReadVector3("Waypoint", i); } else { var newpos = packet.ReadVector3("Waypoint Endpoint"); 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; packet.WriteLine("[" + i + "]" + " Waypoint: " + vec); } } }
public static void HandleMonsterMove(Packet packet) { WowGuid guid = packet.ReadPackedGuid("GUID"); if (Storage.Objects != null && Storage.Objects.ContainsKey(guid)) { WoWObject 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)) { WowGuid transportGuid = packet.ReadPackedGuid("Transport GUID"); int seat = -1; if (ClientVersion.AddedInVersion(ClientVersionBuild.V3_1_0_9767)) // no idea when this was added exactly seat = packet.ReadByte("Transport Seat"); if (transportGuid.HasEntry() && transportGuid.GetHighType() == HighGuidType.Vehicle && guid.HasEntry() && guid.GetHighType() == HighGuidType.Creature) { VehicleTemplateAccessory vehicleAccessory = new VehicleTemplateAccessory { Entry = transportGuid.GetEntry(), AccessoryEntry = guid.GetEntry(), SeatId = seat }; Storage.VehicleTemplateAccessorys.Add(vehicleAccessory, packet.TimeSpan); } } 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; } if (ClientVersion.AddedInVersion(ClientVersionBuild.V5_1_0_16309)) { // Not the best way ReadSplineMovement510(packet, pos); return; } if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_2_2_14545)) { // Not the best way ReadSplineMovement422(packet, pos); return; } var flags = packet.ReadInt32E<SplineFlag>("Spline Flags"); if (flags.HasAnyFlag(SplineFlag.AnimationTier)) { packet.ReadByteE<MovementAnimationState>("Animation State"); packet.ReadInt32("Async-time in ms"); } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag.Trajectory)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Async-time in ms"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag.Flying | SplineFlag.CatmullRom)) { for (var i = 0; i < waypoints; i++) packet.ReadVector3("Waypoint", i); } else { var newpos = packet.ReadVector3("Waypoint Endpoint"); Vector3 mid = (pos + newpos) * 0.5f; for (var i = 1; i < waypoints; i++) { var vec = packet.ReadPackedVector3(); vec = mid - vec; packet.AddValue("Waypoint", vec, i); } } }
private static void ReadSplineMovement422(Packet packet, Vector3 pos) { var flags = packet.ReadInt32E<SplineFlag422>("Spline Flags"); if (flags.HasAnyFlag(SplineFlag422.AnimationTier)) { packet.ReadByteE<MovementAnimationState>("Animation State"); packet.ReadInt32("Asynctime in ms"); // Async-time in ms } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag422.Trajectory)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Unk Int32 2"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag422.UsePathSmoothing)) { 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 }; for (var i = 1; i < waypoints; i++) { var vec = packet.ReadPackedVector3(); vec.X += mid.X; vec.Y += mid.Y; vec.Z += mid.Z; packet.AddValue("Waypoint", vec); } } }
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)); } }
public static void HandleMonsterMove(Packet packet) { 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("Unk Boolean"); // Something to do with IsVehicleExitVoluntary ? 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; } 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 } // Cannot find anything similar to this in 4.2.2 client if (ClientVersion.RemovedInVersion(ClientVersionBuild.V4_2_2_14545)) { 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"); if (flags.HasAnyFlag(SplineFlag.Flying | SplineFlag.CatmullRom)) { packet.ReadVector3("Waypoint", 0); for (var i = 1; i < waypoints; i++) packet.ReadVector3("Waypoint", i); } else { var newpos = packet.ReadVector3("Waypoint Endpoint"); 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; packet.Writer.WriteLine("[" + i + "]" + " Waypoint: " + vec); } } }
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.ReadEnum<SplineFlag434>("Spline Flags", TypeCode.Int32); if (hasAnimationState) packet.ReadEnum<MovementAnimationState>("Animation State", TypeCode.Byte); 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); }
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); }
public static void HandleMonsterMove(Packet packet) { 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 AnimTierInTrans"); 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("Async-time in ms"); } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag.Trajectory)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Async-time in ms"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag.Flying | SplineFlag.CatmullRom)) { for (var i = 0; i < waypoints; i++) packet.ReadVector3("Waypoint", i); } else { var newpos = packet.ReadVector3("Waypoint Endpoint"); 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; packet.WriteLine("[" + i + "]" + " Waypoint: " + vec); } } }
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.ReadEnum<SplineFlag434>("Spline Flags", TypeCode.Int32); 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); }
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); } } } } }
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); }
public static void HandleOnMonsterMove(Packet packet) { var guid3 = new byte[8]; var target = new byte[8]; var pos = new Vector3(); pos.Z = packet.ReadSingle(); // 24 pos.X = packet.ReadSingle(); // 16 packet.ReadInt32("Spline ID"); pos.Y = packet.ReadSingle(); //20 packet.WriteLine("Pos: {0}", pos); var transportPos = new Vector3 { Y = packet.ReadSingle(), // 48 Z = packet.ReadSingle(), // 52 X = packet.ReadSingle(), // 44 }; packet.WriteLine("transportPos: {0}", transportPos); var hasAngle = !packet.ReadBit("!hasAngle"); guid3[0] = packet.ReadBit(); var splineType = packet.ReadBitsE<SplineType>("Spline Type", 3); if (splineType == SplineType.FacingTarget) { target = packet.StartBitStream(6, 4, 3, 0, 5, 7, 1, 2); // 184 } var unk76 = !packet.ReadBit("!unk76"); var unk69 = !packet.ReadBit("!unk69"); var unk120 = -packet.ReadBit("unk120"); var uncompressedSplineCount = packet.ReadBits("uncompressedSplineCount", 20); var hasSplineFlags = !packet.ReadBit("!hasSplineFlags"); guid3[3] = packet.ReadBit(); var unk108 = !packet.ReadBit("!unk108"); var unk88 = !packet.ReadBit("!unk88"); var unk109 = !packet.ReadBit("!unk109"); var hasDutation = !packet.ReadBit("!hasduration"); guid3[7] = packet.ReadBit(); guid3[4] = packet.ReadBit(); var unk72 = !packet.ReadBit("!unk72"); guid3[5] = packet.ReadBit(); var compressedSplineCount = packet.ReadBits("compressedSplineCount", 22); guid3[6] = packet.ReadBit(); var unk112 = packet.ReadBit("!unk112") ? 0u : 1u; var guid2 = packet.StartBitStream(7, 1, 3, 0, 6, 4, 5, 2); // 112 var unk176 = packet.ReadBit("unk176"); var unk78 = 0u; var count140 = 0u; if (unk176) { unk78 = packet.ReadBits("unk78*2", 2); count140 = packet.ReadBits("count140", 22); } var unk56 = packet.ReadBit("unk56"); guid3[2] = packet.ReadBit(); guid3[1] = packet.ReadBit(); for (var i = 0; i < compressedSplineCount; i++) { var vec = packet.ReadPackedVector3(); vec.X += pos.X; vec.Y += pos.Y; vec.Z += pos.Z; packet.WriteLine("[{0}] Waypoint: {1}", i, vec); // not completed } packet.ParseBitStream(guid3, 1); packet.ParseBitStream(guid2, 6, 4, 1, 7, 0, 3, 5, 2); packet.WriteGuid("Guid2", guid2); for (var i = 0; i < uncompressedSplineCount; i++) { var point = new Vector3 { Y = packet.ReadSingle(), // 100 X = packet.ReadSingle(), // 96 Z = packet.ReadSingle(), // 104 }; packet.WriteLine("[{0}] Point: {1}", i, point); } if (unk72) packet.ReadInt32("unk72"); if (splineType == SplineType.FacingTarget) { packet.ParseBitStream(target, 5, 7, 0, 4, 3, 2, 6, 1); packet.WriteGuid("Target", target); } packet.ParseBitStream(guid3, 5); if (hasAngle) packet.ReadSingle("Angle"); if (unk176) { for (var i = 0; i < count140; i++) { packet.ReadInt16("unk146", i); packet.ReadInt16("unk144", i); } packet.ReadSingle("unka8h*4"); packet.ReadInt16("unk82*2"); packet.ReadInt16("unk86*2"); packet.ReadSingle("unka0h*4"); } if (unk76) packet.ReadInt32("unk76"); if (splineType == SplineType.FacingAngle) packet.ReadSingle("Facing Angle"); packet.ParseBitStream(guid3, 3); if (hasSplineFlags) packet.ReadUInt32E<SplineFlag>("Spline Flags"); if (unk69) packet.ReadByte("unk69"); packet.ParseBitStream(guid3, 6); if (unk109) packet.ReadByte("unk109"); if (splineType == SplineType.FacingSpot) { var facingSpot = new Vector3 { X = packet.ReadSingle(), Y = packet.ReadSingle(), Z = packet.ReadSingle(), }; packet.WriteLine("Facing spot: {0}", facingSpot); } packet.ParseBitStream(guid3, 0); if (unk120 != -1) packet.ReadByte("unk120"); if (unk108) packet.ReadByte("unk108"); packet.ParseBitStream(guid3, 7, 2); if (unk88) packet.ReadInt32("unk88"); packet.ParseBitStream(guid3, 4); if (hasDutation) packet.ReadInt32("Spline Duration"); packet.WriteGuid("Unit", guid3); var guidUnit = new WowGuid64(BitConverter.ToUInt64(guid3, 0)); if (!Storage.Objects.IsEmpty() && Storage.Objects.ContainsKey(guidUnit)) { var obj = Storage.Objects[guidUnit].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; } }
private static void ReadSplineMovement434(ref Packet packet, Vector3 pos) { var flags = packet.ReadEnum<SplineFlag434>("Spline Flags", TypeCode.Int32); if (flags.HasAnyFlag(SplineFlag434.Animation)) { packet.ReadEnum<MovementAnimationState>("Animation State", TypeCode.Byte); packet.ReadInt32("Asynctime in ms"); // Async-time in ms } packet.ReadInt32("Move Time"); if (flags.HasAnyFlag(SplineFlag434.Parabolic)) { packet.ReadSingle("Vertical Speed"); packet.ReadInt32("Async-time in ms"); } var waypoints = packet.ReadInt32("Waypoints"); if (flags.HasAnyFlag(SplineFlag434.UncompressedPath)) { for (var i = 0; i < waypoints; i++) packet.ReadVector3("Waypoint", i); } else { var newpos = packet.ReadVector3("Waypoint Endpoint"); 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; if (waypoints != 1) { var vec = packet.ReadPackedVector3(); vec.X += mid.X; vec.Y += mid.Y; vec.Z += mid.Z; packet.WriteLine("[0] Waypoint: " + vec); 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.WriteLine("[" + i + "]" + " Waypoint: " + vec); } } } } }
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.ReadEnum<MovementAnimationState>("Animation State", TypeCode.Byte); 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.ReadEnum<SplineFlag434>("Spline Flags", TypeCode.Int32); 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.WriteLine("[{0}] Waypoint: {1}", i, vec); } packet.WriteGuid("Owner GUID", ownerGUID); packet.WriteGuid("GUID2", guid2); packet.WriteLine("Position: {0}", pos); }
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); } }
public static void HandleMonsterMove(Packet packet) { packet.ReadPackedGuid("GUID"); if (packet.Opcode == Opcodes.GetOpcode(Opcode.SMSG_MONSTER_MOVE_TRANSPORT)) { packet.ReadPackedGuid("Transport GUID"); packet.ReadByte("Transport Seat"); } packet.ReadBoolean("Unk Boolean"); // Something to do with IsVehicleExitVoluntary ? 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; } var flags = packet.ReadEnum<SplineFlag>("Spline Flags", TypeCode.Int32); if (flags.HasAnyFlag(SplineFlag.AnimationTier)) { packet.ReadEnum<MovementAnimationState>("Animation State", TypeCode.Byte); packet.ReadInt32("Unk Int32 1"); } 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 newpos = packet.ReadVector3("Waypoint 0"); if (flags.HasAnyFlag(SplineFlag.Flying) || flags.HasAnyFlag(SplineFlag.CatmullRom)) for (var i = 0; i < waypoints - 1; i++) packet.ReadVector3("Waypoint " + (i + 1)); else { 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 = 0; i < waypoints - 1; i++) { var vec = packet.ReadPackedVector3(); vec.X += mid.X; vec.Y += mid.Y; vec.Z += mid.Z; packet.Writer.WriteLine("Waypoint " + (i + 1) + ": " + vec); } } }