public static void HandlePlayerMove(ref PacketReader packet, WorldClass session) { ObjectMovementValues movementValues = new ObjectMovementValues(); BitUnpack BitUnpack = new BitUnpack(packet); var guidMask = new bool[8]; var guidBytes = new byte[8]; Vector4 vector = new Vector4() { Y = packet.Read <float>(), Z = packet.Read <float>(), X = packet.Read <float>() }; guidMask[3] = BitUnpack.GetBit(); var HasPitch = !BitUnpack.GetBit(); guidMask[0] = BitUnpack.GetBit(); var counter = BitUnpack.GetBits <uint>(22); guidMask[2] = BitUnpack.GetBit(); var HasSplineElevation = !BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); var Unknown = BitUnpack.GetBit(); var Unknown2 = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); var HasTime = !BitUnpack.GetBit(); movementValues.IsFallingOrJumping = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); var Unknown3 = !BitUnpack.GetBit(); var Unknown4 = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); if (movementValues.HasMovementFlags) { movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits <uint>(30); } if (movementValues.IsFallingOrJumping) { movementValues.HasJumpData = BitUnpack.GetBit(); } if (movementValues.HasMovementFlags2) { movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits <uint>(13); } if (guidMask[0]) { guidBytes[0] = (byte)(packet.Read <byte>() ^ 1); } for (int i = 0; i < counter; i++) { packet.Read <uint>(); } if (guidMask[4]) { guidBytes[4] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[1]) { guidBytes[1] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[5]) { guidBytes[5] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[6]) { guidBytes[6] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[2]) { guidBytes[2] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[3]) { guidBytes[3] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[7]) { guidBytes[7] = (byte)(packet.Read <byte>() ^ 1); } if (HasPitch) { packet.Read <float>(); } if (movementValues.HasRotation) { vector.O = packet.Read <float>(); } if (movementValues.IsFallingOrJumping) { movementValues.JumpVelocity = packet.Read <float>(); if (movementValues.HasJumpData) { movementValues.CurrentSpeed = packet.Read <float>(); movementValues.Sin = packet.Read <float>(); movementValues.Cos = packet.Read <float>(); } movementValues.FallTime = packet.Read <uint>(); } if (Unknown3) { packet.Read <uint>(); } if (HasSplineElevation) { packet.Read <float>(); } if (HasTime) { movementValues.Time = packet.Read <uint>(); } var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
public void WriteUpdateObjectMovement(ref PacketWriter packet, ref Character character, UpdateFlag updateFlags) { ObjectMovementValues values = new ObjectMovementValues(updateFlags); BitPack BitPack = new BitPack(packet, character.Guid, character.GuildGuid); BitPack.Write(values.HasTarget); BitPack.Write(values.IsVehicle); BitPack.Write(values.BitCounter, 24); BitPack.Write(values.HasUnknown5); BitPack.Write(values.HasGoTransportPosition); BitPack.Write(values.HasStationaryPosition); BitPack.Write(values.BitCounter2, 21); BitPack.Write(values.HasUnknown); BitPack.Write(values.HasUnknown3); BitPack.Write(values.HasUnknown4); BitPack.Write(values.IsAlive); BitPack.Write(values.Bit1); BitPack.Write(values.HasUnknown2); BitPack.Write(values.Bit2); BitPack.Write(values.HasRotation); BitPack.Write(values.HasAnimKits); BitPack.Write(values.Bit3); BitPack.Write(values.IsSelf); if (values.IsAlive) { BitPack.WriteGuidMask(3); BitPack.Write(0); // HasSplineData, don't write simple basic splineData BitPack.Write(0, 24); // BitCounter_Alive_1 BitPack.WriteGuidMask(4); BitPack.Write(1); // Pitch or splineElevation, not implanted BitPack.Write(values.IsTransport); BitPack.Write(0); // IsInterpolated, not implanted BitPack.Write(!values.IsAlive); if (values.IsTransport) { // Transports not implanted. } BitPack.Write(1); // Unknown_Alive_2, Reversed BitPack.WriteGuidMask(7); BitPack.Write(true); // MovementFlags2 are not implanted BitPack.WriteGuidMask(0); BitPack.Write(0); // Unknown_Alive_1 BitPack.WriteGuidMask(5); /* MovementFlags2 are not implanted * if (movementFlag2 != 0) * BitPack.Write(0, 12);*/ BitPack.WriteGuidMask(2, 6); BitPack.Write(true); // Movementflags are not implanted /* IsInterpolated, not implanted * if (IsInterpolated) * { * BitPack.Write(0); // IsFalling * }*/ /* Movementflags are not implanted * if (movementFlags != 0) * BitPack.Write((uint)movementFlags, 30);*/ BitPack.Write(!values.HasRotation); BitPack.Write(0); // Unknown_Alive_3 BitPack.Write(0); // Unknown_Alive_4 // Don't send basic spline data and disable advanced data //if (HasSplineData) { //BitPack.Write(0); // Disable advance splineData } BitPack.WriteGuidMask(1); BitPack.Write(1); // Pitch or splineElevation, not implanted } BitPack.Flush(); if (values.IsAlive) { // Don't send basic spline data /*if (HasSplineBasicData) * { * // Advanced spline data not implanted * if (HasAdvancedSplineData) * { * * } * * packet.WriteFloat(character.X); * packet.WriteFloat(character.Y); * packet.WriteUInt32(0); * packet.WriteFloat(character.Z); * }*/ packet.WriteFloat((float)MovementSpeed.WalkSpeed); if (values.IsTransport) { // Not implanted } BitPack.WriteGuidBytes(2); BitPack.WriteGuidBytes(7); packet.WriteUInt32(0); packet.WriteFloat((float)MovementSpeed.FlyBackSpeed); packet.WriteFloat(character.X); packet.WriteFloat(character.Y); BitPack.WriteGuidBytes(5); packet.WriteFloat(character.Z); BitPack.WriteGuidBytes(3, 6, 1); packet.WriteFloat((float)MovementSpeed.FlySpeed); packet.WriteFloat((float)MovementSpeed.PitchSpeed); packet.WriteFloat((float)MovementSpeed.RunSpeed); packet.WriteFloat(character.O); BitPack.WriteGuidBytes(4); packet.WriteFloat((float)MovementSpeed.SwimSpeed); packet.WriteFloat((float)MovementSpeed.RunBackSpeed); packet.WriteFloat((float)MovementSpeed.TurnSpeed); packet.WriteFloat((float)MovementSpeed.SwimBackSpeed); BitPack.WriteGuidBytes(0); } if (values.HasRotation) { // Packed orientation packet.WriteUInt64(0); } }
public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector) { PacketWriter moveUpdate = new PacketWriter(ServerMessage.MoveUpdate); BitPack BitPack = new BitPack(moveUpdate, guid); BitPack.WriteGuidMask(0); BitPack.Write(!movementValues.HasRotation); BitPack.Write(!movementValues.HasMovementFlags2); BitPack.WriteGuidMask(5); if (movementValues.HasMovementFlags2) { BitPack.Write((uint)movementValues.MovementFlags2, 13); } BitPack.Write(!movementValues.HasMovementFlags); BitPack.Write(0); BitPack.Write <uint>(0, 22); BitPack.Write(1); BitPack.Write(1); BitPack.Write(0); BitPack.Write(0); BitPack.WriteGuidMask(7); BitPack.Write(movementValues.IsTransport); BitPack.Write(1); BitPack.WriteGuidMask(4, 1); BitPack.Write(movementValues.IsFallingOrJumping); if (movementValues.HasMovementFlags) { BitPack.Write((uint)movementValues.MovementFlags, 30); } BitPack.Write(movementValues.Time == 0); if (movementValues.IsFallingOrJumping) { BitPack.Write(movementValues.HasJumpData); } BitPack.WriteGuidMask(2, 3, 6); BitPack.Flush(); BitPack.WriteGuidBytes(6); if (movementValues.Time != 0) { moveUpdate.WriteUInt32(movementValues.Time); } if (movementValues.IsFallingOrJumping) { moveUpdate.WriteFloat(movementValues.JumpVelocity); if (movementValues.HasJumpData) { moveUpdate.WriteFloat(movementValues.Cos); moveUpdate.WriteFloat(movementValues.CurrentSpeed); moveUpdate.WriteFloat(movementValues.Sin); } moveUpdate.WriteUInt32(movementValues.FallTime); } moveUpdate.WriteFloat(vector.X); BitPack.WriteGuidBytes(1); moveUpdate.WriteFloat(vector.Y); BitPack.WriteGuidBytes(2, 7, 5); moveUpdate.WriteFloat(vector.Z); BitPack.WriteGuidBytes(0, 4, 3); if (movementValues.HasRotation) { moveUpdate.WriteFloat(vector.O); } var session = WorldMgr.GetSession(guid); if (session != null) { Character pChar = session.Character; ObjectMgr.SetPosition(ref pChar, vector, false); WorldMgr.SendToInRangeCharacter(pChar, moveUpdate); } }
public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector) { PacketWriter moveUpdate = new PacketWriter(ServerMessage.MoveUpdate); BitPack BitPack = new BitPack(moveUpdate, guid); BitPack.WriteGuidMask(2); BitPack.Write(0); BitPack.WriteGuidMask(1); BitPack.Write(!movementValues.HasMovementFlags2); BitPack.Write(true); BitPack.Write(true); BitPack.Write <uint>(0, 22); BitPack.WriteGuidMask(3); BitPack.Write(!movementValues.IsAlive); BitPack.Write(!movementValues.HasMovementFlags); BitPack.WriteGuidMask(6); if (movementValues.HasMovementFlags2) { BitPack.Write((uint)movementValues.MovementFlags2, 13); } BitPack.WriteGuidMask(4, 7); BitPack.Write(movementValues.IsInterpolated); BitPack.Write(0); if (movementValues.HasMovementFlags) { BitPack.Write((uint)movementValues.MovementFlags, 30); } BitPack.Write(!movementValues.HasRotation); BitPack.Write(movementValues.IsTransport); BitPack.WriteGuidMask(5); if (movementValues.IsInterpolated) { BitPack.Write(movementValues.IsInterpolated2); } BitPack.Write(true); BitPack.Write(0); BitPack.WriteGuidMask(0); BitPack.Flush(); moveUpdate.WriteFloat(vector.Z); BitPack.WriteGuidBytes(3); moveUpdate.WriteFloat(vector.X); BitPack.WriteGuidBytes(0, 7); moveUpdate.WriteFloat(vector.Y); BitPack.WriteGuidBytes(5); if (movementValues.IsInterpolated) { moveUpdate.WriteFloat(0); if (movementValues.IsInterpolated2) { moveUpdate.WriteFloat(0); moveUpdate.WriteFloat(0); moveUpdate.WriteFloat(0); } moveUpdate.WriteUInt32(0); } BitPack.WriteGuidBytes(6, 2); if (movementValues.IsAlive) { moveUpdate.WriteUInt32(movementValues.Time); } BitPack.WriteGuidBytes(1, 4); if (movementValues.HasRotation) { moveUpdate.WriteFloat(vector.O); } var session = WorldMgr.GetSession(guid); if (session != null) { Character pChar = session.Character; ObjectMgr.SetPosition(ref pChar, vector, false); WorldMgr.SendToInRangeCharacter(pChar, moveUpdate); } }
public static void HandleMove(ref PacketReader packet, ref WorldClass session) { ObjectMovementValues movementValues = new ObjectMovementValues(); BitUnpack BitUnpack = new BitUnpack(packet); bool[] guidMask = new bool[8]; byte[] guidBytes = new byte[8]; Vector4 vector = new Vector4() { X = packet.Read <float>(), Y = packet.Read <float>(), Z = packet.Read <float>() }; guidMask[0] = BitUnpack.GetBit(); guidMask[3] = BitUnpack.GetBit(); bool HasPitch = !BitUnpack.GetBit(); guidMask[2] = BitUnpack.GetBit(); bool HasSplineElevation = !BitUnpack.GetBit(); bool Unknown = BitUnpack.GetBit(); bool Unknown2 = BitUnpack.GetBit(); guidMask[6] = BitUnpack.GetBit(); guidMask[7] = BitUnpack.GetBit(); guidMask[5] = BitUnpack.GetBit(); movementValues.HasMovementFlags = !BitUnpack.GetBit(); movementValues.HasRotation = !BitUnpack.GetBit(); bool Unknown3 = BitUnpack.GetBit(); movementValues.HasMovementFlags2 = !BitUnpack.GetBit(); movementValues.IsAlive = !BitUnpack.GetBit(); guidMask[1] = BitUnpack.GetBit(); movementValues.IsTransport = BitUnpack.GetBit(); guidMask[4] = BitUnpack.GetBit(); movementValues.IsInterpolated = BitUnpack.GetBit(); bool HasTime = !BitUnpack.GetBit(); uint counter = BitUnpack.GetBits <uint>(22); if (movementValues.IsInterpolated) { movementValues.IsInterpolated2 = BitUnpack.GetBit(); } if (movementValues.HasMovementFlags) { movementValues.MovementFlags = (MovementFlag)BitUnpack.GetBits <uint>(30); } if (movementValues.HasMovementFlags2) { movementValues.MovementFlags2 = (MovementFlag2)BitUnpack.GetBits <uint>(13); } if (guidMask[0]) { guidBytes[0] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[2]) { guidBytes[2] = (byte)(packet.Read <byte>() ^ 1); } for (int i = 0; i < counter; i++) { packet.Read <uint>(); } if (guidMask[7]) { guidBytes[7] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[6]) { guidBytes[6] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[1]) { guidBytes[1] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[4]) { guidBytes[4] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[3]) { guidBytes[3] = (byte)(packet.Read <byte>() ^ 1); } if (guidMask[5]) { guidBytes[5] = (byte)(packet.Read <byte>() ^ 1); } if (HasSplineElevation) { packet.Read <float>(); } /*if (movementValues.IsTransport) * { * * }*/ if (movementValues.IsInterpolated) { if (movementValues.IsInterpolated2) { packet.Read <float>(); packet.Read <float>(); packet.Read <float>(); } packet.Read <uint>(); packet.Read <float>(); } if (HasPitch) { packet.Read <float>(); } if (movementValues.IsAlive) { movementValues.Time = packet.Read <uint>(); } if (movementValues.HasRotation) { vector.O = packet.Read <float>(); } if (HasTime) { movementValues.Time = packet.Read <uint>(); } var guid = BitConverter.ToUInt64(guidBytes, 0); HandleMoveUpdate(guid, movementValues, vector); }
public void WriteUpdateObjectMovement(ref PacketWriter packet, ref WorldObject wObject, UpdateFlag updateFlags) { ObjectMovementValues values = new ObjectMovementValues(updateFlags); BitPack BitPack = new BitPack(packet, wObject.Guid); BitPack.Write(0); BitPack.Write(values.IsVehicle); BitPack.Write(0); BitPack.Write(wObject is GameObjectSpawn); BitPack.Write(0); BitPack.Write(values.IsAlive); BitPack.Write(values.IsSceneObject); BitPack.Write(0); BitPack.Write(values.IsAreaTrigger); BitPack.Write(values.IsSelf); BitPack.Write(0); BitPack.Write(0); BitPack.Write(values.HasGoTransportPosition); BitPack.Write(values.IsTransport); BitPack.Write(values.HasAnimKits); BitPack.Write(values.HasStationaryPosition); BitPack.Write(values.HasTarget); BitPack.Write(0); BitPack.Write(0, 22); BitPack.Write(0); BitPack.Write(0); if (values.IsAlive) { BitPack.Write(values.IsTransport); BitPack.Write(1); BitPack.Write(0); BitPack.Write(0, 19); BitPack.WriteGuidMask(1); BitPack.Write(!values.HasMovementFlags2); BitPack.Write(0); BitPack.Write(1); if (values.HasMovementFlags2) { BitPack.Write(values.MovementFlags2, 13); } BitPack.Write(!values.HasRotation); BitPack.Write(0); BitPack.Write(!values.HasMovementFlags); BitPack.Write(1); BitPack.WriteGuidMask(2, 6); BitPack.Write(values.IsFallingOrJumping); BitPack.WriteGuidMask(5, 4, 0); if (values.HasMovementFlags) { BitPack.Write(values.MovementFlags, 30); } BitPack.Write(0); if (values.IsFallingOrJumping) { BitPack.Write(values.HasJumpData); } BitPack.Write(0, 22); BitPack.WriteGuidMask(7); BitPack.Write(0); BitPack.WriteGuidMask(3); } BitPack.Flush(); if (values.IsAlive) { if (values.IsFallingOrJumping) { if (values.HasJumpData) { packet.WriteFloat(values.CurrentSpeed); packet.WriteFloat(values.Sin); packet.WriteFloat(values.Cos); } packet.WriteFloat(values.JumpVelocity); packet.WriteUInt32(values.FallTime); } packet.WriteFloat(wObject.Position.Z); packet.WriteFloat(wObject.Position.Y); packet.WriteFloat(MovementSpeed.FlySpeed); BitPack.WriteGuidBytes(6); packet.WriteFloat(MovementSpeed.FlyBackSpeed); packet.WriteFloat(wObject.Position.X); BitPack.WriteGuidBytes(2); packet.WriteFloat(MovementSpeed.SwimBackSpeed); BitPack.WriteGuidBytes(1); packet.WriteFloat(MovementSpeed.RunBackSpeed); packet.WriteFloat(MovementSpeed.SwimSpeed); BitPack.WriteGuidBytes(5); packet.WriteFloat(MovementSpeed.TurnSpeed); BitPack.WriteGuidBytes(3); packet.WriteFloat(MovementSpeed.RunSpeed); BitPack.WriteGuidBytes(7); packet.WriteFloat(MovementSpeed.WalkSpeed); packet.WriteFloat(MovementSpeed.PitchSpeed); packet.WritePackedTime(); BitPack.WriteGuidBytes(4, 0); if (values.HasRotation) { packet.WriteFloat(wObject.Position.O); } } if (values.HasStationaryPosition) { packet.WriteFloat(wObject.Position.O); packet.WriteFloat(wObject.Position.X); packet.WriteFloat(wObject.Position.Y); packet.WriteFloat(wObject.Position.Z); } if (wObject is GameObjectSpawn) { packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O)); } }
public void WriteUpdateObjectMovement(ref PacketWriter packet, ref WorldObject wObject, UpdateFlag updateFlags) { ObjectMovementValues values = new ObjectMovementValues(updateFlags); BitPack BitPack = new BitPack(packet, wObject.Guid); BitPack.Write(values.HasTarget); BitPack.Write(values.Bit1); BitPack.Write(values.HasUnknown2); BitPack.Write(0); // New in 5.1.0, 784, Unknown BitPack.Write(values.Bit0); BitPack.Write(values.Bit3); BitPack.Write(0); // New in 5.1.0, 654, Unknown BitPack.Write(values.IsSelf); BitPack.Write(values.HasGoTransportPosition); BitPack.Write(values.HasUnknown); BitPack.Write(wObject is GameObjectSpawn); BitPack.Write(values.IsAlive); BitPack.Write(values.HasUnknown4); BitPack.Write(values.HasAnimKits); BitPack.Write(values.HasUnknown3); BitPack.Write(values.IsVehicle); BitPack.Write(values.HasStationaryPosition); BitPack.Write(values.Bit2); BitPack.Write(values.BitCounter, 22); if (values.IsAlive) { BitPack.WriteGuidMask(7); BitPack.Write(0, 19); // BitCounter_Alive_1 BitPack.Write(0); // IsInterpolated, not implanted BitPack.Write(values.IsTransport); BitPack.Write(0); // Unknown_Alive_1 BitPack.WriteGuidMask(0); BitPack.Write(1); // splineElevation, not implanted BitPack.Write(true); // Movementflags are not implanted BitPack.Write(0); // HasSplineData, don't write simple basic splineData BitPack.WriteGuidMask(1); BitPack.Write(true); // MovementFlags2 are not implanted BitPack.Write(0, 22); // BitCounter_Alive_2 BitPack.WriteGuidMask(3, 5, 6); BitPack.Write(0); // Unknown_Alive_3 BitPack.Write(!values.HasRotation); BitPack.Write(1); // Pitch, not implanted BitPack.Write(1); // Unknown_Alive_2, Reversed BitPack.WriteGuidMask(2); BitPack.Write(!values.IsAlive); BitPack.Write(0); // Unknown_Alive_4 BitPack.WriteGuidMask(4); } BitPack.Flush(); if (values.IsAlive) { BitPack.WriteGuidBytes(5); packet.WriteFloat((float)MovementSpeed.SwimSpeed); packet.WriteFloat((float)MovementSpeed.WalkSpeed); BitPack.WriteGuidBytes(6); packet.WriteFloat((float)MovementSpeed.RunSpeed); BitPack.WriteGuidBytes(0); packet.WriteFloat(wObject.Position.Z); packet.WriteFloat((float)MovementSpeed.FlySpeed); packet.WriteFloat(wObject.Position.Y); packet.WriteFloat(wObject.Position.X); BitPack.WriteGuidBytes(4, 3); packet.WriteFloat((float)MovementSpeed.TurnSpeed); BitPack.WriteGuidBytes(2); packet.WriteUInt32(0); packet.WriteFloat(wObject.Position.O); packet.WriteFloat((float)MovementSpeed.FlyBackSpeed); packet.WriteFloat((float)MovementSpeed.SwimBackSpeed); packet.WriteFloat((float)MovementSpeed.RunBackSpeed); packet.WriteFloat((float)MovementSpeed.PitchSpeed); BitPack.WriteGuidBytes(1, 7); } if (values.HasStationaryPosition) { packet.WriteFloat(wObject.Position.Z); packet.WriteFloat(wObject.Position.O); packet.WriteFloat(wObject.Position.Y); packet.WriteFloat(wObject.Position.X); } if (wObject is GameObjectSpawn) { packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O)); } }
public void WriteUpdateObjectMovement(ref PacketWriter packet, ref WorldObject wObject, UpdateFlag updateFlags) { ObjectMovementValues values = new ObjectMovementValues(updateFlags); BitPack BitPack = new BitPack(packet, wObject.Guid); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.Write(values.IsSelf); BitPack.Write(0); BitPack.Write(values.HasTarget); BitPack.Write(0, 22); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.Write(0); BitPack.Write(values.HasStationaryPosition); BitPack.Write(0); BitPack.Write(values.IsAlive); BitPack.Write(values.HasAnimKits); BitPack.Write(values.IsVehicle); BitPack.Write(values.HasGoTransportPosition); BitPack.Write(0); BitPack.Write(wObject is GameObjectSpawn); if (values.IsAlive) { BitPack.WriteGuidMask(4, 1); BitPack.Write(0, 19); BitPack.WriteGuidMask(5); BitPack.Write(!values.HasRotation); BitPack.WriteGuidMask(7); BitPack.Write(0, 22); BitPack.Write(0); BitPack.Write(1); BitPack.Write(1); BitPack.WriteGuidMask(3); BitPack.Write(0); BitPack.Write(1); BitPack.Write(0); BitPack.Write(0); BitPack.WriteGuidMask(2); BitPack.Write(0); BitPack.WriteGuidMask(0); BitPack.Write(values.IsTransport); BitPack.WriteGuidMask(6); BitPack.Write(0); BitPack.Write(1); BitPack.Write(1); } BitPack.Flush(); if (values.IsAlive) { packet.WriteFloat(wObject.Position.Y); packet.WriteFloat(MovementSpeed.FlySpeed); packet.WriteFloat(MovementSpeed.RunSpeed); BitPack.WriteGuidBytes(4); packet.WriteFloat(MovementSpeed.WalkSpeed); BitPack.WriteGuidBytes(5); packet.WriteUInt32(0); BitPack.WriteGuidBytes(1); packet.WriteFloat(MovementSpeed.SwimBackSpeed); packet.WriteFloat(MovementSpeed.FlyBackSpeed); BitPack.WriteGuidBytes(6); packet.WriteFloat(MovementSpeed.TurnSpeed); packet.WriteFloat(wObject.Position.X); packet.WriteFloat(wObject.Position.O); packet.WriteFloat(MovementSpeed.PitchSpeed); packet.WriteFloat(MovementSpeed.SwimSpeed); BitPack.WriteGuidBytes(3); packet.WriteFloat(MovementSpeed.RunBackSpeed); BitPack.WriteGuidBytes(7, 2); packet.WriteFloat(wObject.Position.Z); BitPack.WriteGuidBytes(0); } if (values.HasStationaryPosition) { packet.WriteFloat(wObject.Position.X); packet.WriteFloat(wObject.Position.Z); packet.WriteFloat(wObject.Position.Y); packet.WriteFloat(wObject.Position.O); } if (wObject is GameObjectSpawn) { packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O)); } }
public void WriteUpdateObjectMovement(ref PacketWriter packet, ref WorldObject wObject, UpdateFlag updateFlags) { ObjectMovementValues values = new ObjectMovementValues(updateFlags); BitPack BitPack = new BitPack(packet, wObject.Guid); BitPack.Write(0); // Unknown 4 BitPack.Write(0, 22); // BitCounter BitPack.Write(values.IsVehicle); BitPack.Write(0); // Unknown 8 BitPack.Write(values.HasGoTransportPosition); BitPack.Write(0); // Bit 3 BitPack.Write(0); // Unknown 6 BitPack.Write(0); // Unknown BitPack.Write(0); // Unknown 3 BitPack.Write(0); // Unknown 2 BitPack.Write(wObject is GameObjectSpawn); BitPack.Write(values.HasTarget); BitPack.Write(0); // Bit 2 BitPack.Write(0); // Bit 0 BitPack.Write(values.IsSelf); BitPack.Write(0); // Bit 1 BitPack.Write(values.IsAlive); BitPack.Write(0); // Unknown 7 BitPack.Write(0); // Unknown 5 BitPack.Write(values.HasAnimKits); BitPack.Write(values.HasStationaryPosition); if (values.IsAlive) { BitPack.WriteGuidMask(0); BitPack.Write(1); // !Pitch or !SplineElevation BitPack.WriteGuidMask(4, 7); BitPack.Write(1); // !MovementFlags2 BitPack.WriteGuidMask(5, 2); BitPack.Write(0); // HasBasicSplineData BitPack.Write(1); // !MovementFlags BitPack.Write(0); // !HasTime BitPack.Write(0); // Unknown_Alive_2 BitPack.Write(0); // Unknown_Alive_1 BitPack.Write(!values.HasRotation); BitPack.Write(values.IsTransport); BitPack.Write(1); // Pitch or SplineElevation BitPack.WriteGuidMask(6); BitPack.Write(0, 19); // BitCounter_Alive_1 BitPack.WriteGuidMask(1); BitPack.Write(1); // !Unknown_Alive_3 BitPack.WriteGuidMask(3); BitPack.Write(0, 22); // BitCounter_Alive_2 BitPack.Write(0); // IsFallingOrJumping BitPack.Write(0); // Unknown_Alive_4 } BitPack.Flush(); if (values.IsAlive) { packet.WriteUInt32(0); BitPack.WriteGuidBytes(2, 1); packet.WriteFloat((float)MovementSpeed.WalkSpeed); packet.WriteFloat((float)MovementSpeed.RunSpeed); BitPack.WriteGuidBytes(0, 3); packet.WriteFloat((float)MovementSpeed.SwimBackSpeed); packet.WriteFloat((float)MovementSpeed.TurnSpeed); BitPack.WriteGuidBytes(5); packet.WriteFloat(wObject.Position.Z); packet.WriteFloat(wObject.Position.O); BitPack.WriteGuidBytes(6); packet.WriteFloat((float)MovementSpeed.PitchSpeed); packet.WriteFloat((float)MovementSpeed.RunBackSpeed); packet.WriteFloat(wObject.Position.Y); packet.WriteFloat((float)MovementSpeed.SwimSpeed); packet.WriteFloat((float)MovementSpeed.FlyBackSpeed); BitPack.WriteGuidBytes(7); packet.WriteFloat((float)MovementSpeed.FlySpeed); packet.WriteFloat(wObject.Position.X); BitPack.WriteGuidBytes(4); } if (wObject is GameObjectSpawn) { packet.WriteInt64(Quaternion.GetCompressed(wObject.Position.O)); } if (values.HasStationaryPosition) { packet.WriteFloat(wObject.Position.X); packet.WriteFloat(wObject.Position.Z); packet.WriteFloat(wObject.Position.O); packet.WriteFloat(wObject.Position.Y); } }
public static void HandleMoveUpdate(ulong guid, ObjectMovementValues movementValues, Vector4 vector) { PacketWriter moveUpdate = new PacketWriter(JAMCMessage.MoveUpdate); BitPack BitPack = new BitPack(moveUpdate, guid); BitPack.WriteGuidMask(0); BitPack.Write(!movementValues.HasMovementFlags); BitPack.Write(!movementValues.HasRotation); BitPack.WriteGuidMask(2, 6); BitPack.Write(!movementValues.HasMovementFlags2); BitPack.WriteGuidMask(7); BitPack.Write <uint>(0, 24); BitPack.WriteGuidMask(1); if (movementValues.HasMovementFlags) { BitPack.Write((uint)movementValues.MovementFlags, 30); } BitPack.WriteGuidMask(4); BitPack.Write(!movementValues.IsAlive); BitPack.Write(0); if (movementValues.HasMovementFlags2) { BitPack.Write((uint)movementValues.MovementFlags2, 13); } BitPack.Write(0); BitPack.WriteGuidMask(5); BitPack.Write(true); BitPack.Write(0); BitPack.Write(movementValues.IsInterpolated); BitPack.Write(0); BitPack.Write(true); BitPack.WriteGuidMask(3); BitPack.Write(true); if (movementValues.IsInterpolated) { BitPack.Write(movementValues.IsInterpolated2); } BitPack.Flush(); if (movementValues.IsInterpolated) { moveUpdate.WriteUInt32(0); if (movementValues.IsInterpolated2) { moveUpdate.WriteFloat(0); moveUpdate.WriteFloat(0); moveUpdate.WriteFloat(0); } moveUpdate.WriteFloat(0); } if (movementValues.IsAlive) { moveUpdate.WriteUInt32(movementValues.Time); } BitPack.WriteGuidBytes(5, 7); moveUpdate.WriteFloat(vector.Z); BitPack.WriteGuidBytes(4, 3, 2, 6, 0); moveUpdate.WriteFloat(vector.X); if (movementValues.HasRotation) { moveUpdate.WriteFloat(vector.W); } moveUpdate.WriteFloat(vector.Y); Character pChar = WorldMgr.GetSession(guid).Character; ObjectMgr.SetPosition(ref pChar, vector, false); WorldMgr.SendToAllInZone(guid, moveUpdate); }