From 6201cc7a3b361cfe938bb49fc99d47296a413325 Mon Sep 17 00:00:00 2001 From: Linewalker Date: Thu, 7 Jul 2022 23:41:57 +0200 Subject: [PATCH] Code cleanup Some code changes and cleanup --- Config/Settings.cs | 57 ++ GTAVCSMM.csproj | 13 +- {Memory => Helpers}/Mem.cs | 395 +++++++------ Math/Library.cs | 58 -- Math/Math2.cs | 65 --- Math/Math3.cs | 335 ----------- Math/MathF.cs | 211 ------- Math/Matrix3x4.cs | 125 ---- Math/Matrix4x4.cs | 816 -------------------------- Math/Vector2.cs | 869 ---------------------------- Math/Vector3.cs | 1114 ----------------------------------- Program.cs | 1117 +++++++++++++++++------------------- Settings/Addresses.cs | 85 --- Settings/TSettings.cs | 660 --------------------- 14 files changed, 786 insertions(+), 5134 deletions(-) create mode 100644 Config/Settings.cs rename {Memory => Helpers}/Mem.cs (97%) delete mode 100644 Math/Library.cs delete mode 100644 Math/Math2.cs delete mode 100644 Math/Math3.cs delete mode 100644 Math/MathF.cs delete mode 100644 Math/Matrix3x4.cs delete mode 100644 Math/Matrix4x4.cs delete mode 100644 Math/Vector2.cs delete mode 100644 Math/Vector3.cs delete mode 100644 Settings/Addresses.cs delete mode 100644 Settings/TSettings.cs diff --git a/Config/Settings.cs b/Config/Settings.cs new file mode 100644 index 0000000..5238ae3 --- /dev/null +++ b/Config/Settings.cs @@ -0,0 +1,57 @@ +namespace GTAVCSMM.Config +{ + public class Settings + { + #region Globals + public static string gameName = "GTA5"; + public static int gameProcess = 0; + public static long GlobalPTR; + public static long WorldPTR; + public static long BlipPTR; + public static long ReplayInterfacePTR; + public static long LocalScriptsPTR; + public static long PlayerCountPTR; + public static long PickupDataPTR; + public static long WeatherADDR; + public static long SettingsPTR; + public static long AimCPedPTR; + public static long FriendlistPTR; + #endregion + + #region Trainer settings + public static int aConnect = 0; + public static int aFKtoggle = 0; + public static int aGodMode = 0; + public static int aLogPlayers = 0; + public static int aDarkMode = 0; + public static int player_tracking = 0; + public static int pictureGrabOFF = 0; + public static int markMyRid = -1; + public static int myCPed = -1; + + public static bool GlobalPTRFound = false; + public static bool WorldPTRFound = false; + public static bool BlipPTRFound = false; + public static bool ReplayInterfacePTRFound = false; + public static bool LocalScriptsPTRFound = false; + public static bool PlayerCountPTRFound = false; + public static bool PickupDataPTRFound = false; + public static bool WeatherADDRFound = false; + public static bool SettingsPTRFound = false; + public static bool AimCPedPTRFound = false; + public static bool FriendlistPTRFound = false; + #endregion + + public static bool pgodm = false; + public static bool pnwanted = false; + public static bool pnragdoll = false; + public static bool puoffradar = false; + public static bool psbelt = false; + public static bool psjump = false; + public static bool psexammo = false; + public static bool pdiscol = false; + public static bool vgodm = false; + public static bool cKiller = false; + + } +} diff --git a/GTAVCSMM.csproj b/GTAVCSMM.csproj index c0f4cc2..e386d3f 100644 --- a/GTAVCSMM.csproj +++ b/GTAVCSMM.csproj @@ -65,19 +65,10 @@ - - - - - - - - - + - - + ResXFileCodeGenerator Resources.Designer.cs diff --git a/Memory/Mem.cs b/Helpers/Mem.cs similarity index 97% rename from Memory/Mem.cs rename to Helpers/Mem.cs index 88d026a..6f2d0fc 100644 --- a/Memory/Mem.cs +++ b/Helpers/Mem.cs @@ -1,199 +1,198 @@ -using System; -using System.Diagnostics; -using System.Runtime.InteropServices; -using System.Text; - -namespace GTAVCSMM.Memory -{ - class Mem - { - [DllImport("ntdll.dll")] - public static extern int NtWriteVirtualMemory(IntPtr ProcessHandle, long BaseAddress, byte[] Buffer, int Size, int BytesWritten = 0); - - [DllImport("ntdll.dll")] - public static extern int NtReadVirtualMemory(IntPtr ProcessHandle, long Address, byte[] buffer, int Size, int BytesRead = 0); - - public Process Proc; - public long BaseAddress; - - public Mem(string process) - { - try - { - Proc = Process.GetProcessesByName(process)[0]; - BaseAddress = Proc.MainModule.BaseAddress.ToInt64(); - } - catch { throw new Exception(); } - } - - public IntPtr GetProcHandle() - { - try { return Proc.Handle; } catch { return IntPtr.Zero; } - } - - public long GetPtrAddr(long Pointer, int[] Offset = null) - { - byte[] Buffer = new byte[8]; - - NtReadVirtualMemory(GetProcHandle(), Pointer, Buffer, Buffer.Length); - - if (Offset != null) - { - for (int x = 0; x < (Offset.Length - 1); x++) - { - Pointer = BitConverter.ToInt64(Buffer, 0) + Offset[x]; - NtReadVirtualMemory(GetProcHandle(), Pointer, Buffer, Buffer.Length); - } - - Pointer = BitConverter.ToInt64(Buffer, 0) + Offset[Offset.Length - 1]; - } - - return Pointer; - } - - public long FindPattern(byte[] pattern, string mask) - { - int moduleSize = Proc.MainModule.ModuleMemorySize; - - if (moduleSize == 0) throw new Exception($"Size of module {Proc.MainModule.ModuleName} is INVALID."); - - byte[] moduleBytes = new byte[moduleSize]; - NtReadVirtualMemory(GetProcHandle(), BaseAddress, moduleBytes, moduleSize); - - for (long i = 0; i < moduleSize; i++) - { - for (int l = 0; l < mask.Length; l++) - //dirty hack heh - if (!(mask[l] == '?' || moduleBytes[l + i] == pattern[l])) goto SKIP; - - return i; - SKIP:; - } - return 0; - } - - public byte[] ReadBytes(long BasePTR, int[] offset, int Length) - { - byte[] Buffer = new byte[Length]; - NtReadVirtualMemory(GetProcHandle(), GetPtrAddr(BaseAddress + BasePTR, offset), Buffer, Length); - return Buffer; - } - - public byte[] ReadBytes_new(long BasePTR, int[] offset, int Length) - { - byte[] Buffer = new byte[Length]; - NtReadVirtualMemory(GetProcHandle(), BasePTR, Buffer, Length); - return Buffer; - } - - public void Write(long BasePTR, int[] offset, byte[] Bytes) => NtWriteVirtualMemory(GetProcHandle(), GetPtrAddr(BaseAddress + BasePTR, offset), Bytes, Bytes.Length); - - public void Write(long BasePTR, int[] offset, bool b) => Write(BasePTR, offset, b ? new byte[] { 0x01 } : new byte[] { 0x00 }); - public void Write(long BasePTR, int[] offset, float Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); - public void Write(long BasePTR, int[] offset, double Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); - public void Write(long BasePTR, int[] offset, int Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); - public void Write(long BasePTR, int[] offset, string String) => Write(BasePTR, offset, new ASCIIEncoding().GetBytes(String)); - public void Write(long BasePTR, int[] offset, long Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); - public void Write(long BasePTR, int[] offset, uint Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); - public void Write(long BasePTR, int[] offset, byte Value) => Write(BasePTR, offset, new byte[] { Value }); - - public void writeInt(long BasePTR, int[] offset, int Value) - { - NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 4); - } - public void writeUInt(long BasePTR, int[] offset, uint Value) - { - NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 4); - } - public void writePointer(long BasePTR, int[] offset, long Value) - { - NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 8); - } - public void writeFloat(long BasePTR, int[] offset, float Value) - { - NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 8); - } - - public bool ReadBool(long BasePTR, int[] offset) => ReadByte(BasePTR, offset) != 0x00; - public float ReadFloat(long BasePTR, int[] offset) => BitConverter.ToSingle(ReadBytes(BasePTR, offset, 4), 0); - public double ReadDouble(long BasePTR, int[] offset) => BitConverter.ToDouble(ReadBytes(BasePTR, offset, 8), 0); - public int ReadInt(long BasePTR, int[] offset) => BitConverter.ToInt32(ReadBytes(BasePTR, offset, 4), 0); - public uint ReadUInt(long BasePTR, int[] offset) => BitConverter.ToUInt32(ReadBytes(BasePTR, offset, 4), 0); - public string ReadString(long BasePTR, int[] offset, int size) => new ASCIIEncoding().GetString(ReadBytes(BasePTR, offset, size)); - public long ReadPointer(long BasePTR, int[] offset) => BitConverter.ToInt64(ReadBytes(BasePTR, offset, 8), 0); - public byte ReadByte(long BasePTR, int[] offset) => ReadBytes(BasePTR, offset, 1)[0]; - public string ReadStr(long BasePTR, int[] offset, int size) => new ASCIIEncoding().GetString(ReadBytes_new(BasePTR, offset, size)); - - public T Read(long basePtr, int[] offsets) where T : struct - { - byte[] buffer = new byte[Marshal.SizeOf(typeof(T))]; - NtReadVirtualMemory(GetProcHandle(), GetPtrAddr(basePtr, offsets), buffer, buffer.Length); - return ByteArrayToStructure(buffer); - } - - public T Read(long address) where T : struct - { - byte[] buffer = new byte[Marshal.SizeOf(typeof(T))]; - NtReadVirtualMemory(GetProcHandle(), address, buffer, buffer.Length); - return ByteArrayToStructure(buffer); - } - - public void Write(long basePtr, int[] offsets, T value) where T : struct - { - byte[] buffer = StructureToByteArray(value); - NtWriteVirtualMemory(GetProcHandle(), GetPtrAddr(basePtr, offsets), buffer, buffer.Length); - } - - public void Write(long address, T value) where T : struct - { - byte[] buffer = StructureToByteArray(value); - NtWriteVirtualMemory(GetProcHandle(), address, buffer, buffer.Length); - } - - public bool IsValid(long Address) - { - return Address >= 0x10000 && Address < 0x000F000000000000; - } - - #region Conversion - private static T ByteArrayToStructure(byte[] bytes) where T : struct - { - var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); - try - { - return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); - } - finally - { - handle.Free(); - } - } - - private static byte[] StructureToByteArray(object obj) - { - int length = Marshal.SizeOf(obj); - byte[] array = new byte[length]; - IntPtr pointer = Marshal.AllocHGlobal(length); - Marshal.StructureToPtr(obj, pointer, true); - Marshal.Copy(pointer, array, 0, length); - Marshal.FreeHGlobal(pointer); - return array; - } - - private static float[] ConvertToFloatArray(byte[] bytes) - { - if (bytes.Length % 4 != 0) - { - throw new ArgumentException(); - } - - float[] floats = new float[bytes.Length / 4]; - for (int i = 0; i < floats.Length; i++) - { - floats[i] = BitConverter.ToSingle(bytes, i * 4); - } - return floats; - } - #endregion - } +using System; +using System.Diagnostics; +using System.Runtime.InteropServices; +using System.Text; + +namespace GTAVCSMM.Helpers +{ + public class Mem + { + [DllImport("ntdll.dll")] + public static extern int NtWriteVirtualMemory(IntPtr ProcessHandle, long BaseAddress, byte[] Buffer, int Size, int BytesWritten = 0); + + [DllImport("ntdll.dll")] + public static extern int NtReadVirtualMemory(IntPtr ProcessHandle, long Address, byte[] buffer, int Size, int BytesRead = 0); + + public Process Proc; + public long BaseAddress; + + public Mem(string process) + { + try + { + Proc = Process.GetProcessesByName(process)[0]; + BaseAddress = Proc.MainModule.BaseAddress.ToInt64(); + } + catch { throw new Exception(); } + } + + public IntPtr GetProcHandle() + { + try { return Proc.Handle; } catch { return IntPtr.Zero; } + } + + public long GetPtrAddr(long Pointer, int[] Offset = null) + { + byte[] Buffer = new byte[8]; + + NtReadVirtualMemory(GetProcHandle(), Pointer, Buffer, Buffer.Length); + + if (Offset != null) + { + for (int x = 0; x < (Offset.Length - 1); x++) + { + Pointer = BitConverter.ToInt64(Buffer, 0) + Offset[x]; + NtReadVirtualMemory(GetProcHandle(), Pointer, Buffer, Buffer.Length); + } + + Pointer = BitConverter.ToInt64(Buffer, 0) + Offset[Offset.Length - 1]; + } + + return Pointer; + } + + public long FindPattern(byte[] pattern, string mask) + { + int moduleSize = Proc.MainModule.ModuleMemorySize; + + if (moduleSize == 0) throw new Exception($"Size of module {Proc.MainModule.ModuleName} is INVALID."); + + byte[] moduleBytes = new byte[moduleSize]; + NtReadVirtualMemory(GetProcHandle(), BaseAddress, moduleBytes, moduleSize); + + for (long i = 0; i < moduleSize; i++) + { + for (int l = 0; l < mask.Length; l++) + //dirty hack heh + if (!(mask[l] == '?' || moduleBytes[l + i] == pattern[l])) goto SKIP; + + return i; + SKIP:; + } + return 0; + } + + public byte[] ReadBytes(long BasePTR, int[] offset, int Length) + { + byte[] Buffer = new byte[Length]; + NtReadVirtualMemory(GetProcHandle(), GetPtrAddr(BaseAddress + BasePTR, offset), Buffer, Length); + return Buffer; + } + + public byte[] ReadBytes_new(long BasePTR, int[] offset, int Length) + { + byte[] Buffer = new byte[Length]; + NtReadVirtualMemory(GetProcHandle(), BasePTR, Buffer, Length); + return Buffer; + } + + public void Write(long BasePTR, int[] offset, byte[] Bytes) => NtWriteVirtualMemory(GetProcHandle(), GetPtrAddr(BaseAddress + BasePTR, offset), Bytes, Bytes.Length); + + public void Write(long BasePTR, int[] offset, bool b) => Write(BasePTR, offset, b ? new byte[] { 0x01 } : new byte[] { 0x00 }); + public void Write(long BasePTR, int[] offset, float Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); + public void Write(long BasePTR, int[] offset, double Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); + public void Write(long BasePTR, int[] offset, int Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); + public void Write(long BasePTR, int[] offset, string String) => Write(BasePTR, offset, new ASCIIEncoding().GetBytes(String)); + public void Write(long BasePTR, int[] offset, long Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); + public void Write(long BasePTR, int[] offset, uint Value) => Write(BasePTR, offset, BitConverter.GetBytes(Value)); + public void Write(long BasePTR, int[] offset, byte Value) => Write(BasePTR, offset, new byte[] { Value }); + + public void writeInt(long BasePTR, int[] offset, int Value) + { + NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 4); + } + public void writeUInt(long BasePTR, int[] offset, uint Value) + { + NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 4); + } + public void writePointer(long BasePTR, int[] offset, long Value) + { + NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 8); + } + public void writeFloat(long BasePTR, int[] offset, float Value) + { + NtWriteVirtualMemory(Proc.Handle, BasePTR, BitConverter.GetBytes(Value), 8); + } + public bool ReadBool(long BasePTR, int[] offset) => ReadByte(BasePTR, offset) != 0x00; + public float ReadFloat(long BasePTR, int[] offset) => BitConverter.ToSingle(ReadBytes(BasePTR, offset, 4), 0); + public double ReadDouble(long BasePTR, int[] offset) => BitConverter.ToDouble(ReadBytes(BasePTR, offset, 8), 0); + public int ReadInt(long BasePTR, int[] offset) => BitConverter.ToInt32(ReadBytes(BasePTR, offset, 4), 0); + public uint ReadUInt(long BasePTR, int[] offset) => BitConverter.ToUInt32(ReadBytes(BasePTR, offset, 4), 0); + public string ReadString(long BasePTR, int[] offset, int size) => new ASCIIEncoding().GetString(ReadBytes(BasePTR, offset, size)); + public long ReadPointer(long BasePTR, int[] offset) => BitConverter.ToInt64(ReadBytes(BasePTR, offset, 8), 0); + public byte ReadByte(long BasePTR, int[] offset) => ReadBytes(BasePTR, offset, 1)[0]; + public string ReadStr(long BasePTR, int[] offset, int size) => new ASCIIEncoding().GetString(ReadBytes_new(BasePTR, offset, size)); + + public T Read(long basePtr, int[] offsets) where T : struct + { + byte[] buffer = new byte[Marshal.SizeOf(typeof(T))]; + NtReadVirtualMemory(GetProcHandle(), GetPtrAddr(basePtr, offsets), buffer, buffer.Length); + return ByteArrayToStructure(buffer); + } + + public T Read(long address) where T : struct + { + byte[] buffer = new byte[Marshal.SizeOf(typeof(T))]; + NtReadVirtualMemory(GetProcHandle(), address, buffer, buffer.Length); + return ByteArrayToStructure(buffer); + } + + public void Write(long basePtr, int[] offsets, T value) where T : struct + { + byte[] buffer = StructureToByteArray(value); + NtWriteVirtualMemory(GetProcHandle(), GetPtrAddr(basePtr, offsets), buffer, buffer.Length); + } + + public void Write(long address, T value) where T : struct + { + byte[] buffer = StructureToByteArray(value); + NtWriteVirtualMemory(GetProcHandle(), address, buffer, buffer.Length); + } + + public bool IsValid(long Address) + { + return Address >= 0x10000 && Address < 0x000F000000000000; + } + + #region Conversion + private static T ByteArrayToStructure(byte[] bytes) where T : struct + { + var handle = GCHandle.Alloc(bytes, GCHandleType.Pinned); + try + { + return (T)Marshal.PtrToStructure(handle.AddrOfPinnedObject(), typeof(T)); + } + finally + { + handle.Free(); + } + } + + private static byte[] StructureToByteArray(object obj) + { + int length = Marshal.SizeOf(obj); + byte[] array = new byte[length]; + IntPtr pointer = Marshal.AllocHGlobal(length); + Marshal.StructureToPtr(obj, pointer, true); + Marshal.Copy(pointer, array, 0, length); + Marshal.FreeHGlobal(pointer); + return array; + } + + private static float[] ConvertToFloatArray(byte[] bytes) + { + if (bytes.Length % 4 != 0) + { + throw new ArgumentException(); + } + + float[] floats = new float[bytes.Length / 4]; + for (int i = 0; i < floats.Length; i++) + { + floats[i] = BitConverter.ToSingle(bytes, i * 4); + } + return floats; + } + #endregion + } } \ No newline at end of file diff --git a/Math/Library.cs b/Math/Library.cs deleted file mode 100644 index 8f49612..0000000 --- a/Math/Library.cs +++ /dev/null @@ -1,58 +0,0 @@ -using System.Reflection; - -namespace GameMath -{ - /// - /// Provides displayable information about this library. - /// - public static class Library - { - /// - /// Gets the author of this library. - /// - /// - /// The name of the author. - /// - public static string Author => "michel-pi"; - - /// - /// Gets the name of this library. - /// - /// - /// The name of the library. - /// - public static string Name => "GameMath.Net"; - - /// - /// Gets the projects url. - /// - /// - /// The projects url. - /// - public static string ProjectUrl => "https://github.com/michel-pi/GameMath.Net"; - - /// - /// Gets the version of this library. - /// - /// - /// The version. - /// - public static string Version - { - get - { - try - { - var assembly = Assembly.GetExecutingAssembly(); - var assemblyName = assembly.GetName(); - - return assemblyName.Version.ToString(); - } - catch - { - return "1.0.0.0"; - } - } - } - } -} \ No newline at end of file diff --git a/Math/Math2.cs b/Math/Math2.cs deleted file mode 100644 index ce1b329..0000000 --- a/Math/Math2.cs +++ /dev/null @@ -1,65 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace GameMath -{ - /// - /// Provides static methods for 2d math. - /// - public static class Math2 - { - /// - /// Calculates the distance of a point to the center of a circle. - /// - /// The point. - /// The circle center. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static double DistanceInCircle(Vector2 point, Vector2 circleCenter) - { - return Math.Sqrt((circleCenter.X - point.X) * (circleCenter.X - point.X) + - (circleCenter.Y - point.Y) * (circleCenter.Y - point.Y)); - } - - /// - /// Calculates the distance of a point to the center of the screen. - /// - /// The x. - /// The y. - /// The screen. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DistanceOnScreen(float X, float Y, Vector2 screen) - { - return (float) Math.Sqrt(Math.Pow(Y - screen.Y / 2, 2) + Math.Pow(X - screen.X / 2, 2)); - } - - /// - /// Calculates the distance of a point to the center of the screen. - /// - /// The point. - /// The screen. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DistanceOnScreen(Vector2 point, Vector2 screen) - { - return (float) Math.Sqrt(Math.Pow(point.Y - screen.Y / 2, 2) + Math.Pow(point.X - screen.X / 2, 2)); - } - - /// - /// Determines whether a given point is inside of a circle. - /// - /// The point. - /// The circle center. - /// The radius. - /// - /// true if [is point in circle] [the specified point]; otherwise, false. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool IsPointInCircle(Vector2 point, Vector2 circleCenter, int radius) - { - return Math.Sqrt((circleCenter.X - point.X) * (circleCenter.X - point.X) + - (circleCenter.Y - point.Y) * (circleCenter.Y - point.Y)) < radius; - } - } -} \ No newline at end of file diff --git a/Math/Math3.cs b/Math/Math3.cs deleted file mode 100644 index fd9e86e..0000000 --- a/Math/Math3.cs +++ /dev/null @@ -1,335 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace GameMath -{ - /// - /// Provides static methods for 3d math. - /// - public static class Math3 - { - /// - /// Calculates the difference of two angles. - /// - /// The point of view. - /// The first angle. - /// The second angle. - /// Degree. - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float AngleDifference(Vector3 pointOfView, Vector3 angle_1, Vector3 angle_2) - { - float deltaX = (float) Math.Sin(MathF.DegreesToRadians(angle_1.X - angle_2.X)); - float deltaY = (float) Math.Sin(MathF.DegreesToRadians(angle_1.Y - angle_2.Y)); - - return (deltaX * deltaX + deltaY * deltaY) * pointOfView.Length(); - } - - /// - /// Calculates the difference of two angles. - /// - /// The distance of our view point. - /// The first angle. - /// The second angle. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float AngleDifference(float distance, Vector3 viewAngle, Vector3 targetAngle) - { - double pitch = Math.Sin(MathF.DegreesToRadians(viewAngle.X - targetAngle.X)) * distance; - double yaw = Math.Sin(MathF.DegreesToRadians(viewAngle.Y - targetAngle.Y)) * distance; - - return (float) Math.Sqrt(pitch * pitch + yaw * yaw); - } - - /// - /// Applies a linear smooth onto an angle. - /// - /// The source angle. - /// The destination angle. - /// The value. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 AngleLinearSmooth(Vector3 source, Vector3 dest, float value) - { - dest -= source; - if (!dest.AngleClampAndNormalize()) return Vector3.Invalid; - dest /= value; - if (!dest.AngleClampAndNormalize()) return Vector3.Invalid; - dest += source; - if (!dest.AngleClampAndNormalize()) return Vector3.Invalid; - return dest; - } - - /// - /// Creates an angle from a vector. - /// - /// The vector. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 AngleVector(Vector3 vec) - { - float x = vec.X * MathF.Deg2Rad; - float y = vec.Y * MathF.Deg2Rad; - - float sinYaw = (float) Math.Sin(y); - float cosYaw = (float) Math.Cos(y); - - float sinPitch = (float) Math.Sin(x); - float cosPitch = (float) Math.Cos(x); - - return new Vector3(cosPitch * cosYaw, cosPitch * sinYaw, -sinPitch); - } - - /// - /// Calculates the angle. - /// - /// The source position. - /// The destination position. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 CalcAngle(Vector3 source, Vector3 dest) - { - var ret = new Vector3(); - var delta = source - dest; - - float hyp = (float) Math.Sqrt(delta.X * delta.X + delta.Y * delta.Y); - - ret.X = MathF.RadiansToDegrees((float) Math.Atan(delta.Z / hyp)); - ret.Y = MathF.RadiansToDegrees((float) Math.Atan(delta.Y / delta.X)); - - if (delta.X >= 0.0f) - ret.Y += 180.0f; - - return ret; - } - - /// - /// Gets the fov. - /// - /// The view angle. - /// The target angle. - /// The distance. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float GetFov(Vector3 viewAngle, Vector3 targetAngle, float distance) - { - double deltaX = Math.Sin(MathF.DegreesToRadians(Math.Abs(viewAngle.X - targetAngle.X))); - double deltaY = Math.Sin(MathF.DegreesToRadians(Math.Abs(viewAngle.Y - targetAngle.Y))); - - return (float) Math.Sin(deltaX * deltaX + deltaY * deltaY) * distance; - } - - /// - /// Gets the fov. - /// - /// The view angle. - /// The origin. - /// The destination. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float GetFov(Vector3 angle, Vector3 src, Vector3 dst) - { - var tmp = dst - src; - - var ang = VectorAngles(tmp); - - var vTempAngles = ang - angle; - - while (vTempAngles.X > 180.0f) vTempAngles.X -= 360.0f; - - while (vTempAngles.X < -180.0f) vTempAngles.X += 360.0f; - - while (vTempAngles.Y > 180.0f) vTempAngles.Y -= 360.0f; - - while (vTempAngles.Y < -180.0f) vTempAngles.Y += 360.0f; - - while (vTempAngles.Z > 180.0f) vTempAngles.Z -= 360.0f; - - while (vTempAngles.Z < -180.0f) vTempAngles.Z += 360.0f; - - return vTempAngles.Length(); - } - - /// - /// Returns the middle of two vector. - /// - /// The minimum. - /// The maximum. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 VectorMid(Vector3 min, Vector3 max) - { - return (max - min) / 2.0f + min; - } - - /// - /// Creates a vector from an angle - /// - /// The forward (direction) vector. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 VectorAngles(Vector3 forward) - { - float yaw; - float pitch; - - if (forward.X == 0 && forward.Y == 0) - { - yaw = 0; - pitch = forward.Z > 0.0f ? 270.0f : 90.0f; - } - else - { - yaw = MathF.RadiansToDegrees((float) Math.Atan2(forward.Y, forward.X)); - - if (yaw < 0) yaw += 360.0f; - - pitch = MathF.RadiansToDegrees((float) Math.Atan2(-forward.Z, - Math.Sqrt(forward.X * forward.X + forward.Y * forward.Y))); - - if (pitch < 0) pitch += 360; - } - - return new Vector3(pitch, yaw, 0); - } - - /// - /// Transfroms a vector - /// - /// The vector. - /// The matrix. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 VectorTransform(Vector3 vec, Matrix3x4 matrix) - { - float x = vec.DotProduct(new Vector3(matrix.M11, matrix.M12, matrix.M13)) + matrix.M14; - float y = vec.DotProduct(new Vector3(matrix.M21, matrix.M22, matrix.M23)) + matrix.M24; - float z = vec.DotProduct(new Vector3(matrix.M31, matrix.M32, matrix.M33)) + matrix.M34; - - return new Vector3(x, y, z); - } - - /// - /// Rotates a vector around a position - /// - /// The target origin. - /// The position to rotate. - /// The rotation yaw. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 VectorRotatePosition(Vector3 targetOrigin, Vector3 positionToRotate, float rotationYaw) - { - var deltaTarget = positionToRotate - targetOrigin; - - float radius = (float) Math.Sqrt(deltaTarget.X * deltaTarget.X + deltaTarget.Y * deltaTarget.Y); - - float rotationYawRad = rotationYaw * MathF.Deg2Rad; - - deltaTarget.X = (float) Math.Sin(rotationYawRad) * radius; - deltaTarget.Y = (float) Math.Cos(rotationYawRad) * radius; - - return new Vector3(deltaTarget.X + targetOrigin.X, deltaTarget.Y + targetOrigin.Y, positionToRotate.Z); - } - - /// - /// Rotates a vectors yaw around a position - /// - /// The target origin. - /// The position to rotate. - /// The target angle. - /// The rotation yaw. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 VectorYawRotate(Vector3 targetOrigin, Vector3 positionToRotate, Vector3 targetAngle, - float rotationYaw) - { - float deltaX = positionToRotate.X - targetOrigin.X; - float deltaY = positionToRotate.Y - targetOrigin.Y; - - float rotationAngle = rotationYaw - targetAngle.Y; - - float radianAngle = rotationAngle * MathF.Deg2Rad; - - float cosX = (float) (deltaX * Math.Cos(radianAngle)); - float cosY = (float) (deltaY * Math.Cos(radianAngle)); - - float sinX = (float) (deltaX * Math.Sin(radianAngle)); - float sinY = (float) (deltaY * Math.Sin(radianAngle)); - - float rotationX = cosX - sinY; - float rotationY = cosY + sinX; - - positionToRotate.X += rotationX; - positionToRotate.Y += rotationY; - - return positionToRotate; - } - - /// - /// Returns the position on screen - /// - /// The view matrix. - /// The vector. - /// The screen x. - /// The screen y. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 WorldToScreen(Matrix4x4 viewMatrix, Vector3 vec, float screenX, float screenY) - { - var returnVector = new Vector2(0, 0); - float w = viewMatrix.M41 * vec.X + viewMatrix.M42 * vec.Y + viewMatrix.M43 * vec.Z + viewMatrix.M44; - - if (!(w >= 0.01f)) return returnVector; - - float inverseX = 1f / w; - - returnVector.X = - screenX / 2f + - (0.5f * ( - (viewMatrix.M11 * vec.X + viewMatrix.M12 * vec.Y + viewMatrix.M13 * vec.Z + viewMatrix.M14) - * inverseX) - * screenX + 0.5f); - - returnVector.Y = - screenY / 2f - - (0.5f * ( - (viewMatrix.M21 * vec.X + viewMatrix.M22 * vec.Y + viewMatrix.M23 * vec.Z + viewMatrix.M24) - * inverseX) - * screenY + 0.5f); - - return returnVector; - } - - /// - /// Returns the position on screen - /// - /// The view matrix. - /// The vec. - /// The screen. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 WorldToScreen(Matrix4x4 viewMatrix, Vector3 vec, Vector2 screen) - { - var returnVector = new Vector2(0, 0); - float w = viewMatrix.M41 * vec.X + viewMatrix.M42 * vec.Y + viewMatrix.M43 * vec.Z + viewMatrix.M44; - - if (!(w >= 0.01f)) return returnVector; - - float inverseX = 1f / w; - - returnVector.X = - screen.X / 2f + - (0.5f * ( - (viewMatrix.M11 * vec.X + viewMatrix.M12 * vec.Y + viewMatrix.M13 * vec.Z + viewMatrix.M14) - * inverseX) - * screen.X + 0.5f); - returnVector.Y = - screen.Y / 2f - - (0.5f * ( - (viewMatrix.M21 * vec.X + viewMatrix.M22 * vec.Y + viewMatrix.M23 * vec.Z + viewMatrix.M24) - * inverseX) - * screen.Y + 0.5f); - - return returnVector; - } - } -} \ No newline at end of file diff --git a/Math/MathF.cs b/Math/MathF.cs deleted file mode 100644 index c5d0290..0000000 --- a/Math/MathF.cs +++ /dev/null @@ -1,211 +0,0 @@ -using System; -using System.Runtime.CompilerServices; - -namespace GameMath -{ - /// - /// Provides methods for float math - /// - public static class MathF - { - private static readonly Random RandomNumberGenerator = new Random(); - - /// - /// PI - /// - public static readonly float Pi = 3.14159274f; - - /// - /// DEG_2_RAD - /// - public static readonly float Deg2Rad = (float) (Math.PI / 180f); - - /// - /// RAD_2_DEG - /// - public static readonly float Rad2Deg = (float) (180.0f / Math.PI); - - /// - /// Returns the absolute value - /// - /// value - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Abs(float x) - { - return Math.Abs(x); - } - - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Acos(float x) - { - return (float) Math.Acos(x); - } - - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Cos(float x) - { - return (float) Math.Cos(x); - } - - /// - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float IeeeRemainder(float x, float y) - { - return (float) Math.IEEERemainder(x, y); - } - - /// - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Pow(float x, float y) - { - return (float) Math.Pow(x, y); - } - - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Sin(float x) - { - return (float) Math.Sin(x); - } - - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Sqrt(float x) - { - return (float) Math.Sqrt(x); - } - - /// - /// - /// - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Tan(float x) - { - return (float) Math.Tan(x); - } - - /// - /// Clamps the specified value. - /// - /// The value. - /// The minimum. - /// The maximum. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Clamp(float value, float min, float max) - { - if (value < min) return min; - - return value > max ? max : value; - } - - /// - /// Degreeses to radians. - /// - /// The deg. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DegreesToRadians(float deg) - { - return deg * Deg2Rad; - } - - /// - /// Normalizes the specified value. - /// - /// The value. - /// The minimum. - /// The maximum. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Normalize(float value, float min, float max) - { - float norm = max < 0.0f ? max * -1.0f : max; - - while (value < min) - value += norm; - while (value > max) - value -= norm; - - return value; - } - - /// - /// Normalizes the specified value. - /// - /// The value. - /// The minimum. - /// The maximum. - /// The norm. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Normalize(float value, float min, float max, float norm) - { - while (value < min) - value += norm; - while (value > max) - value -= norm; - - return value; - } - - /// - /// Radianses to degrees. - /// - /// The RAD. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float RadiansToDegrees(float rad) - { - return rad * Rad2Deg; - } - - /// - /// Random float. - /// - /// The minimum. - /// The maximum. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float RandomFloat(float min, float max) - { - return (float) RandomNumberGenerator.NextDouble() * (max - min) + min; - } - - /// - /// Random int. - /// - /// The minimum. - /// The maximum. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static int RandomInt(int min, int max) - { - return RandomNumberGenerator.Next(min, max); - } - } -} \ No newline at end of file diff --git a/Math/Matrix3x4.cs b/Math/Matrix3x4.cs deleted file mode 100644 index 68abe59..0000000 --- a/Math/Matrix3x4.cs +++ /dev/null @@ -1,125 +0,0 @@ -using System.Runtime.InteropServices; - -namespace GameMath -{ - /// - /// Represents a 3x4 fields Matrix. - /// - [StructLayout(LayoutKind.Sequential)] - public struct Matrix3x4 - { - /// - /// The M11 - /// - public float M11; - - /// - /// The M12 - /// - public float M12; - - /// - /// The M13 - /// - public float M13; - - /// - /// The M14 - /// - public float M14; - - /// - /// The M21 - /// - public float M21; - - /// - /// The M22 - /// - public float M22; - - /// - /// The M23 - /// - public float M23; - - /// - /// The M24 - /// - public float M24; - - /// - /// The M31 - /// - public float M31; - - /// - /// The M32 - /// - public float M32; - - /// - /// The M33 - /// - public float M33; - - /// - /// The M34 - /// - public float M34; - - /// - /// Gets the left. - /// - /// - public Vector3 GetLeft() - { - return GetRight() * -1f; - } - - /// - /// Gets the right. - /// - /// - public Vector3 GetRight() - { - return new Vector3(M11, M21, M31); - } - - /// - /// Gets up. - /// - /// - public Vector3 GetUp() - { - return new Vector3(M12, M22, M33); - } - - /// - /// Gets down. - /// - /// - public Vector3 GetDown() - { - return GetUp() * -1f; - } - - /// - /// Gets the forward. - /// - /// - public Vector3 GetForward() - { - return GetBackward() * -1f; - } - - /// - /// Gets the backward. - /// - /// - public Vector3 GetBackward() - { - return new Vector3(M13, M23, M33); - } - } -} \ No newline at end of file diff --git a/Math/Matrix4x4.cs b/Math/Matrix4x4.cs deleted file mode 100644 index 2261efc..0000000 --- a/Math/Matrix4x4.cs +++ /dev/null @@ -1,816 +0,0 @@ -using System.Globalization; -using System.Runtime.InteropServices; - -namespace GameMath -{ - /// - /// Represents a 4x4 fields matrix - /// - [StructLayout(LayoutKind.Sequential)] - public struct Matrix4x4 - { - /// - /// Gets the identity. - /// - /// - /// The identity. - /// - public static Matrix4x4 Identity => - new Matrix4x4(1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f, 0f, 0f, 0f, 0f, 1f); - - /// - /// Gets a value indicating whether this instance is identity. - /// - /// - /// true if this instance is identity; otherwise, false. - /// - public bool IsIdentity => M11 == 1f && M22 == 1f && M33 == 1f && M44 == 1f && M12 == 0f && M13 == 0f && - M14 == 0f && M21 == 0f && M23 == 0f && M24 == 0f && M31 == 0f && M32 == 0f && - M34 == 0f && M41 == 0f && M42 == 0f && M43 == 0f; - - /// - /// Gets or sets the translation. - /// - /// - /// The translation. - /// - public Vector3 Translation - { - get => new Vector3(M41, M42, M43); - set - { - M41 = value.X; - M42 = value.Y; - M43 = value.Z; - } - } - - /// - /// The M11 - /// - public float M11; - - /// - /// The M12 - /// - public float M12; - - /// - /// The M13 - /// - public float M13; - - /// - /// The M14 - /// - public float M14; - - /// - /// The M21 - /// - public float M21; - - /// - /// The M22 - /// - public float M22; - - /// - /// The M23 - /// - public float M23; - - /// - /// The M24 - /// - public float M24; - - /// - /// The M31 - /// - public float M31; - - /// - /// The M32 - /// - public float M32; - - /// - /// The M33 - /// - public float M33; - - /// - /// The M34 - /// - public float M34; - - /// - /// The M41 - /// - public float M41; - - /// - /// The M42 - /// - public float M42; - - /// - /// The M43 - /// - public float M43; - - /// - /// The M44 - /// - public float M44; - - /// - /// Initializes a new instance of the struct. - /// - /// The M11. - /// The M12. - /// The M13. - /// The M14. - /// The M21. - /// The M22. - /// The M23. - /// The M24. - /// The M31. - /// The M32. - /// The M33. - /// The M34. - /// The M41. - /// The M42. - /// The M43. - /// The M44. - public Matrix4x4(float m11, float m12, float m13, float m14, float m21, float m22, float m23, float m24, - float m31, float m32, float m33, float m34, float m41, float m42, float m43, float m44) - { - M11 = m11; - M12 = m12; - M13 = m13; - M14 = m14; - M21 = m21; - M22 = m22; - M23 = m23; - M24 = m24; - M31 = m31; - M32 = m32; - M33 = m33; - M34 = m34; - M41 = m41; - M42 = m42; - M43 = m43; - M44 = m44; - } - - /// - /// Worlds to screen. - /// - /// The vec. - /// Size of the screen. - /// - public Vector2 WorldToScreen(Vector3 vec, Vector2 screenSize) - { - return WorldToScreen(vec, screenSize.X, screenSize.Y); - } - - /// - /// Worlds to screen. - /// - /// The vec. - /// The size x. - /// The size y. - /// - public Vector2 WorldToScreen(Vector3 vec, float sizeX, float sizeY) - { - var returnVector = new Vector2(0, 0); - float w = M41 * vec.X + M42 * vec.Y + M43 * vec.Z + M44; - - if (!(w >= 0.01f)) return returnVector; - - float inverseX = 1f / w; - - returnVector.X = - sizeX / 2f + - (0.5f * ( - (M11 * vec.X + M12 * vec.Y + M13 * vec.Z + M14) - * inverseX) - * sizeX + 0.5f); - - returnVector.Y = - sizeY / 2f - - (0.5f * ( - (M21 * vec.X + M22 * vec.Y + M23 * vec.Z + M24) - * inverseX) - * sizeY + 0.5f); - - return returnVector; - } - - /// - /// Gets the left. - /// - /// - public Vector3 GetLeft() - { - return GetRight() * -1f; - } - - /// - /// Gets the right. - /// - /// - public Vector3 GetRight() - { - return new Vector3(M11, M21, M31); - } - - /// - /// Gets up. - /// - /// - public Vector3 GetUp() - { - return new Vector3(M12, M22, M33); - } - - /// - /// Gets down. - /// - /// - public Vector3 GetDown() - { - return GetUp() * -1f; - } - - /// - /// Gets the forward. - /// - /// - public Vector3 GetForward() - { - return GetBackward() * -1f; - } - - /// - /// Gets the backward. - /// - /// - public Vector3 GetBackward() - { - return new Vector3(M13, M23, M33); - } - - /// Adds each element in one matrix with its corresponding element in a second matrix. - /// The first matrix. - /// The second matrix. - /// - /// The matrix that contains the summed values of value1 and - /// value2. - /// - public static Matrix4x4 Add(Matrix4x4 value1, Matrix4x4 value2) - { - var result = new Matrix4x4 - { - M11 = value1.M11 + value2.M11, - M12 = value1.M12 + value2.M12, - M13 = value1.M13 + value2.M13, - M14 = value1.M14 + value2.M14, - M21 = value1.M21 + value2.M21, - M22 = value1.M22 + value2.M22, - M23 = value1.M23 + value2.M23, - M24 = value1.M24 + value2.M24, - M31 = value1.M31 + value2.M31, - M32 = value1.M32 + value2.M32, - M33 = value1.M33 + value2.M33, - M34 = value1.M34 + value2.M34, - M41 = value1.M41 + value2.M41, - M42 = value1.M42 + value2.M42, - M43 = value1.M43 + value2.M43, - M44 = value1.M44 + value2.M44 - }; - return result; - } - - /// Subtracts each element in a second matrix from its corresponding element in a first matrix. - /// The first matrix. - /// The second matrix. - /// - /// The matrix containing the values that result from subtracting each element in - /// value2 from its corresponding element in - /// value1. - /// - public static Matrix4x4 Subtract(Matrix4x4 value1, Matrix4x4 value2) - { - var result = new Matrix4x4 - { - M11 = value1.M11 - value2.M11, - M12 = value1.M12 - value2.M12, - M13 = value1.M13 - value2.M13, - M14 = value1.M14 - value2.M14, - M21 = value1.M21 - value2.M21, - M22 = value1.M22 - value2.M22, - M23 = value1.M23 - value2.M23, - M24 = value1.M24 - value2.M24, - M31 = value1.M31 - value2.M31, - M32 = value1.M32 - value2.M32, - M33 = value1.M33 - value2.M33, - M34 = value1.M34 - value2.M34, - M41 = value1.M41 - value2.M41, - M42 = value1.M42 - value2.M42, - M43 = value1.M43 - value2.M43, - M44 = value1.M44 - value2.M44 - }; - return result; - } - - /// Creates a translation matrix from the specified 3-dimensional vector. - /// The amount to translate in each axis. - /// The translation matrix. - public static Matrix4x4 CreateTranslation(Vector3 position) - { - var result = new Matrix4x4 - { - M11 = 1f, - M12 = 0f, - M13 = 0f, - M14 = 0f, - M21 = 0f, - M22 = 1f, - M23 = 0f, - M24 = 0f, - M31 = 0f, - M32 = 0f, - M33 = 1f, - M34 = 0f, - M41 = position.X, - M42 = position.Y, - M43 = position.Z, - M44 = 1f - }; - return result; - } - - /// Inverts the specified matrix. The return value indicates whether the operation succeeded. - /// The matrix to invert. - /// When this method returns, contains the inverted matrix if the operation succeeded. - /// true if matrix was converted successfully; otherwise, false. - public static bool Invert(Matrix4x4 matrix, out Matrix4x4 result) - { - float m = matrix.M11; - float m2 = matrix.M12; - float m3 = matrix.M13; - float m4 = matrix.M14; - float m5 = matrix.M21; - float m6 = matrix.M22; - float m7 = matrix.M23; - float m8 = matrix.M24; - float m9 = matrix.M31; - float m10 = matrix.M32; - float m11 = matrix.M33; - float m12 = matrix.M34; - float m13 = matrix.M41; - float m14 = matrix.M42; - float m15 = matrix.M43; - float m16 = matrix.M44; - float num = m11 * m16 - m12 * m15; - float num2 = m10 * m16 - m12 * m14; - float num3 = m10 * m15 - m11 * m14; - float num4 = m9 * m16 - m12 * m13; - float num5 = m9 * m15 - m11 * m13; - float num6 = m9 * m14 - m10 * m13; - float num7 = m6 * num - m7 * num2 + m8 * num3; - float num8 = -(m5 * num - m7 * num4 + m8 * num5); - float num9 = m5 * num2 - m6 * num4 + m8 * num6; - float num10 = -(m5 * num3 - m6 * num5 + m7 * num6); - float num11 = m * num7 + m2 * num8 + m3 * num9 + m4 * num10; - if (MathF.Abs(num11) < 1.401298E-45f) - { - result = new Matrix4x4(float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, - float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN, float.NaN); - return false; - } - float num12 = 1f / num11; - result.M11 = num7 * num12; - result.M21 = num8 * num12; - result.M31 = num9 * num12; - result.M41 = num10 * num12; - result.M12 = -(m2 * num - m3 * num2 + m4 * num3) * num12; - result.M22 = (m * num - m3 * num4 + m4 * num5) * num12; - result.M32 = -(m * num2 - m2 * num4 + m4 * num6) * num12; - result.M42 = (m * num3 - m2 * num5 + m3 * num6) * num12; - float num13 = m7 * m16 - m8 * m15; - float num14 = m6 * m16 - m8 * m14; - float num15 = m6 * m15 - m7 * m14; - float num16 = m5 * m16 - m8 * m13; - float num17 = m5 * m15 - m7 * m13; - float num18 = m5 * m14 - m6 * m13; - result.M13 = (m2 * num13 - m3 * num14 + m4 * num15) * num12; - result.M23 = -(m * num13 - m3 * num16 + m4 * num17) * num12; - result.M33 = (m * num14 - m2 * num16 + m4 * num18) * num12; - result.M43 = -(m * num15 - m2 * num17 + m3 * num18) * num12; - float num19 = m7 * m12 - m8 * m11; - float num20 = m6 * m12 - m8 * m10; - float num21 = m6 * m11 - m7 * m10; - float num22 = m5 * m12 - m8 * m9; - float num23 = m5 * m11 - m7 * m9; - float num24 = m5 * m10 - m6 * m9; - result.M14 = -(m2 * num19 - m3 * num20 + m4 * num21) * num12; - result.M24 = (m * num19 - m3 * num22 + m4 * num23) * num12; - result.M34 = -(m * num20 - m2 * num22 + m4 * num24) * num12; - result.M44 = (m * num21 - m2 * num23 + m3 * num24) * num12; - return true; - } - - /// - /// Performs a linear interpolation from one matrix to a second matrix based on a value that specifies the - /// weighting of the second matrix. - /// - /// The first matrix. - /// The second matrix. - /// The relative weighting of matrix2. - /// The interpolated matrix. - public static Matrix4x4 Lerp(Matrix4x4 matrix1, Matrix4x4 matrix2, float amount) - { - var result = new Matrix4x4 - { - M11 = matrix1.M11 + (matrix2.M11 - matrix1.M11) * amount, - M12 = matrix1.M12 + (matrix2.M12 - matrix1.M12) * amount, - M13 = matrix1.M13 + (matrix2.M13 - matrix1.M13) * amount, - M14 = matrix1.M14 + (matrix2.M14 - matrix1.M14) * amount, - M21 = matrix1.M21 + (matrix2.M21 - matrix1.M21) * amount, - M22 = matrix1.M22 + (matrix2.M22 - matrix1.M22) * amount, - M23 = matrix1.M23 + (matrix2.M23 - matrix1.M23) * amount, - M24 = matrix1.M24 + (matrix2.M24 - matrix1.M24) * amount, - M31 = matrix1.M31 + (matrix2.M31 - matrix1.M31) * amount, - M32 = matrix1.M32 + (matrix2.M32 - matrix1.M32) * amount, - M33 = matrix1.M33 + (matrix2.M33 - matrix1.M33) * amount, - M34 = matrix1.M34 + (matrix2.M34 - matrix1.M34) * amount, - M41 = matrix1.M41 + (matrix2.M41 - matrix1.M41) * amount, - M42 = matrix1.M42 + (matrix2.M42 - matrix1.M42) * amount, - M43 = matrix1.M43 + (matrix2.M43 - matrix1.M43) * amount, - M44 = matrix1.M44 + (matrix2.M44 - matrix1.M44) * amount - }; - return result; - } - - /// Returns the matrix that results from multiplying two matrices together. - /// The first matrix. - /// The second matrix. - /// The product matrix. - public static Matrix4x4 Multiply(Matrix4x4 value1, Matrix4x4 value2) - { - var result = new Matrix4x4 - { - M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21 + value1.M13 * value2.M31 + - value1.M14 * value2.M41, - M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22 + value1.M13 * value2.M32 + - value1.M14 * value2.M42, - M13 = value1.M11 * value2.M13 + value1.M12 * value2.M23 + value1.M13 * value2.M33 + - value1.M14 * value2.M43, - M14 = value1.M11 * value2.M14 + value1.M12 * value2.M24 + value1.M13 * value2.M34 + - value1.M14 * value2.M44, - M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21 + value1.M23 * value2.M31 + - value1.M24 * value2.M41, - M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22 + value1.M23 * value2.M32 + - value1.M24 * value2.M42, - M23 = value1.M21 * value2.M13 + value1.M22 * value2.M23 + value1.M23 * value2.M33 + - value1.M24 * value2.M43, - M24 = value1.M21 * value2.M14 + value1.M22 * value2.M24 + value1.M23 * value2.M34 + - value1.M24 * value2.M44, - M31 = value1.M31 * value2.M11 + value1.M32 * value2.M21 + value1.M33 * value2.M31 + - value1.M34 * value2.M41, - M32 = value1.M31 * value2.M12 + value1.M32 * value2.M22 + value1.M33 * value2.M32 + - value1.M34 * value2.M42, - M33 = value1.M31 * value2.M13 + value1.M32 * value2.M23 + value1.M33 * value2.M33 + - value1.M34 * value2.M43, - M34 = value1.M31 * value2.M14 + value1.M32 * value2.M24 + value1.M33 * value2.M34 + - value1.M34 * value2.M44, - M41 = value1.M41 * value2.M11 + value1.M42 * value2.M21 + value1.M43 * value2.M31 + - value1.M44 * value2.M41, - M42 = value1.M41 * value2.M12 + value1.M42 * value2.M22 + value1.M43 * value2.M32 + - value1.M44 * value2.M42, - M43 = value1.M41 * value2.M13 + value1.M42 * value2.M23 + value1.M43 * value2.M33 + - value1.M44 * value2.M43, - M44 = value1.M41 * value2.M14 + value1.M42 * value2.M24 + value1.M43 * value2.M34 + - value1.M44 * value2.M44 - }; - return result; - } - - /// Returns the matrix that results from scaling all the elements of a specified matrix by a scalar factor. - /// The matrix to scale. - /// The scaling value to use. - /// The scaled matrix. - public static Matrix4x4 Multiply(Matrix4x4 value1, float value2) - { - var result = new Matrix4x4 - { - M11 = value1.M11 * value2, - M12 = value1.M12 * value2, - M13 = value1.M13 * value2, - M14 = value1.M14 * value2, - M21 = value1.M21 * value2, - M22 = value1.M22 * value2, - M23 = value1.M23 * value2, - M24 = value1.M24 * value2, - M31 = value1.M31 * value2, - M32 = value1.M32 * value2, - M33 = value1.M33 * value2, - M34 = value1.M34 * value2, - M41 = value1.M41 * value2, - M42 = value1.M42 * value2, - M43 = value1.M43 * value2, - M44 = value1.M44 * value2 - }; - return result; - } - - /// Negates the specified matrix by multiplying all its values by -1. - /// The matrix to negate. - /// The negated matrix. - public static Matrix4x4 Negate(Matrix4x4 value) - { - Matrix4x4 result; - result.M11 = -value.M11; - result.M12 = -value.M12; - result.M13 = -value.M13; - result.M14 = -value.M14; - result.M21 = -value.M21; - result.M22 = -value.M22; - result.M23 = -value.M23; - result.M24 = -value.M24; - result.M31 = -value.M31; - result.M32 = -value.M32; - result.M33 = -value.M33; - result.M34 = -value.M34; - result.M41 = -value.M41; - result.M42 = -value.M42; - result.M43 = -value.M43; - result.M44 = -value.M44; - return result; - } - - /// Transposes the rows and columns of a matrix. - /// The matrix to transpose. - /// The transposed matrix. - // Token: 0x06000107 RID: 263 RVA: 0x00018318 File Offset: 0x00016518 - public static Matrix4x4 Transpose(Matrix4x4 matrix) - { - var result = new Matrix4x4 - { - M11 = matrix.M11, - M12 = matrix.M21, - M13 = matrix.M31, - M14 = matrix.M41, - M21 = matrix.M12, - M22 = matrix.M22, - M23 = matrix.M32, - M24 = matrix.M42, - M31 = matrix.M13, - M32 = matrix.M23, - M33 = matrix.M33, - M34 = matrix.M43, - M41 = matrix.M14, - M42 = matrix.M24, - M43 = matrix.M34, - M44 = matrix.M44 - }; - return result; - } - - /// Adds each element in one matrix with its corresponding element in a second matrix. - /// The first matrix. - /// The second matrix. - /// The matrix that contains the summed values. - public static Matrix4x4 operator +(Matrix4x4 value1, Matrix4x4 value2) - { - var result = new Matrix4x4 - { - M11 = value1.M11 + value2.M11, - M12 = value1.M12 + value2.M12, - M13 = value1.M13 + value2.M13, - M14 = value1.M14 + value2.M14, - M21 = value1.M21 + value2.M21, - M22 = value1.M22 + value2.M22, - M23 = value1.M23 + value2.M23, - M24 = value1.M24 + value2.M24, - M31 = value1.M31 + value2.M31, - M32 = value1.M32 + value2.M32, - M33 = value1.M33 + value2.M33, - M34 = value1.M34 + value2.M34, - M41 = value1.M41 + value2.M41, - M42 = value1.M42 + value2.M42, - M43 = value1.M43 + value2.M43, - M44 = value1.M44 + value2.M44 - }; - return result; - } - - /// Returns a value that indicates whether the specified matrices are equal. - /// The first matrix to compare. - /// The second matrix to care - /// - /// true if value1 and value2 are equal; - /// otherwise, false. - /// - public static bool operator ==(Matrix4x4 value1, Matrix4x4 value2) - { - return value1.M11 == value2.M11 && value1.M22 == value2.M22 && value1.M33 == value2.M33 && - value1.M44 == value2.M44 && value1.M12 == value2.M12 && value1.M13 == value2.M13 && - value1.M14 == value2.M14 && value1.M21 == value2.M21 && value1.M23 == value2.M23 && - value1.M24 == value2.M24 && value1.M31 == value2.M31 && value1.M32 == value2.M32 && - value1.M34 == value2.M34 && value1.M41 == value2.M41 && value1.M42 == value2.M42 && - value1.M43 == value2.M43; - } - - /// Returns a value that indicates whether the specified matrices are not equal. - /// The first matrix to compare. - /// The second matrix to compare. - /// - /// true if value1 and value2 are not equal; - /// otherwise, false. - /// - public static bool operator !=(Matrix4x4 value1, Matrix4x4 value2) - { - return value1.M11 != value2.M11 || value1.M12 != value2.M12 || value1.M13 != value2.M13 || - value1.M14 != value2.M14 || value1.M21 != value2.M21 || value1.M22 != value2.M22 || - value1.M23 != value2.M23 || value1.M24 != value2.M24 || value1.M31 != value2.M31 || - value1.M32 != value2.M32 || value1.M33 != value2.M33 || value1.M34 != value2.M34 || - value1.M41 != value2.M41 || value1.M42 != value2.M42 || value1.M43 != value2.M43 || - value1.M44 != value2.M44; - } - - /// Returns the matrix that results from multiplying two matrices together. - /// The first matrix. - /// The second matrix. - /// The product matrix. - public static Matrix4x4 operator *(Matrix4x4 value1, Matrix4x4 value2) - { - Matrix4x4 result; - result.M11 = value1.M11 * value2.M11 + value1.M12 * value2.M21 + value1.M13 * value2.M31 + - value1.M14 * value2.M41; - result.M12 = value1.M11 * value2.M12 + value1.M12 * value2.M22 + value1.M13 * value2.M32 + - value1.M14 * value2.M42; - result.M13 = value1.M11 * value2.M13 + value1.M12 * value2.M23 + value1.M13 * value2.M33 + - value1.M14 * value2.M43; - result.M14 = value1.M11 * value2.M14 + value1.M12 * value2.M24 + value1.M13 * value2.M34 + - value1.M14 * value2.M44; - result.M21 = value1.M21 * value2.M11 + value1.M22 * value2.M21 + value1.M23 * value2.M31 + - value1.M24 * value2.M41; - result.M22 = value1.M21 * value2.M12 + value1.M22 * value2.M22 + value1.M23 * value2.M32 + - value1.M24 * value2.M42; - result.M23 = value1.M21 * value2.M13 + value1.M22 * value2.M23 + value1.M23 * value2.M33 + - value1.M24 * value2.M43; - result.M24 = value1.M21 * value2.M14 + value1.M22 * value2.M24 + value1.M23 * value2.M34 + - value1.M24 * value2.M44; - result.M31 = value1.M31 * value2.M11 + value1.M32 * value2.M21 + value1.M33 * value2.M31 + - value1.M34 * value2.M41; - result.M32 = value1.M31 * value2.M12 + value1.M32 * value2.M22 + value1.M33 * value2.M32 + - value1.M34 * value2.M42; - result.M33 = value1.M31 * value2.M13 + value1.M32 * value2.M23 + value1.M33 * value2.M33 + - value1.M34 * value2.M43; - result.M34 = value1.M31 * value2.M14 + value1.M32 * value2.M24 + value1.M33 * value2.M34 + - value1.M34 * value2.M44; - result.M41 = value1.M41 * value2.M11 + value1.M42 * value2.M21 + value1.M43 * value2.M31 + - value1.M44 * value2.M41; - result.M42 = value1.M41 * value2.M12 + value1.M42 * value2.M22 + value1.M43 * value2.M32 + - value1.M44 * value2.M42; - result.M43 = value1.M41 * value2.M13 + value1.M42 * value2.M23 + value1.M43 * value2.M33 + - value1.M44 * value2.M43; - result.M44 = value1.M41 * value2.M14 + value1.M42 * value2.M24 + value1.M43 * value2.M34 + - value1.M44 * value2.M44; - return result; - } - - /// Returns the matrix that results from scaling all the elements of a specified matrix by a scalar factor. - /// The matrix to scale. - /// The scaling value to use. - /// The scaled matrix. - public static Matrix4x4 operator *(Matrix4x4 value1, float value2) - { - Matrix4x4 result; - result.M11 = value1.M11 * value2; - result.M12 = value1.M12 * value2; - result.M13 = value1.M13 * value2; - result.M14 = value1.M14 * value2; - result.M21 = value1.M21 * value2; - result.M22 = value1.M22 * value2; - result.M23 = value1.M23 * value2; - result.M24 = value1.M24 * value2; - result.M31 = value1.M31 * value2; - result.M32 = value1.M32 * value2; - result.M33 = value1.M33 * value2; - result.M34 = value1.M34 * value2; - result.M41 = value1.M41 * value2; - result.M42 = value1.M42 * value2; - result.M43 = value1.M43 * value2; - result.M44 = value1.M44 * value2; - return result; - } - - /// Subtracts each element in a second matrix from its corresponding element in a first matrix. - /// The first matrix. - /// The second matrix. - /// - /// The matrix containing the values that result from subtracting each element in - /// value2 from its corresponding element in - /// value1. - /// - public static Matrix4x4 operator -(Matrix4x4 value1, Matrix4x4 value2) - { - Matrix4x4 result; - result.M11 = value1.M11 - value2.M11; - result.M12 = value1.M12 - value2.M12; - result.M13 = value1.M13 - value2.M13; - result.M14 = value1.M14 - value2.M14; - result.M21 = value1.M21 - value2.M21; - result.M22 = value1.M22 - value2.M22; - result.M23 = value1.M23 - value2.M23; - result.M24 = value1.M24 - value2.M24; - result.M31 = value1.M31 - value2.M31; - result.M32 = value1.M32 - value2.M32; - result.M33 = value1.M33 - value2.M33; - result.M34 = value1.M34 - value2.M34; - result.M41 = value1.M41 - value2.M41; - result.M42 = value1.M42 - value2.M42; - result.M43 = value1.M43 - value2.M43; - result.M44 = value1.M44 - value2.M44; - return result; - } - - /// Negates the specified matrix by multiplying all its values by -1. - /// The matrix to negate. - /// The negated matrix. - public static Matrix4x4 operator -(Matrix4x4 value) - { - Matrix4x4 result; - result.M11 = -value.M11; - result.M12 = -value.M12; - result.M13 = -value.M13; - result.M14 = -value.M14; - result.M21 = -value.M21; - result.M22 = -value.M22; - result.M23 = -value.M23; - result.M24 = -value.M24; - result.M31 = -value.M31; - result.M32 = -value.M32; - result.M33 = -value.M33; - result.M34 = -value.M34; - result.M41 = -value.M41; - result.M42 = -value.M42; - result.M43 = -value.M43; - result.M44 = -value.M44; - return result; - } - - /// Returns a string that represents this matrix. - /// The string representation of this matrix. - public override string ToString() - { - var currentCulture = CultureInfo.CurrentCulture; - return string.Format(currentCulture, - "{{ {{M11:{0} M12:{1} M13:{2} M14:{3}}} {{M21:{4} M22:{5} M23:{6} M24:{7}}} {{M31:{8} M32:{9} M33:{10} M34:{11}}} {{M41:{12} M42:{13} M43:{14} M44:{15}}} }}", - M11.ToString(currentCulture), M12.ToString(currentCulture), M13.ToString(currentCulture), - M14.ToString(currentCulture), M21.ToString(currentCulture), M22.ToString(currentCulture), - M23.ToString(currentCulture), M24.ToString(currentCulture), M31.ToString(currentCulture), - M32.ToString(currentCulture), M33.ToString(currentCulture), M34.ToString(currentCulture), - M41.ToString(currentCulture), M42.ToString(currentCulture), M43.ToString(currentCulture), - M44.ToString(currentCulture)); - } - - /// Returns the hash code for this instance. - /// The hash code. - public override int GetHashCode() - { - return M11.GetHashCode() + M12.GetHashCode() + M13.GetHashCode() + M14.GetHashCode() + M21.GetHashCode() + - M22.GetHashCode() + M23.GetHashCode() + M24.GetHashCode() + M31.GetHashCode() + M32.GetHashCode() + - M33.GetHashCode() + M34.GetHashCode() + M41.GetHashCode() + M42.GetHashCode() + M43.GetHashCode() + - M44.GetHashCode(); - } - - /// Returns a value that indicates whether this instance and a specified object are equal. - /// The object to compare with the current instance. - /// - /// true if the current instance and obj are equal; otherwise, false. If - /// obj is null, the method returns false. - /// - public override bool Equals(object obj) - { - return obj is Matrix4x4 && Equals((Matrix4x4) obj); - } - - /// Returns a value that indicates whether this instance and another 4x4 matrix are equal. - /// The other matrix. - /// true if the two matrices are equal; otherwise, false. - public bool Equals(Matrix4x4 other) - { - return M11 == other.M11 && M22 == other.M22 && M33 == other.M33 && M44 == other.M44 && M12 == other.M12 && - M13 == other.M13 && M14 == other.M14 && M21 == other.M21 && M23 == other.M23 && M24 == other.M24 && - M31 == other.M31 && M32 == other.M32 && M34 == other.M34 && M41 == other.M41 && M42 == other.M42 && - M43 == other.M43; - } - } -} \ No newline at end of file diff --git a/Math/Vector2.cs b/Math/Vector2.cs deleted file mode 100644 index 65614f6..0000000 --- a/Math/Vector2.cs +++ /dev/null @@ -1,869 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace GameMath -{ - /// - /// Represents a 2 dimensional vector - /// - [StructLayout(LayoutKind.Sequential)] - public struct Vector2 - { - /// - /// Represents an ampty vector2 - /// - public static readonly Vector2 Empty; - - /// - /// Represents an invalid vector2 - /// - public static readonly Vector2 Invalid = new Vector2(float.NaN, float.NaN); - - /// - /// The size of a vector2 in memory - /// - public static readonly int Size = 8; - - /// - /// The x - /// - public float X; - - /// - /// The y - /// - public float Y; - - /// - /// Gets or sets the at the specified index. - /// - /// - /// The . - /// - /// The index. - /// - public float this[int index] - { - get - { - switch (index) - { - case 0: - return X; - case 1: - return Y; - } - - return index < 0 ? X : Y; - } - set - { - switch (index) - { - case 0: - X = value; - break; - case 1: - Y = value; - break; - default: - if (index < 0) X = value; - else Y = value; - break; - } - } - } - - /// - /// Initializes a new instance of the struct. - /// - /// The array. - public Vector2(float[] array) - { - if (array == null || array.Length < 2) - { - X = float.NaN; - Y = float.NaN; - return; - } - - X = array[0]; - Y = array[1]; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The x. - /// The y. - public Vector2(float x, float y) - { - X = x; - Y = y; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The x. - /// The y. - public Vector2(double x, double y) - { - X = (float) x; - Y = (float) y; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The x. - /// The y. - public Vector2(int x, int y) - { - X = x; - Y = y; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The bytes. - public Vector2(byte[] bytes) - { - if (bytes == null || bytes.Length < 8) - { - X = 0.0f; - Y = 0.0f; - } - - X = BitConverter.ToSingle(bytes, 0); - Y = BitConverter.ToSingle(bytes, 4); - } - - /// - /// Initializes a new instance of the struct. - /// - /// The dword. - public Vector2(int dword) - { - X = dword & 65535; // LO-WORD - Y = (dword >> 16) & 65535; // HI-WORD - } - - /// - /// Determines whether the specified , is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - if (obj is Vector2) - return (Vector2) obj == this; - - return base.Equals(obj); - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return base.GetHashCode(); - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return "{X = " + X + ", Y = " + Y + "}"; - } - - /// - /// Adds the specified vec. - /// - /// The vec. - public void Add(Vector2 vec) - { - X += vec.X; - Y += vec.Y; - } - - /// - /// Adds the specified vec. - /// - /// The vec. - public void Add(float vec) - { - X += vec; - Y += vec; - } - - /// - /// Adds the specified vec. - /// - /// The vec. - public void Add(int vec) - { - X += vec; - Y += vec; - } - - /// - /// Subtracts the specified vec. - /// - /// The vec. - public void Subtract(Vector2 vec) - { - X -= vec.X; - Y -= vec.Y; - } - - /// - /// Subtracts the specified vec. - /// - /// The vec. - public void Subtract(float vec) - { - X -= vec; - Y -= vec; - } - - /// - /// Subtracts the specified vec. - /// - /// The vec. - public void Subtract(int vec) - { - X -= vec; - Y -= vec; - } - - /// - /// Multiplies the specified vec. - /// - /// The vec. - public void Multiply(Vector2 vec) - { - X *= vec.X; - Y *= vec.Y; - } - - /// - /// Multiplies the specified vec. - /// - /// The vec. - public void Multiply(float vec) - { - X *= vec; - Y *= vec; - } - - /// - /// Multiplies the specified vec. - /// - /// The vec. - public void Multiply(int vec) - { - X *= vec; - Y *= vec; - } - - /// - /// Divides the specified vec. - /// - /// The vec. - public void Divide(Vector2 vec) - { - if (vec.X == 0.0f) vec.X = float.Epsilon; - if (vec.Y == 0.0f) vec.Y = float.Epsilon; - - X /= vec.X; - Y /= vec.Y; - } - - /// - /// Divides the specified vec. - /// - /// The vec. - public void Divide(float vec) - { - if (vec == 0.0f) vec = float.Epsilon; - - X /= vec; - Y /= vec; - } - - /// - /// Divides the specified vec. - /// - /// The vec. - public void Divide(int vec) - { - float tmp = vec; - if (tmp == 0.0f) tmp = float.Epsilon; - - X /= tmp; - Y /= tmp; - } - - /// - /// Clones this instance. - /// - /// - public Vector2 Clone() - { - return new Vector2(X, Y); - } - - /// - /// Clears this instance. - /// - public void Clear() - { - X = 0.0f; - Y = 0.0f; - } - - /// - /// Distances to. - /// - /// The vec. - /// - public float DistanceTo(Vector2 vec) - { - return (this - vec).Length(); - } - - /// - /// Dots the product. - /// - /// The vec. - /// - public float DotProduct(Vector2 vec) - { - return X * vec.X + Y * vec.Y; - } - - /// - /// Crosses the product. - /// - /// The vec. - /// - public Vector2 CrossProduct(Vector2 vec) - { - return new Vector2(X * vec.Y - Y * vec.X, Y * vec.Y - X * vec.X); - } - - /// - /// Gets the bytes. - /// - /// - public byte[] GetBytes() - { - byte[] bytes = new byte[8]; - Buffer.BlockCopy(BitConverter.GetBytes(X), 0, bytes, 0, 4); - Buffer.BlockCopy(BitConverter.GetBytes(Y), 0, bytes, 4, 4); - return bytes; - } - - /// - /// Returns the vecors length - /// - /// - public float Length() - { - return (float) Math.Sqrt(X * X + Y * Y); - } - - /// - /// Determines whether this instance is empty. - /// - /// - /// true if this instance is empty; otherwise, false. - /// - public bool IsEmpty() - { - return X == 0.0f && Y == 0.0f; - } - - /// - /// Reals the is empty. - /// - /// - public bool RealIsEmpty() - { - return X < float.Epsilon && X > -float.Epsilon && Y < float.Epsilon && Y > -float.Epsilon; - } - - /// - /// Determines whether [is na n]. - /// - /// - /// true if [is na n]; otherwise, false. - /// - public bool IsNaN() - { - return float.IsNaN(X) || float.IsNaN(Y); - } - - /// - /// Determines whether this instance is infinity. - /// - /// - /// true if this instance is infinity; otherwise, false. - /// - public bool IsInfinity() - { - return float.IsInfinity(X) || float.IsInfinity(Y); - } - - /// - /// Returns true if ... is valid. - /// - /// - /// true if this instance is valid; otherwise, false. - /// - public bool IsValid() - { - if (IsNaN()) return false; - - return !IsInfinity(); - } - - /// - /// Implements the operator +. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator +(Vector2 left, Vector2 right) - { - return new Vector2(left.X + right.X, left.Y + right.Y); - } - - /// - /// Implements the operator +. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator +(Vector2 left, float right) - { - return new Vector2(left.X + right, left.Y + right); - } - - /// - /// Implements the operator +. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator +(Vector2 left, int right) - { - return new Vector2(left.X + right, left.Y + right); - } - - /// - /// Implements the operator -. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator -(Vector2 left, Vector2 right) - { - return new Vector2(left.X - right.X, left.Y - right.Y); - } - - /// - /// Implements the operator -. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator -(Vector2 left, float right) - { - return new Vector2(left.X - right, left.Y - right); - } - - /// - /// Implements the operator -. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator -(Vector2 left, int right) - { - return new Vector2(left.X - right, left.Y - right); - } - - /// - /// Implements the operator *. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator *(Vector2 left, Vector2 right) - { - return new Vector2(left.X * right.X, left.Y * right.Y); - } - - /// - /// Implements the operator *. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator *(Vector2 left, float right) - { - return new Vector2(left.X * right, left.Y * right); - } - - /// - /// Implements the operator *. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator *(Vector2 left, int right) - { - return new Vector2(left.X * right, left.Y * right); - } - - /// - /// Implements the operator /. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator /(Vector2 left, Vector2 right) - { - return new Vector2(left.X / right.X, left.Y / right.Y); - } - - /// - /// Implements the operator /. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator /(Vector2 left, float right) - { - return new Vector2(left.X / right, left.Y / right); - } - - /// - /// Implements the operator /. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector2 operator /(Vector2 left, int right) - { - return new Vector2(left.X / right, left.Y / right); - } - - /// - /// Implements the operator ==. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator ==(Vector2 left, Vector2 right) - { - return left.X == right.X && left.Y == right.Y; - } - - /// - /// Implements the operator ==. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator ==(Vector2 left, float right) - { - return left.X == right && left.Y == right; - } - - /// - /// Implements the operator ==. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator ==(Vector2 left, int right) - { - return left.X == right && left.Y == right; - } - - /// - /// Implements the operator !=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator !=(Vector2 left, Vector2 right) - { - return left.X != right.X || left.Y != right.Y; - } - - /// - /// Implements the operator !=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator !=(Vector2 left, float right) - { - return left.X != right || left.Y != right; - } - - /// - /// Implements the operator !=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator !=(Vector2 left, int right) - { - return left.X != right || left.Y != right; - } - - /// - /// Implements the operator <. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <(Vector2 left, Vector2 right) - { - return left.X < right.X && left.Y < right.Y; - } - - /// - /// Implements the operator <. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <(Vector2 left, float right) - { - return left.X < right && left.Y < right; - } - - /// - /// Implements the operator <. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <(Vector2 left, int right) - { - return left.X < right && left.Y < right; - } - - /// - /// Implements the operator >. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >(Vector2 left, Vector2 right) - { - return left.X > right.X && left.Y > right.Y; - } - - /// - /// Implements the operator >. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >(Vector2 left, float right) - { - return left.X > right && left.Y > right; - } - - /// - /// Implements the operator >. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >(Vector2 left, int right) - { - return left.X > right && left.Y > right; - } - - /// - /// Implements the operator <=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <=(Vector2 left, Vector2 right) - { - return left < right || left == right; - } - - /// - /// Implements the operator <=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <=(Vector2 left, float right) - { - return left < right || left == right; - } - - /// - /// Implements the operator <=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <=(Vector2 left, int right) - { - return left < right || left == right; - } - - /// - /// Implements the operator >=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >=(Vector2 left, Vector2 right) - { - return left > right || left == right; - } - - /// - /// Implements the operator >=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >=(Vector2 left, float right) - { - return left > right || left == right; - } - - /// - /// Implements the operator >=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >=(Vector2 left, int right) - { - return left > right || left == right; - } - - /// - /// Distances the specified left. - /// - /// The left. - /// The right. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Distance(Vector2 left, Vector2 right) - { - return left.DistanceTo(right); - } - - /// - /// Dots the product. - /// - /// The left. - /// The right. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DotProduct(Vector2 left, Vector2 right) - { - return left.DotProduct(right); - } - - /// - /// Crosses the product. - /// - /// The left. - /// The right. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector2 CrossProduct(Vector2 left, Vector2 right) - { - return left.CrossProduct(right); - } - } -} \ No newline at end of file diff --git a/Math/Vector3.cs b/Math/Vector3.cs deleted file mode 100644 index a374c27..0000000 --- a/Math/Vector3.cs +++ /dev/null @@ -1,1114 +0,0 @@ -using System; -using System.Runtime.CompilerServices; -using System.Runtime.InteropServices; - -namespace GameMath -{ - /// - /// Represents a 3 dimensional vector - /// - [StructLayout(LayoutKind.Sequential)] - public struct Vector3 - { - /// - /// The empty - /// - public static readonly Vector3 Empty; - - /// - /// The zero - /// - public static readonly Vector3 Zero; - - /// - /// The invalid - /// - public static readonly Vector3 Invalid = new Vector3(float.NaN, float.NaN, float.NaN); - - /// - /// The size - /// - public static readonly int Size = 12; - - /// - /// The x - /// - public float X; - - /// - /// The y - /// - public float Y; - - /// - /// The z - /// - public float Z; - - /// - /// Gets or sets the at the specified index. - /// - /// - /// The . - /// - /// The index. - /// - public float this[int index] - { - get - { - if (index < 0 || index > 2) return float.NaN; - - switch (index) - { - case 0: - return X; - case 1: - return Y; - } - - return Z; - } - set - { - if (index < 0 || index > 2) return; - - switch (index) - { - case 0: - X = value; - break; - case 1: - Y = value; - break; - default: - Z = value; - break; - } - } - } - - /// - /// Initializes a new instance of the struct. - /// - /// The x. - /// The y. - /// The z. - public Vector3(float x, float y, float z) - { - X = x; - Y = y; - Z = z; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The x. - /// The y. - /// The z. - public Vector3(double x, double y, double z) - { - X = (float) x; - Y = (float) y; - Z = (float) z; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The x. - /// The y. - /// The z. - public Vector3(int x, int y, int z) - { - X = x; - Y = y; - Z = z; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The array. - public Vector3(float[] array) - { - if (array == null || array.Length != 3) - { - X = float.NaN; - Y = float.NaN; - Z = float.NaN; - return; - } - - X = array[0]; - Y = array[1]; - Z = array[2]; - } - - /// - /// Initializes a new instance of the struct. - /// - /// The array. - public Vector3(byte[] array) - { - if (array == null || array.Length != 12) - { - X = float.NaN; - Y = float.NaN; - Z = float.NaN; - return; - } - - X = BitConverter.ToSingle(array, 0); - Y = BitConverter.ToSingle(array, 4); - Z = BitConverter.ToSingle(array, 8); - } - - /// - /// Determines whether the specified , is equal to this instance. - /// - /// The to compare with this instance. - /// - /// true if the specified is equal to this instance; otherwise, false. - /// - public override bool Equals(object obj) - { - return obj is Vector3 && Equals((Vector3) obj); - } - - /// - /// Returns a hash code for this instance. - /// - /// - /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table. - /// - public override int GetHashCode() - { - return X.GetHashCode() ^ Y.GetHashCode() ^ Z.GetHashCode(); - } - - /// - /// Returns a that represents this instance. - /// - /// - /// A that represents this instance. - /// - public override string ToString() - { - return "{X = " + X + ", Y = " + Y + ", Z = " + Z + "}"; - } - - /// - /// Adds the specified vec. - /// - /// The vec. - public void Add(Vector3 vec) - { - X += vec.X; - Y += vec.Y; - Z += vec.Z; - } - - /// - /// Adds the specified vec. - /// - /// The vec. - public void Add(float vec) - { - X += vec; - Y += vec; - Z += vec; - } - - /// - /// Adds the specified vec. - /// - /// The vec. - public void Add(int vec) - { - X += vec; - Y += vec; - Z += vec; - } - - /// - /// Subtracts the specified vec. - /// - /// The vec. - public void Subtract(Vector3 vec) - { - X -= vec.X; - Y -= vec.Y; - Z -= vec.Z; - } - - /// - /// Subtracts the specified vec. - /// - /// The vec. - public void Subtract(float vec) - { - X -= vec; - Y -= vec; - Z -= vec; - } - - /// - /// Subtracts the specified vec. - /// - /// The vec. - public void Subtract(int vec) - { - X -= vec; - Y -= vec; - Z -= vec; - } - - /// - /// Multiplies the specified vec. - /// - /// The vec. - public void Multiply(Vector3 vec) - { - X *= vec.X; - Y *= vec.Y; - Z *= vec.Z; - } - - /// - /// Multiplies the specified vec. - /// - /// The vec. - public void Multiply(float vec) - { - X *= vec; - Y *= vec; - Z *= vec; - } - - /// - /// Multiplies the specified vec. - /// - /// The vec. - public void Multiply(int vec) - { - X *= vec; - Y *= vec; - Z *= vec; - } - - /// - /// Divides the specified vec. - /// - /// The vec. - public void Divide(Vector3 vec) - { - if (vec.X == 0.0f) vec.X = float.Epsilon; - if (vec.Y == 0.0f) vec.Y = float.Epsilon; - if (vec.Z == 0.0f) vec.Z = float.Epsilon; - - X /= vec.X; - Y /= vec.Y; - Z /= vec.Z; - } - - /// - /// Divides the specified vec. - /// - /// The vec. - public void Divide(float vec) - { - if (vec == 0.0f) vec = float.Epsilon; - - X /= vec; - Y /= vec; - Z /= vec; - } - - /// - /// Divides the specified vec. - /// - /// The vec. - public void Divide(int vec) - { - float tmp = vec; - if (tmp == 0.0f) tmp = float.Epsilon; - - X /= tmp; - Y /= tmp; - Z /= tmp; - } - - /// - /// Clones this instance. - /// - /// - public Vector3 Clone() - { - return new Vector3(X, Y, Z); - } - - /// - /// Clears this instance. - /// - public void Clear() - { - X = 0.0f; - Y = 0.0f; - Z = 0.0f; - } - - /// - /// Distances to. - /// - /// The vec. - /// - public float DistanceTo(Vector3 vec) - { - return (this - vec).Length(); - } - - /// - /// Lengthes this instance. - /// - /// - public float Length() - { - return (float) Math.Sqrt(X * X + Y * Y + Z * Z); - } - - /// - /// Lengthes the squared. - /// - /// - public float LengthSquared() - { - return X * X + Y * Y + Z * Z; - } - - /// - /// Dots the product. - /// - /// The right. - /// - public float DotProduct(Vector3 right) - { - return X * right.X + Y * right.Y + Z * right.Z; - } - - /// - /// Crosses the product. - /// - /// The right. - /// - public Vector3 CrossProduct(Vector3 right) - { - return new Vector3 - { - X = Y * right.Z - Z * right.Y, - Y = Z * right.X - X * right.Z, - Z = X * right.Y - Y * right.X - }; - } - - /// - /// Lerps the specified right. - /// - /// The right. - /// The amount. - /// - public Vector3 Lerp(Vector3 right, float amount) - { - return new Vector3(X + (right.X - X) * amount, Y + (right.Y - Y) * amount, Z + (right.Z - Z) * amount); - } - - /// - /// Gets the bytes. - /// - /// - public byte[] GetBytes() - { - byte[] bytes = new byte[12]; - Buffer.BlockCopy(BitConverter.GetBytes(X), 0, bytes, 0, 4); - Buffer.BlockCopy(BitConverter.GetBytes(Y), 0, bytes, 4, 4); - Buffer.BlockCopy(BitConverter.GetBytes(Z), 0, bytes, 8, 4); - return bytes; - } - - /// - /// Determines whether this instance is empty. - /// - /// - /// true if this instance is empty; otherwise, false. - /// - public bool IsEmpty() - { - return X == 0.0f && Y == 0.0f && Z == 0.0f; - } - - /// - /// Reals the is empty. - /// - /// - public bool RealIsEmpty() - { - return X < float.Epsilon && X > -float.Epsilon && Y < float.Epsilon && Y > -float.Epsilon && - Z < float.Epsilon && Z > -float.Epsilon; - } - - /// - /// Determines whether [is na n]. - /// - /// - /// true if [is na n]; otherwise, false. - /// - public bool IsNaN() - { - return float.IsNaN(X) || float.IsNaN(Y) || float.IsNaN(Z); - } - - /// - /// Determines whether this instance is infinity. - /// - /// - /// true if this instance is infinity; otherwise, false. - /// - public bool IsInfinity() - { - return float.IsInfinity(X) || float.IsInfinity(Y) || float.IsInfinity(Z); - } - - /// - /// Returns true if ... is valid. - /// - /// - /// true if this instance is valid; otherwise, false. - /// - public bool IsValid() - { - if (IsNaN()) return false; - - return !IsInfinity(); - } - - /// - /// Angles the clamp. - /// - /// - public bool AngleClamp() - { - if (!IsValid()) return false; - - X = MathF.Clamp(X, -89.0f, 89.0f); - - Z = 0.0f; - - return IsValid(); - } - - /// - /// Angles the clamp. - /// - /// The minimum. - /// The maximum. - /// - public bool AngleClamp(float min, float max) - { - if (!IsValid()) return false; - - X = MathF.Clamp(X, min, max); - - Z = 0.0f; - - return IsValid(); - } - - /// - /// Angles the normalize. - /// - /// - public bool AngleNormalize() - { - if (!IsValid()) return false; - - Y = MathF.Normalize(Y, -180.0f, 180.0f, 360.0f); - - Z = 0.0f; - - return IsValid(); - } - - /// - /// Angles the normalize. - /// - /// The minimum. - /// The maximum. - /// The norm. - /// - public bool AngleNormalize(float min, float max, float norm) - { - if (!IsValid()) return false; - - Y = MathF.Normalize(Y, min, max, norm); - - Z = 0.0f; - - return IsValid(); - } - - /// - /// Angles the clamp and normalize. - /// - /// - public bool AngleClampAndNormalize() - { - if (!IsValid()) return false; - - X = MathF.Clamp(X, -89.0f, 89.0f); - Y = MathF.Normalize(Y, -180.0f, 180.0f, 360.0f); - Z = 0.0f; - - return IsValid(); - } - - /// - /// Vectors the normalize. - /// - /// - public bool VectorNormalize() - { - if (!IsValid()) return false; - - float length = Length(); - - if (length == 0.0f) return true; - - X /= length; - Y /= length; - Z /= length; - - return IsValid(); - } - - /// - /// Implements the operator +. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator +(Vector3 left, Vector3 right) - { - return new Vector3(left.X + right.X, left.Y + right.Y, left.Z + right.Z); - } - - /// - /// Implements the operator +. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator +(Vector3 left, float right) - { - return new Vector3(left.X + right, left.Y + right, left.Z + right); - } - - /// - /// Implements the operator +. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator +(Vector3 left, int right) - { - return new Vector3(left.X + right, left.Y + right, left.Z + right); - } - - /// - /// Implements the operator -. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator -(Vector3 left, Vector3 right) - { - return new Vector3(left.X - right.X, left.Y - right.Y, left.Z - right.Z); - } - - /// - /// Implements the operator -. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator -(Vector3 left, float right) - { - return new Vector3(left.X - right, left.Y - right, left.Z - right); - } - - /// - /// Implements the operator -. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator -(Vector3 left, int right) - { - return new Vector3(left.X - right, left.Y - right, left.Z - right); - } - - /// - /// Implements the operator *. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator *(Vector3 left, Vector3 right) - { - return new Vector3(left.X * right.X, left.Y * right.Y, left.Z * right.Z); - } - - /// - /// Implements the operator *. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator *(Vector3 left, float right) - { - return new Vector3(left.X * right, left.Y * right, left.Z * right); - } - - /// - /// Implements the operator *. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator *(Vector3 left, int right) - { - return new Vector3(left.X * right, left.Y * right, left.Z * right); - } - - /// - /// Implements the operator /. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator /(Vector3 left, Vector3 right) - { - return new Vector3(left.X / right.X, left.Y / right.Y, left.Z / right.Z); - } - - /// - /// Implements the operator /. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator /(Vector3 left, float right) - { - return new Vector3(left.X / right, left.Y / right, left.Z / right); - } - - /// - /// Implements the operator /. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static Vector3 operator /(Vector3 left, int right) - { - return new Vector3(left.X / right, left.Y / right, left.Z / right); - } - - /// - /// Implements the operator ==. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator ==(Vector3 left, Vector3 right) - { - return left.X == right.X - && left.Y == right.Y - && left.Z == right.Z; - } - - /// - /// Implements the operator ==. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator ==(Vector3 left, float right) - { - return left.X == right - && left.Y == right - && left.Z == right; - } - - /// - /// Implements the operator ==. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator ==(Vector3 left, int right) - { - return left.X == right - && left.Y == right - && left.Z == right; - } - - /// - /// Implements the operator !=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator !=(Vector3 left, Vector3 right) - { - return left.X != right.X - || left.Y != right.Y - || left.Z != right.Z; - } - - /// - /// Implements the operator !=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator !=(Vector3 left, float right) - { - return left.X != right - || left.Y != right - || left.Z != right; - } - - /// - /// Implements the operator !=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator !=(Vector3 left, int right) - { - return left.X != right - || left.Y != right - || left.Z != right; - } - - /// - /// Implements the operator <. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <(Vector3 left, Vector3 right) - { - return left.X < right.X - && left.Y < right.Y - && left.Z < right.Z; - } - - /// - /// Implements the operator <. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <(Vector3 left, float right) - { - return left.X < right - && left.Y < right - && left.Z < right; - } - - /// - /// Implements the operator <. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <(Vector3 left, int right) - { - return left.X < right - && left.Y < right - && left.Z < right; - } - - /// - /// Implements the operator >. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >(Vector3 left, Vector3 right) - { - return left.X > right.X - && left.Y > right.Y - && left.Z > right.Z; - } - - /// - /// Implements the operator >. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >(Vector3 left, float right) - { - return left.X > right - && left.Y > right - && left.Z > right; - } - - /// - /// Implements the operator >. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >(Vector3 left, int right) - { - return left.X > right - && left.Y > right - && left.Z > right; - } - - /// - /// Implements the operator <=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <=(Vector3 left, Vector3 right) - { - return left == right || left < right; - } - - /// - /// Implements the operator <=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <=(Vector3 left, float right) - { - return left == right || left < right; - } - - /// - /// Implements the operator <=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator <=(Vector3 left, int right) - { - return left == right || left < right; - } - - /// - /// Implements the operator >=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >=(Vector3 left, Vector3 right) - { - return left == right || left > right; - } - - /// - /// Implements the operator >=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >=(Vector3 left, float right) - { - return left == right || left > right; - } - - /// - /// Implements the operator >=. - /// - /// The left. - /// The right. - /// - /// The result of the operator. - /// - public static bool operator >=(Vector3 left, int right) - { - return left == right || left > right; - } - - /// - /// Distances the specified left. - /// - /// The left. - /// The right. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float Distance(Vector3 left, Vector3 right) - { - return left.DistanceTo(right); - } - - /// - /// Dots the product. - /// - /// The left. - /// The right. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static float DotProduct(Vector3 left, Vector3 right) - { - return left.DotProduct(right); - } - - /// - /// Crosses the product. - /// - /// The left. - /// The right. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public Vector3 CrossProduct(Vector3 left, Vector3 right) - { - return left.CrossProduct(right); - } - - /// - /// Lerps the specified left. - /// - /// The left. - /// The right. - /// The amount. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 Lerp(Vector3 left, Vector3 right, float amount) - { - return left.Lerp(right, amount); - } - - /// - /// Angles the clamp. - /// - /// The vec. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 AngleClamp(Vector3 vec) - { - var tmp = vec.Clone(); - tmp.AngleClamp(); - return tmp; - } - - /// - /// Angles the clamp. - /// - /// The vec. - /// The minimum. - /// The maximum. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 AngleClamp(Vector3 vec, float min, float max) - { - var tmp = vec.Clone(); - tmp.AngleClamp(min, max); - return tmp; - } - - /// - /// Angles the normalize. - /// - /// The vec. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 AngleNormalize(Vector3 vec) - { - var tmp = vec.Clone(); - tmp.AngleNormalize(); - return tmp; - } - - /// - /// Angles the normalize. - /// - /// The vec. - /// The minimum. - /// The maximum. - /// The norm. - /// - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Vector3 AngleNormalize(Vector3 vec, float min, float max, float norm) - { - var tmp = vec.Clone(); - tmp.AngleNormalize(min, max, norm); - return tmp; - } - } -} \ No newline at end of file diff --git a/Program.cs b/Program.cs index 12d08d5..3350217 100644 --- a/Program.cs +++ b/Program.cs @@ -1,7 +1,5 @@ using GTAVCSMM.Config; using GTAVCSMM.Helpers; -using GTAVCSMM.Memory; -using GTAVCSMM.Settings; using System; using System.Collections.Generic; using System.Diagnostics; @@ -11,12 +9,12 @@ using System.Threading; using System.Threading.Tasks; using System.Windows.Forms; -using GameMath; namespace GTAVCSMM { static class Program { + #region Program Init keys private const int WH_KEYBOARD_LL = 13; private const int WM_KEYDOWN = 0x0100; private static LowLevelKeyboardProc _proc = HookCallback; @@ -59,8 +57,6 @@ private static extern IntPtr CallNextHookEx(IntPtr hhk, int nCode, private static List pedList = new List(); private static List vehList = new List(); - #region WINDOW SETUP - public const string WINDOW_NAME = "Grand Theft Auto V"; public static IntPtr handle = FindWindow(null, WINDOW_NAME); @@ -84,18 +80,11 @@ public struct RECT public static extern bool GetWindowRect(IntPtr hwnd, out RECT IpRect); public static Offsets offsets = new Offsets(); - public static Addresses addresses = new Addresses(); public static Patterns pattern = new Patterns(); - public static TSettings settings = new TSettings(); public static Mem Mem; - public static System.Windows.Forms.Timer ProcessTimer = new System.Windows.Forms.Timer(); public static System.Windows.Forms.Timer MemoryTimer = new System.Windows.Forms.Timer(); public static System.Windows.Forms.Timer fastTimer = new System.Windows.Forms.Timer(); - - #endregion - - #region PROCESS INFO private static bool bGodMode = false; private static bool bgodState = false; private static bool bNeverWanted = false; @@ -109,6 +98,7 @@ public struct RECT private static int frameFlagCount = 0; private static bool bGetCasinoPrice = false; private static int casinoPrice = 0; + private static bool bCopKiller = false; [DllImport("user32.dll")] static extern short GetAsyncKeyState(System.Windows.Forms.Keys vKey); @@ -117,281 +107,90 @@ public struct RECT public static extern void mouse_event(int a, int b, int c, int d, int damnIwonderifpeopleactuallyreadsthis); #endregion - #region METHODS - public static void pGODMODE() - { - if (bGodMode) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oGod }, 1); - if (!settings.pgodm) - { - Activate(); - } - settings.pgodm = true; - } - else - { - if (settings.pgodm) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oGod }, 0); - settings.pgodm = false; - Deactivate(); - } - } - } - - public static void pNEVERWANTED() - { - if (bNeverWanted) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 0); - if (!settings.pnwanted) - { - Activate(); - } - settings.pnwanted = true; - } - else - { - if (settings.pnwanted) - { - settings.pnwanted = false; - Deactivate(); - } - } - } - - public static void pNORAGDOLL() - { - if (bNoRagdoll) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oRagdoll }, 1); - if (!settings.pnragdoll) - { - Activate(); - } - settings.pnragdoll = true; - } - else - { - if (settings.pnragdoll) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oRagdoll }, 32); - settings.pnragdoll = false; - Deactivate(); - } - } - } - - public static void pUNDEADOFFRADAR() - { - if (bUndeadOffRadar) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oHealthMax }, 0); - if (!settings.puoffradar) - { - Activate(); - } - settings.puoffradar = true; - } - else - { - if (settings.puoffradar) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oHealthMax }, 328f); - settings.puoffradar = false; - Deactivate(); - } - } - } - - public static void pSEATBELT() - { - if (bSeatBelt) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oSeatbelt }, -55); - if (!settings.psbelt) - { - Activate(); - } - settings.psbelt = true; - } - else - { - if (settings.psbelt) - { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oSeatbelt }, -56); - settings.psbelt = false; - Deactivate(); - } - } - } + #region Timers - public static void pSUPERJUMP() + private static void MemoryTimer_Tick(object sender, EventArgs e) { - if (bSuperJump) - { - if (!settings.psjump) - { - frameFlagCount = frameFlagCount + 64; - Activate(); - } - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); - settings.psjump = true; - } - else - { - if (settings.psjump) - { - frameFlagCount = frameFlagCount - 64; - Deactivate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); - settings.psjump = false; - } - } + pGODMODE(); + vGODMODE(); + vCOPKILLER(); } - public static void pEXPLOSIVEAMMO() + private static void fastTimer_Tick(object sender, EventArgs e) { - if (bExplosiveAmmo) - { - if (!settings.psexammo) - { - frameFlagCount = frameFlagCount + 8; - Activate(); - } - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); - settings.psexammo = true; - } - else - { - if (settings.psexammo) - { - frameFlagCount = frameFlagCount - 8; - Deactivate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); - settings.psexammo = false; - } - } + pNEVERWANTED(); + pNORAGDOLL(); + pUNDEADOFFRADAR(); + pSEATBELT(); + pDISABLECOLLISION(); + pSUPERJUMP(); + pEXPLOSIVEAMMO(); + cPRICE(); } - public static void pDISABLECOLLISION() - { - long paddr = Mem.ReadPointer(settings.WorldPTR, new int[] { offsets.pCPed, 0x30, 0x10, 0x20, 0x70, 0x0 }); - long paddr2 = Mem.GetPtrAddr(paddr + 0x2C, null); - if (bDisableCollision) - { - Mem.writeFloat(paddr2, null, -1.0f); - if (!settings.pdiscol) - { - Activate(); - } - settings.pdiscol = true; - } - else - { - if (settings.pdiscol) - { - Mem.writeFloat(paddr2, null, 0.25f); - settings.pdiscol = false; - Deactivate(); - } - } - } - public static void vGODMODE() - { - long paddr = Mem.ReadPointer(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle }); - if (paddr > 0) - { - long paddr2 = Mem.GetPtrAddr(paddr + offsets.oGod, null); - if (bVehicleGodMode) - { - Mem.writeInt(paddr2, null, 1); - if (!settings.vgodm) - { - Activate(); - } - settings.vgodm = true; - } - else - { - if (settings.vgodm) - { - Mem.writeInt(paddr2, null, 0); - settings.vgodm = false; - Deactivate(); - } - } - } - } - public static void cPRICE() - { - if (bGetCasinoPrice) - { - getLuckyWheelPrice(casinoPrice); - } - } + #endregion + #region System/Main public static void getPointer() { try { - Mem = new Mem(settings.gameName); + Mem = new Mem(Settings.gameName); - var processes = Process.GetProcessesByName(settings.gameName); + var processes = Process.GetProcessesByName(Settings.gameName); foreach (var p in processes) { if (p.Id > 0) { - settings.gameProcess = p.Id; + Settings.gameProcess = p.Id; } } - if (settings.gameProcess > 0) + if (Settings.gameProcess > 0) { // GlobalPTR long addr = Mem.FindPattern(pattern.GlobalPTR, pattern.GlobalPTR_Mask); - settings.GlobalPTR = addr + Mem.ReadInt(addr + 3, null) + 7; + Settings.GlobalPTR = addr + Mem.ReadInt(addr + 3, null) + 7; // WorldPTR long addr2 = Mem.FindPattern(pattern.WorldPTR, pattern.WorldPTR_Mask); - settings.WorldPTR = addr2 + Mem.ReadInt(addr2 + 3, null) + 7; + Settings.WorldPTR = addr2 + Mem.ReadInt(addr2 + 3, null) + 7; // BlipPTR long addr3 = Mem.FindPattern(pattern.BlipPTR, pattern.BlipPTR_Mask); - settings.BlipPTR = addr3 + Mem.ReadInt(addr3 + 3, null) + 7; + Settings.BlipPTR = addr3 + Mem.ReadInt(addr3 + 3, null) + 7; // ReplayInterfacePTR long addr4 = Mem.FindPattern(pattern.ReplayInterfacePTR, pattern.ReplayInterfacePTR_Mask); - settings.ReplayInterfacePTR = addr4 + Mem.ReadInt(addr4 + 3, null) + 7; + Settings.ReplayInterfacePTR = addr4 + Mem.ReadInt(addr4 + 3, null) + 7; // LocalScriptsPTR long addr5 = Mem.FindPattern(pattern.LocalScriptsPTR, pattern.LocalScriptsPTR_Mask); - settings.LocalScriptsPTR = addr5 + Mem.ReadInt(addr5 + 3, null) + 7; + Settings.LocalScriptsPTR = addr5 + Mem.ReadInt(addr5 + 3, null) + 7; // PlayerCountPTR long addr6 = Mem.FindPattern(pattern.PlayerCountPTR, pattern.PlayerCountPTR_Mask); - settings.PlayerCountPTR = addr6 + Mem.ReadInt(addr6 + 3, null) + 7; + Settings.PlayerCountPTR = addr6 + Mem.ReadInt(addr6 + 3, null) + 7; // PickupDataPTR long addr7 = Mem.FindPattern(pattern.PickupDataPTR, pattern.PickupDataPTR_Mask); - settings.PickupDataPTR = addr7 + Mem.ReadInt(addr7 + 3, null) + 7; + Settings.PickupDataPTR = addr7 + Mem.ReadInt(addr7 + 3, null) + 7; // WeatherADDR long addr8 = Mem.FindPattern(pattern.WeatherADDR, pattern.WeatherADDR_Mask); - settings.WeatherADDR = addr8 + Mem.ReadInt(addr8 + 6, null) + 10; + Settings.WeatherADDR = addr8 + Mem.ReadInt(addr8 + 6, null) + 10; // SettingsPTR long addr9 = Mem.FindPattern(pattern.SettingsPTR, pattern.SettingsPTR_Mask); - settings.SettingsPTR = addr9 + Mem.ReadInt(addr9 + 3, null) - Convert.ToInt64("0x89", 16); + Settings.SettingsPTR = addr9 + Mem.ReadInt(addr9 + 3, null) - Convert.ToInt64("0x89", 16); // AimCPedPTR long addr10 = Mem.FindPattern(pattern.AimCPedPTR, pattern.AimCPedPTR_Mask); - settings.AimCPedPTR = addr10 + Mem.ReadInt(addr10 + 3, null) + 7; + Settings.AimCPedPTR = addr10 + Mem.ReadInt(addr10 + 3, null) + 7; // FriendlistPTR long addr11 = Mem.FindPattern(pattern.FriendlistPTR, pattern.FriendlistPTR_Mask); - settings.FriendlistPTR = addr11 + Mem.ReadInt(addr11 + 3, null) + 7; + Settings.FriendlistPTR = addr11 + Mem.ReadInt(addr11 + 3, null) + 7; } else { @@ -405,36 +204,31 @@ public static void getPointer() Quit(); } } - #endregion - - - #region TIMERS - - private static void ProcessTimer_Tick(object sender, EventArgs e) - { - - } - - private static void MemoryTimer_Tick(object sender, EventArgs e) + public static string ShowDialog(string text, string caption) { - pGODMODE(); - pNEVERWANTED(); - pNORAGDOLL(); - pUNDEADOFFRADAR(); - pSEATBELT(); - pDISABLECOLLISION(); - vGODMODE(); - } + Form prompt = new Form() + { + Width = 500, + Height = 150, + FormBorderStyle = FormBorderStyle.FixedDialog, + Text = caption, + StartPosition = FormStartPosition.Manual, + Location = new Point(100, 100) + }; + Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = text }; + TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 }; + Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK }; + confirmation.Click += (sender, e) => { prompt.Close(); }; + prompt.Controls.Add(textBox); + prompt.Controls.Add(confirmation); + prompt.Controls.Add(textLabel); + prompt.AcceptButton = confirmation; + prompt.MaximizeBox = false; + prompt.MinimizeBox = false; + prompt.TopMost = true; - private static void fastTimer_Tick(object sender, EventArgs e) - { - pSUPERJUMP(); - pEXPLOSIVEAMMO(); - cPRICE(); + return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : ""; } - - #endregion - private static void Quit() { Environment.Exit(0); @@ -482,7 +276,6 @@ static void Main() listboxStyle(); listboxFill(0, 0); fastTimer.Enabled = true; - ProcessTimer.Enabled = true; MemoryTimer.Enabled = true; listBx.Enabled = true; @@ -532,14 +325,9 @@ public static void createMainForm() // // fastTimer // - fastTimer.Interval = 1; + fastTimer.Interval = 10; fastTimer.Tick += new System.EventHandler(fastTimer_Tick); // - // ProcessTimer - // - ProcessTimer.Interval = 100; - ProcessTimer.Tick += new System.EventHandler(ProcessTimer_Tick); - // // MemoryTimer // MemoryTimer.Interval = 100; @@ -577,7 +365,9 @@ public static void createMainForm() mainForm.Show(); } + #endregion + #region List strings public static void listboxStyle() { } @@ -748,6 +538,7 @@ public static void listboxFill(int mainMenulevel, int menulevel) listBx.Items.Add("Destroy Vehicles (Cops)"); listBx.Items.Add("Destroy Vehicles (All)"); listBx.Items.Add("Revive Vehicles"); + listBx.Items.Add("Cop Killer"); menuMainLvl = 1; menuLvl = 8; @@ -1055,7 +846,9 @@ public static void listboxFill(int mainMenulevel, int menulevel) listBx.SelectedIndex = 0; mainForm.TopMost = true; } + #endregion + #region List functions public static void runitem(int mainMenulevel, int menulevel, int menuItem) { int[] tpIdArray; @@ -1228,13 +1021,13 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) break; case 1: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oRange }, 250F); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oLockRange }, 250F); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oRange }, 250F); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oLockRange }, 250F); break; case 2: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oReloadMult }, 10F); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oReloadVehicleMult }, 10F); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oReloadMult }, 10F); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oReloadVehicleMult }, 10F); break; case 3: listboxFill(4, 2); @@ -1341,35 +1134,48 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) switch (menuItem) { case 0: + Activate(); kill_npcs(); break; case 1: + Activate(); kill_enemies(); break; case 2: + Activate(); kill_cops(); break; case 3: + Activate(); blind_cops(true); break; case 4: + Activate(); bribe_cops(true); break; case 5: + Activate(); destroy_vehs_of_npcs(); break; case 6: + Activate(); destroy_vehs_of_enemies(); break; case 7: + Activate(); destroy_vehs_of_cops(); break; case 8: + Activate(); destroy_all_vehicles(); break; case 9: + Activate(); revive_all_vehicles(); break; + case 10: + bCopKiller = !bCopKiller; + break; } break; @@ -1424,47 +1230,47 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) { case 0: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 0.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 0.0f); break; case 1: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 0.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 0.5f); break; case 2: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 1.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 1.0f); break; case 3: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 1.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 1.5f); break; case 4: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 2.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 2.0f); break; case 5: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 2.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 2.5f); break; case 6: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 3.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 3.0f); break; case 7: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 3.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 3.5f); break; case 8: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 4.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 4.0f); break; case 9: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 4.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 4.5f); break; case 10: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 5.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oSwimSpeed }, 5.0f); break; } break; @@ -1474,47 +1280,47 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) { case 0: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 0.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 0.0f); break; case 1: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 0.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 0.5f); break; case 2: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 1.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 1.0f); break; case 3: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 1.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 1.5f); break; case 4: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 2.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 2.0f); break; case 5: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 2.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 2.5f); break; case 6: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 3.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 3.0f); break; case 7: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 3.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 3.5f); break; case 8: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 4.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 4.0f); break; case 9: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 4.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 4.5f); break; case 10: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 5.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWalkSpeed }, 5.0f); break; } break; @@ -1524,47 +1330,47 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) { case 0: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 0.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 0.0f); break; case 1: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 0.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 0.5f); break; case 2: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 1.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 1.0f); break; case 3: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 1.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 1.5f); break; case 4: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 2.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 2.0f); break; case 5: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 2.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 2.5f); break; case 6: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 3.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 3.0f); break; case 7: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 3.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 3.5f); break; case 8: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 4.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 4.0f); break; case 9: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 4.5f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 4.5f); break; case 10: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 5.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oRunSpeed }, 5.0f); break; } break; @@ -1574,27 +1380,27 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) { case 0: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 0); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 0); break; case 1: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 1); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 1); break; case 2: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 2); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 2); break; case 3: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 3); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 3); break; case 4: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 4); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 4); break; case 5: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 5); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 5); break; } break; @@ -1609,51 +1415,51 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) { case 0: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 1.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 1.0f); break; case 1: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 2.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 2.0f); break; case 2: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 3.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 3.0f); break; case 3: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 5.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 5.0f); break; case 4: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 10.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 10.0f); break; case 5: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 20.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 20.0f); break; case 6: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 30.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 30.0f); break; case 7: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 50.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 50.0f); break; case 8: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 100.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 100.0f); break; case 9: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 200.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 200.0f); break; case 10: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 30.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 30.0f); break; case 11: Activate(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 500.0f); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPedWeaponManager, offsets.pCWeaponInfo, offsets.oDamage }, 500.0f); break; } break; @@ -2496,7 +2302,9 @@ public static void runitem(int mainMenulevel, int menulevel, int menuItem) } } + #endregion + #region Keyboard hooks public static void runSingleItem() { Console.WriteLine("Command to run backward: " + LastMenuMainLvl + " " + LastMenuLvl + " " + LastMenuItm); @@ -2614,247 +2422,252 @@ private static IntPtr HookCallback( /* * Development */ - to_blip(new int[] { 819 }); } } } return CallNextHookEx(_hookID, nCode, wParam, lParam); } + #endregion - public static void LoadSession(int id) + #region Methods + public static void pGODMODE() { - Task.Run(() => + if (bGodMode) { - SG(1575012, id); - SG(1574589 + 2, id == -1 ? -1 : 0); - SG(1574589, 1); - }); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oGod }, 1); + if (!Settings.pgodm) + { + Activate(); + } + Settings.pgodm = true; + } + else + { + if (Settings.pgodm) + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oGod }, 0); + Settings.pgodm = false; + Deactivate(); + } + } } - public static void getLuckyWheelPrice(int id) + public static void pNEVERWANTED() { - string script = "casino_lucky_wheel"; - int Index = 274 + 14; - long scriptAddr = GetLocalScript(script); - if (scriptAddr > 0 && id > 0) + if (bNeverWanted) { - long scriptAddr2 = scriptAddr + (8 * Index); - Console.WriteLine(scriptAddr2); - int scriptInt = Mem.ReadInt(scriptAddr2, null); - Console.WriteLine(scriptInt); - Mem.writeInt(scriptAddr2, null, id); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oWanted }, 0); + if (!Settings.pnwanted) + { + Activate(); + } + Settings.pnwanted = true; + } + else + { + if (Settings.pnwanted) + { + Settings.pnwanted = false; + Deactivate(); + } } - } - public static void setRPMultipler(float m) - { - SG(262145 + 1, m); } - public static void setREPMultipler(float m) + public static void pNORAGDOLL() { - SG(262145 + 31294, m); // Street Race - old 31278 + 16 for 1.60 - SG(262145 + 31295, m); // Pursuit Race - SG(262145 + 31296, m); // Scramble - SG(262145 + 31297, m); // Head 2 Head - SG(262145 + 31289, m); // Car Meet - SG(262145 + 31300, m); // Test Track - SG(262145 + 31328, m); // Auto Shop Contract - SG(262145 + 31329, m); // Customer Deliveries - SG(262145 + 31330, m); // Exotic Exports Deliveries + if (bNoRagdoll) + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oRagdoll }, 1); + if (!Settings.pnragdoll) + { + Activate(); + } + Settings.pnragdoll = true; + } + else + { + if (Settings.pnragdoll) + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oRagdoll }, 32); + Settings.pnragdoll = false; + Deactivate(); + } + } } - #region Teleport part - private static void Teleport(Location l) + public static void pUNDEADOFFRADAR() { - if (Mem.ReadInt(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oInVehicle }) == 0) + if (bUndeadOffRadar) { - CarX = l.x; - CarY = l.y; - CarZ = l.z; + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oHealthMax }, 0); + if (!Settings.puoffradar) + { + Activate(); + } + Settings.puoffradar = true; } else { - PlayerX = l.x; - PlayerY = l.y; - PlayerZ = l.z; + if (Settings.puoffradar) + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oHealthMax }, 328f); + Settings.puoffradar = false; + Deactivate(); + } } } - private static void teleportBlip(int[] ID, int[] color, int height = 0) + public static void pSEATBELT() { - Location tmpLoc = getBlipCoords(ID, color, height); - if (tmpLoc.x != 0 && tmpLoc.y != 0) + if (bSeatBelt) { - Teleport(tmpLoc); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oSeatbelt }, -55); + if (!Settings.psbelt) + { + Activate(); + } + Settings.psbelt = true; } else { - Console.WriteLine("No TP, wrong coords (x, y)."); + if (Settings.psbelt) + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oSeatbelt }, -56); + Settings.psbelt = false; + Deactivate(); + } } } - private static Location getBlipCoords(int[] id, int[] color = null, int height = 0) + public static void pSUPERJUMP() { - float zOffset = 0; - Location tempLocation = new Location() { }; - for (int i = 2000; i > 1; i--) + if (bSuperJump) { - long blip = settings.BlipPTR + (i * 8); - int blipId = Mem.ReadInt(blip, new int[] { 0x40 }); - int blipColor = Mem.ReadInt(blip, new int[] { 0x48 }); - if (id != null && id.Contains(blipId)) + if (!Settings.psjump) { - zOffset = (float)(Math.Round(Math.Pow(i, -0.2), 1) * height); - tempLocation = new Location - { - x = Mem.ReadFloat(blip, new int[] { 0x10 }), - y = Mem.ReadFloat(blip, new int[] { 0x14 }), - z = Mem.ReadFloat(blip, new int[] { 0x18 }) - }; - - if (color != null && color.Contains(blipColor)) - { - tempLocation = new Location - { - x = Mem.ReadFloat(blip, new int[] { 0x10 }), - y = Mem.ReadFloat(blip, new int[] { 0x14 }), - z = Mem.ReadFloat(blip, new int[] { 0x18 }) - }; - } + frameFlagCount = frameFlagCount + 64; + Activate(); } + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); + Settings.psjump = true; } - if (tempLocation.z == 20) - { - tempLocation.z = -255F; - } else + else { - tempLocation.z = tempLocation.z + zOffset; + if (Settings.psjump) + { + frameFlagCount = frameFlagCount - 64; + Deactivate(); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); + Settings.psjump = false; + } } - - Console.WriteLine("New location: " + tempLocation.x + ", " + tempLocation.y + ", " + tempLocation.z); - return new Location { x = tempLocation.x, y = tempLocation.y, z = tempLocation.z }; } - public static float PlayerX + public static void pEXPLOSIVEAMMO() { - get { return Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionX }); } - set + if (bExplosiveAmmo) { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionX }, value); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oVisualX }, value); + if (!Settings.psexammo) + { + frameFlagCount = frameFlagCount + 8; + Activate(); + } + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); + Settings.psexammo = true; } - } - public static float PlayerY - { - get { return Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionY }); } - set + else { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionY }, value); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oVisualY }, value); + if (Settings.psexammo) + { + frameFlagCount = frameFlagCount - 8; + Deactivate(); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCPlayerInfo, offsets.oFrameFlags }, frameFlagCount); + Settings.psexammo = false; + } } } - public static float PlayerZ + public static void pDISABLECOLLISION() { - get { return Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionZ }); } - set + long paddr = Mem.ReadPointer(Settings.WorldPTR, new int[] { offsets.pCPed, 0x30, 0x10, 0x20, 0x70, 0x0 }); + long paddr2 = Mem.GetPtrAddr(paddr + 0x2C, null); + + if (bDisableCollision) { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionZ }, value); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.oVisualZ }, value); + Mem.writeFloat(paddr2, null, -1.0f); + if (!Settings.pdiscol) + { + Activate(); + } + Settings.pdiscol = true; } - } - - public static float CarX - { - get { return Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionX }); } - set + else { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionX }, value); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.oVisualX }, value); + if (Settings.pdiscol) + { + Mem.writeFloat(paddr2, null, 0.25f); + Settings.pdiscol = false; + Deactivate(); + } } } - public static float CarY + public static void vGODMODE() { - get { return Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionY }); } - set + long paddr = Mem.ReadPointer(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle }); + if (paddr > 0) { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionY }, value); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.oVisualY }, value); + long paddr2 = Mem.GetPtrAddr(paddr + offsets.oGod, null); + if (bVehicleGodMode) + { + Mem.writeInt(paddr2, null, 1); + if (!Settings.vgodm) + { + Activate(); + } + Settings.vgodm = true; + } + else + { + if (Settings.vgodm) + { + Mem.writeInt(paddr2, null, 0); + Settings.vgodm = false; + Deactivate(); + } + } } } - public static float CarZ + public static void vCOPKILLER() { - get { return Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionZ }); } - set + if (bCopKiller) { - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionZ }, value); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.oVisualZ }, value); + if (!Settings.cKiller) + { + Settings.cKiller = true; + Activate(); + } + kill_cops(); } - } - #endregion - - #region Global Addresses function - public static T GG(int index) where T : struct { return Mem.Read(GA(index)); } - - public static void SG(int index, T vaule) where T : struct { Mem.Write(GA(index), vaule); } - - public static long GA(int Index) - { - long p = settings.GlobalPTR + (8 * (Index >> 0x12 & 0x3F)); - long p_ga = Mem.ReadPointer(p, null); - long p_ga_final = p_ga + (8 * (Index & 0x3FFFF)); - return p_ga_final; - } - - public static void setStat(string stat, int value) - { - uint Stat_ResotreHash = GG(1655453 + 4); - int Stat_ResotreValue = GG(1020252 + 5526); - Console.WriteLine(Stat_ResotreHash + " " + Stat_ResotreValue); - SG(1655453 + 4, Joaat(stat)); - SG(1020252 + 5526, value); - SG(1644218 + 1139, -1); - Thread.Sleep(1000); - SG(1655453 + 4, Stat_ResotreHash); - SG(1020252 + 5526, Stat_ResotreValue); - } - public static uint Joaat(string input) - { - uint num1 = 0U; - input = input.ToLower(); - foreach (char c in input) + else { - uint num2 = num1 + c; - uint num3 = num2 + (num2 << 10); - num1 = num3 ^ num3 >> 6; + if (Settings.cKiller) + { + Settings.cKiller = false; + Deactivate(); + } } - uint num4 = num1 + (num1 << 3); - uint num5 = num4 ^ num4 >> 11; - - return num5 + (num5 << 15); } - #endregion - public static long GetLocalScript(string name) + public static void cPRICE() { - int size = name.Length; - for (int i = 0; i <= 52; i++) + if (bGetCasinoPrice) { - long lc_p = Mem.ReadPointer(settings.LocalScriptsPTR, new int[] { (i * 8), 0xB0 }); - string lc_n = Mem.ReadString(settings.LocalScriptsPTR, new int[] { (i * 8), 0xD0 }, size); - if (lc_n == name) - { - i = 53; - Console.WriteLine(lc_p); - return (lc_p); - } + getLuckyWheelPrice(casinoPrice); } - return 0; } - public static void carSpawn(string Hash, int pegasus = 0) { string model = Hash.ToLower(); - float ped_heading = Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oHeading }); - float ped_heading2 = Mem.ReadFloat(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oHeading2 }); + float ped_heading = Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oHeading }); + float ped_heading2 = Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oHeading2 }); Console.WriteLine(ped_heading + " " + ped_heading2); float spawner_x = PlayerX; float spawner_y = PlayerY; @@ -2934,54 +2747,77 @@ public static void carSpawn(string Hash, int pegasus = 0) SG(offsets.oVMCreate + 27 + 20, weapon2); // primary weapon // _SG_Int(offsets.oVMCreate + 27 + 1, "FCK4FD"); // License plate } - public static string ShowDialog(string text, string caption) + + public static void LoadSession(int id) { - Form prompt = new Form() + Task.Run(() => { - Width = 500, - Height = 150, - FormBorderStyle = FormBorderStyle.FixedDialog, - Text = caption, - StartPosition = FormStartPosition.Manual, - Location = new Point(100, 100) - }; - Label textLabel = new Label() { Left = 50, Top = 20, Width = 400, Text = text }; - TextBox textBox = new TextBox() { Left = 50, Top = 50, Width = 400 }; - Button confirmation = new Button() { Text = "Ok", Left = 350, Width = 100, Top = 70, DialogResult = DialogResult.OK }; - confirmation.Click += (sender, e) => { prompt.Close(); }; - prompt.Controls.Add(textBox); - prompt.Controls.Add(confirmation); - prompt.Controls.Add(textLabel); - prompt.AcceptButton = confirmation; - prompt.MaximizeBox = false; - prompt.MinimizeBox = false; - prompt.TopMost = true; + SG(1575012, id); + SG(1574589 + 2, id == -1 ? -1 : 0); + SG(1574589, 1); + }); + } + public static void empty_session() + { + Task.Run(() => + { + ProcessMgr.SuspendProcess(Settings.gameProcess); + Task.Delay(10000).Wait(); + ProcessMgr.ResumeProcess(Settings.gameProcess); + }); + } - return prompt.ShowDialog() == DialogResult.OK ? textBox.Text : ""; + public static void getLuckyWheelPrice(int id) + { + string script = "casino_lucky_wheel"; + int Index = 274 + 14; + long scriptAddr = GetLocalScript(script); + if (scriptAddr > 0 && id > 0) + { + long scriptAddr2 = scriptAddr + (8 * Index); + Console.WriteLine(scriptAddr2); + int scriptInt = Mem.ReadInt(scriptAddr2, null); + Console.WriteLine(scriptInt); + Mem.writeInt(scriptAddr2, null, id); + } + } + public static void setRPMultipler(float m) + { + SG(262145 + 1, m); } - /* - * Development - */ + public static void setREPMultipler(float m) + { + SG(262145 + 31294, m); // Street Race - old 31278 + 16 for 1.60 + SG(262145 + 31295, m); // Pursuit Race + SG(262145 + 31296, m); // Scramble + SG(262145 + 31297, m); // Head 2 Head + SG(262145 + 31289, m); // Car Meet + SG(262145 + 31300, m); // Test Track + SG(262145 + 31328, m); // Auto Shop Contract + SG(262145 + 31329, m); // Customer Deliveries + SG(262145 + 31330, m); // Exotic Exports Deliveries + } public static void getPeds() { int pedListOffset = 0x10; - int count = Mem.ReadInt(settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.oPedNum }); + int count = Mem.ReadInt(Settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.oPedNum }); for (int i = 0; i <= count; i++) { - long Ped = Mem.ReadPointer(settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.pPedList, (i * pedListOffset) }); - int pedType = Mem.ReadByte(settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.pPedList, (i * pedListOffset), offsets.oEntityType }); - if (pedType != 156 && Mem.IsValid(Ped)) { + long Ped = Mem.ReadPointer(Settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.pPedList, (i * pedListOffset) }); + int pedType = Mem.ReadByte(Settings.ReplayInterfacePTR, new int[] { offsets.pCPedInterface, offsets.pPedList, (i * pedListOffset), offsets.oEntityType }); + if (pedType != 156 && Mem.IsValid(Ped)) + { pedList.Add(Ped); } } } public static void getVehs() { - int count = Mem.ReadInt(settings.ReplayInterfacePTR, new int[] { offsets.pCVehicleInterface, offsets.oVehNum }); + int count = Mem.ReadInt(Settings.ReplayInterfacePTR, new int[] { offsets.pCVehicleInterface, offsets.oVehNum }); for (int i = 0; i <= count; i++) { - long Veh = Mem.ReadPointer(settings.ReplayInterfacePTR, new int[] { offsets.pCVehicleInterface, offsets.pVehList, (i * 0x10) }); + long Veh = Mem.ReadPointer(Settings.ReplayInterfacePTR, new int[] { offsets.pCVehicleInterface, offsets.pVehList, (i * 0x10) }); if (Mem.IsValid(Veh)) { vehList.Add(Veh); @@ -3022,26 +2858,17 @@ public static void set_mc_produce_time(int produce_time, bool toggle) SG(262145 + 17211, toggle ? 1 : 360000); // Meth Staff SG(262145 + 17212, toggle ? 1 : 60000); // Weed Staff } - public static void empty_session() - { - Task.Run(() => - { - ProcessMgr.SuspendProcess(settings.gameProcess); - Task.Delay(10000).Wait(); - ProcessMgr.ResumeProcess(settings.gameProcess); - }); - } public static void setWeaponUnlimitedAmmo() { Task.Run(() => { - ProcessMgr.SuspendProcess(settings.gameProcess); + ProcessMgr.SuspendProcess(Settings.gameProcess); Task.Delay(20).Wait(); - Mem.Write(settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCWeaponInventory, offsets.oAmmoModifier }, 1); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCWeaponInventory, offsets.oAmmoModifier }, 1); Task.Delay(20).Wait(); Activate(); - ProcessMgr.ResumeProcess(settings.gameProcess); + ProcessMgr.ResumeProcess(Settings.gameProcess); }); } @@ -3049,7 +2876,6 @@ public static void kill_npcs() { Task.Run(() => { - Activate(); getPeds(); for (int i = 0; i < pedList.Count; i++) { @@ -3059,12 +2885,11 @@ public static void kill_npcs() } }); } - + public static void kill_enemies() { Task.Run(() => { - Activate(); getPeds(); for (int i = 0; i < pedList.Count; i++) { @@ -3081,7 +2906,6 @@ public static void kill_cops() { Task.Run(() => { - Activate(); getPeds(); for (int i = 0; i < pedList.Count; i++) { @@ -3101,7 +2925,6 @@ public static void blind_cops(bool toggle = true) { Task.Run(() => { - Activate(); SG(offsets.oVMYCar + 4625, toggle ? 1 : 0); if (toggle) SG(offsets.oVMYCar + 4627, get_network_time() + 3600000); SG(offsets.oVMYCar + 4624, toggle ? 5 : 0); @@ -3112,7 +2935,6 @@ public static void bribe_cops(bool toggle = true) { Task.Run(() => { - Activate(); SG(offsets.oVMYCar + 4625, toggle ? 1 : 0); if (toggle) SG(offsets.oVMYCar + 4627, get_network_time() + 3600000); SG(offsets.oVMYCar + 4624, toggle ? 21 : 0); @@ -3123,7 +2945,6 @@ public static void destroy_vehicle(long vehicle) { Task.Run(() => { - Activate(); revive_vehicle(vehicle); set_health3(vehicle, -999.9f); }); @@ -3132,7 +2953,6 @@ public static void destroy_vehs_of_npcs() { Task.Run(() => { - Activate(); getPeds(); for (int i = 0; i < pedList.Count; i++) { @@ -3146,7 +2966,6 @@ public static void destroy_vehs_of_enemies() { Task.Run(() => { - Activate(); getPeds(); for (int i = 0; i < pedList.Count; i++) { @@ -3160,7 +2979,6 @@ public static void destroy_vehs_of_cops() { Task.Run(() => { - Activate(); getPeds(); for (int i = 0; i < pedList.Count; i++) { @@ -3177,7 +2995,6 @@ public static void destroy_all_vehicles() { Task.Run(() => { - Activate(); getVehs(); for (int i = 0; i < vehList.Count; i++) { @@ -3190,7 +3007,6 @@ public static void revive_all_vehicles() { Task.Run(() => { - Activate(); getVehs(); for (int i = 0; i < vehList.Count; i++) { @@ -3226,7 +3042,7 @@ public static void fill_all_ammo() public static bool is_enemy(long ped) { return ((get_hostility(ped) > 1) ? true : false); } public static uint get_pedtype(long ped) { return Mem.Read(ped + 0x10B8) << 11 >> 25; } public static void set_health(long ped, float value) { Mem.Write(ped + 0x280, value); } - public static long get_local_ped() { return Mem.ReadPointer(settings.WorldPTR, new int[] { 0x8 }); } + public static long get_local_ped() { return Mem.ReadPointer(Settings.WorldPTR, new int[] { 0x8 }); } public static long get_ped_inventory(long ped) { return Mem.Read(ped + 0x10D0); } public static bool is_in_vehicle(long ped) { return ((Mem.Read(ped + 0xE52) == 1) ? true : false); } @@ -3252,71 +3068,198 @@ public static void revive_vehicle(long vehicle) set_health3(vehicle, 1000.0f); set_engine_health(vehicle, 1000.0f); } - public static void set_position(long entity, Vector3 pos) + #endregion + + #region Teleport part + private static void Teleport(Location l) { - set_real_position(entity, pos); - set_visual_position(entity, pos); + if (Mem.ReadInt(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oInVehicle }) == 0) + { + CarX = l.x; + CarY = l.y; + CarZ = l.z; + } + else + { + PlayerX = l.x; + PlayerY = l.y; + PlayerZ = l.z; + } } - public static void set_real_position(long entity, Vector3 pos) { nav_set_real_position(get_navigation(entity), pos); } - public static void set_visual_position(long entity, Vector3 pos) { Mem.Write(entity + 0x90, pos); } - public static void nav_set_real_position(long navigation, Vector3 pos) { Mem.Write(navigation + 0x50, pos); } - #region Vector3 - public static long get_blip(int[] icons, int[] colors = null) + private static void teleportBlip(int[] ID, int[] color, int height = 0) { - for (int i = 1; i < 2001; i++) + Location tmpLoc = getBlipCoords(ID, color, height); + if (tmpLoc.x != 0 && tmpLoc.y != 0) { - long p = Mem.ReadPointer(settings.BlipPTR + i * 0x8, null); - if (p == 0) continue; - int icon = Mem.Read(p + 0x40); - int color = Mem.Read(p + 0x48); - if (Array.IndexOf(icons, icon) == -1) continue; - if (colors != null && Array.IndexOf(colors, color) == -1) continue; - return p; + Teleport(tmpLoc); + } + else + { + Console.WriteLine("No TP, wrong coords (x, y)."); } - return 0; } - public static Vector3 get_blip_pos(int[] icons, int[] colors = null) + private static Location getBlipCoords(int[] id, int[] color = null, int height = 0) { - long blip = get_blip(icons, colors); - return ((blip == 0) ? new Vector3() : Mem.Read(blip + 0x10)); + float zOffset = 0; + Location tempLocation = new Location() { }; + for (int i = 2000; i > 1; i--) + { + long blip = Settings.BlipPTR + (i * 8); + int blipId = Mem.ReadInt(blip, new int[] { 0x40 }); + int blipColor = Mem.ReadInt(blip, new int[] { 0x48 }); + if (id != null && id.Contains(blipId)) + { + zOffset = (float)(Math.Round(Math.Pow(i, -0.2), 1) * height); + tempLocation = new Location + { + x = Mem.ReadFloat(blip, new int[] { 0x10 }), + y = Mem.ReadFloat(blip, new int[] { 0x14 }), + z = Mem.ReadFloat(blip, new int[] { 0x18 }) + }; + + if (color != null && color.Contains(blipColor)) + { + tempLocation = new Location + { + x = Mem.ReadFloat(blip, new int[] { 0x10 }), + y = Mem.ReadFloat(blip, new int[] { 0x14 }), + z = Mem.ReadFloat(blip, new int[] { 0x18 }) + }; + } + } + } + if (tempLocation.z == 20) + { + tempLocation.z = -255F; + } else + { + tempLocation.z = tempLocation.z + zOffset; + } + + Console.WriteLine("New location: " + tempLocation.x + ", " + tempLocation.y + ", " + tempLocation.z); + return new Location { x = tempLocation.x, y = tempLocation.y, z = tempLocation.z }; } - public static void to_waypoint() + public static float PlayerX { - Vector3 pos = get_blip_pos(new int[] { 8 }, new int[] { 84 }); - if (pos.X == 0.0f && pos.Y == 0.0f && pos.Z == 0.0f) return; - pos.Z = pos.Z == 20.0f ? -255.0f : pos.Z + 1.0f; - to_coords(get_local_ped(), pos); + get { return Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionX }); } + set + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionX }, value); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oVisualX }, value); + } } - - public static void to_objective() + public static float PlayerY { - Vector3 pos = get_blip_pos(new int[] { 1 }, new int[] { 5, 60, 66 }); - if (pos.X == 0.0f && pos.Y == 0.0f && pos.Z == 0.0f) pos = get_blip_pos(new int[] { 1, 225, 427, 478, 501, 523, 556 }, new int[] { 1, 2, 3, 54, 78 }); - if (pos.X == 0.0f && pos.Y == 0.0f && pos.Z == 0.0f) pos = get_blip_pos(new int[] { 432, 443 }, new int[] { 59 }); - to_coords_with_check(get_local_ped(), pos); + get { return Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionY }); } + set + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionY }, value); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oVisualY }, value); + } + } + public static float PlayerZ + { + get { return Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionZ }); } + set + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCNavigation, offsets.oPositionZ }, value); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.oVisualZ }, value); + } } - public static void to_blip(int[] icons, int[] colors = null) + public static float CarX + { + get { return Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionX }); } + set + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionX }, value); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.oVisualX }, value); + } + } + public static float CarY + { + get { return Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionY }); } + set + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionY }, value); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.oVisualY }, value); + } + } + public static float CarZ { - Vector3 pos = get_blip_pos(icons, colors); - to_coords_with_check(get_local_ped(), pos); + get { return Mem.ReadFloat(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionZ }); } + set + { + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.pCNavigation, offsets.oPositionZ }, value); + Mem.Write(Settings.WorldPTR, new int[] { offsets.pCPed, offsets.pCVehicle, offsets.oVisualZ }, value); + } } + #endregion - public static void to_coords(long ped, Vector3 pos) + #region Global Addresses function + public static T GG(int index) where T : struct { return Mem.Read(GA(index)); } + + public static void SG(int index, T vaule) where T : struct { Mem.Write(GA(index), vaule); } + + public static long GA(int Index) { - long entity = (is_in_vehicle(ped) ? get_current_vehicle(ped) : ped); - set_position(entity, pos); + long p = Settings.GlobalPTR + (8 * (Index >> 0x12 & 0x3F)); + long p_ga = Mem.ReadPointer(p, null); + long p_ga_final = p_ga + (8 * (Index & 0x3FFFF)); + return p_ga_final; } + #endregion - public static void to_coords_with_check(long ped, Vector3 pos) + #region Stat function + public static void setStat(string stat, int value) + { + uint Stat_ResotreHash = GG(1655453 + 4); + int Stat_ResotreValue = GG(1020252 + 5526); + Console.WriteLine(Stat_ResotreHash + " " + Stat_ResotreValue); + SG(1655453 + 4, Joaat(stat)); + SG(1020252 + 5526, value); + SG(1644218 + 1139, -1); + Thread.Sleep(1000); + SG(1655453 + 4, Stat_ResotreHash); + SG(1020252 + 5526, Stat_ResotreValue); + } + public static uint Joaat(string input) { - if (pos.X == 0.0f && pos.Y == 0.0f && pos.Z == 0.0f) return; - to_coords(ped, pos); + uint num1 = 0U; + input = input.ToLower(); + foreach (char c in input) + { + uint num2 = num1 + c; + uint num3 = num2 + (num2 << 10); + num1 = num3 ^ num3 >> 6; + } + uint num4 = num1 + (num1 << 3); + uint num5 = num4 ^ num4 >> 11; + + return num5 + (num5 << 15); } + #endregion + #region Local Script function + public static long GetLocalScript(string name) + { + int size = name.Length; + for (int i = 0; i <= 52; i++) + { + long lc_p = Mem.ReadPointer(Settings.LocalScriptsPTR, new int[] { (i * 8), 0xB0 }); + string lc_n = Mem.ReadString(Settings.LocalScriptsPTR, new int[] { (i * 8), 0xD0 }, size); + if (lc_n == name) + { + i = 53; + Console.WriteLine(lc_p); + return (lc_p); + } + } + return 0; + } #endregion } struct Location { public float x, y, z; } diff --git a/Settings/Addresses.cs b/Settings/Addresses.cs deleted file mode 100644 index 2d61d87..0000000 --- a/Settings/Addresses.cs +++ /dev/null @@ -1,85 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace GTAVCSMM.Settings -{ - class Addresses - { - private string _f_godm = "0x0"; - private string _f_nwanted = "0x0"; - private string _f_nragdoll = "0x0"; - private string _f_uoffradar = "0x0"; - private string _f_sbelt = "0x0"; - private string _f_sjump = "0x0"; - - public string f_godm - { - get - { - return _f_godm; - } - set - { - _f_godm = value; - } - } - public string f_nwanted - { - get - { - return _f_nwanted; - } - set - { - _f_nwanted = value; - } - } - public string f_nragdoll - { - get - { - return _f_nragdoll; - } - set - { - _f_nragdoll = value; - } - } - public string f_uoffradar - { - get - { - return _f_uoffradar; - } - set - { - _f_uoffradar = value; - } - } - public string f_sbelt - { - get - { - return _f_sbelt; - } - set - { - _f_sbelt = value; - } - } - public string f_sjump - { - get - { - return _f_sjump; - } - set - { - _f_sjump = value; - } - } - } -} diff --git a/Settings/TSettings.cs b/Settings/TSettings.cs deleted file mode 100644 index 499dd5f..0000000 --- a/Settings/TSettings.cs +++ /dev/null @@ -1,660 +0,0 @@ -namespace GTAVCSMM.Settings -{ - class TSettings - { - #region Globals - private string _gameName = "GTA5"; - private int _gameProcess = 0; - private long _globalptr; - private long _worldptr; - private long _blipptr; - private long _replayinterfaceptr; - private long _localscriptsptr; - private long _playercountptr; - private long _pickupdataptr; - private long _weatheraddr; - private long _settingsptr; - private long _aimcpedptr; - private long _friendlistptr; - - public string gameName - { - get - { - return _gameName; - } - } - - public int gameProcess - { - get - { - return _gameProcess; - } - set - { - _gameProcess = value; - } - } - - public long GlobalPTR - { - get - { - return _globalptr; - } - set - { - _globalptr = value; - } - } - - public long WorldPTR - { - get - { - return _worldptr; - } - set - { - _worldptr = value; - } - } - - public long BlipPTR - { - get - { - return _blipptr; - } - set - { - _blipptr = value; - } - } - - public long ReplayInterfacePTR - { - get - { - return _replayinterfaceptr; - } - set - { - _replayinterfaceptr = value; - } - } - - public long LocalScriptsPTR - { - get - { - return _localscriptsptr; - } - set - { - _localscriptsptr = value; - } - } - - public long PlayerCountPTR - { - get - { - return _playercountptr; - } - set - { - _playercountptr = value; - } - } - - public long PickupDataPTR - { - get - { - return _pickupdataptr; - } - set - { - _pickupdataptr = value; - } - } - - public long WeatherADDR - { - get - { - return _weatheraddr; - } - set - { - _weatheraddr = value; - } - } - - public long SettingsPTR - { - get - { - return _settingsptr; - } - set - { - _settingsptr = value; - } - } - - public long AimCPedPTR - { - get - { - return _aimcpedptr; - } - set - { - _aimcpedptr = value; - } - } - - public long FriendlistPTR - { - get - { - return _friendlistptr; - } - set - { - _friendlistptr = value; - } - } - #endregion - - #region Trainer settings - private int _aConnect = 0; - private int _aFKtoggle = 0; - private int _aGodMode = 0; - private int _aLogPlayers = 0; - private int _aDarkMode = 0; - private int _player_tracking = 0; - //tbl_origPlayersList = {} - private int _pictureGrabOFF = 0; - //player_watch = {} - //tbl_Players = {} - //tbl_PlayersAll = {} - //tbl_Tracking = {} - private int _markMyRid = -1; - private int _myCPed = -1; - - private bool _GlobalPTRFound = false; - private bool _WorldPTRFound = false; - private bool _BlipPTRFound = false; - private bool _ReplayInterfacePTRFound = false; - private bool _LocalScriptsPTRFound = false; - private bool _PlayerCountPTRFound = false; - private bool _PickupDataPTRFound = false; - private bool _WeatherADDRFound = false; - private bool _SettingsPTRFound = false; - private bool _AimCPedPTRFound = false; - private bool _FriendlistPTRFound = false; - - public int aConnect - { - get - { - return _aConnect; - } - set - { - _aConnect = value; - } - } - - public int aFKtoggle - { - get - { - return _aFKtoggle; - } - set - { - _aFKtoggle = value; - } - } - - public int aGodMode - { - get - { - return _aGodMode; - } - set - { - _aGodMode = value; - } - } - - public int aLogPlayers - { - get - { - return _aLogPlayers; - } - set - { - _aLogPlayers = value; - } - } - - public int aDarkMode - { - get - { - return _aDarkMode; - } - set - { - _aDarkMode = value; - } - } - - public int player_tracking - { - get - { - return _player_tracking; - } - set - { - _player_tracking = value; - } - } - - public int pictureGrabOFF - { - get - { - return _pictureGrabOFF; - } - set - { - _pictureGrabOFF = value; - } - } - - public int markMyRid - { - get - { - return _markMyRid; - } - set - { - _markMyRid = value; - } - } - - public int myCPed - { - get - { - return _myCPed; - } - set - { - _myCPed = value; - } - } - - public bool GlobalPTRFound - { - get - { - return _GlobalPTRFound; - } - set - { - _GlobalPTRFound = value; - } - } - - public bool WorldPTRFound - { - get - { - return _WorldPTRFound; - } - set - { - _WorldPTRFound = value; - } - } - - public bool BlipPTRFound - { - get - { - return _BlipPTRFound; - } - set - { - _BlipPTRFound = value; - } - } - - public bool ReplayInterfacePTRFound - { - get - { - return _ReplayInterfacePTRFound; - } - set - { - _ReplayInterfacePTRFound = value; - } - } - - public bool LocalScriptsPTRFound - { - get - { - return _LocalScriptsPTRFound; - } - set - { - _LocalScriptsPTRFound = value; - } - } - - public bool PlayerCountPTRFound - { - get - { - return _PlayerCountPTRFound; - } - set - { - _PlayerCountPTRFound = value; - } - } - - public bool PickupDataPTRFound - { - get - { - return _PickupDataPTRFound; - } - set - { - _PickupDataPTRFound = value; - } - } - - public bool WeatherADDRFound - { - get - { - return _WeatherADDRFound; - } - set - { - _WeatherADDRFound = value; - } - } - - public bool SettingsPTRFound - { - get - { - return _SettingsPTRFound; - } - set - { - _SettingsPTRFound = value; - } - } - - public bool AimCPedPTRFound - { - get - { - return _AimCPedPTRFound; - } - set - { - _AimCPedPTRFound = value; - } - } - - public bool FriendlistPTRFound - { - get - { - return _FriendlistPTRFound; - } - set - { - _FriendlistPTRFound = value; - } - } - #endregion - - private bool _pgodm = false; - private bool _pgodm_last_hit = false; - private bool _pnwanted = false; - private bool _pnwanted_last_hit = false; - private bool _pnragdoll = false; - private bool _pnragdoll_last_hit = false; - private bool _puoffradar = false; - private bool _puoffradar_last_hit = false; - private bool _psbelt = false; - private bool _psbelt_last_hit = false; - private bool _psjump = false; - private bool _psjump_last_hit = false; - private bool _psexammo = false; - private bool _psexammo_last_hit = false; - private bool _pdiscol = false; - private bool _pdiscol_last_hit = false; - private bool _vgodm = false; - private bool _vgodm_last_hit = false; - - public bool pgodm - { - get - { - return _pgodm; - } - set - { - _pgodm = value; - } - } - public bool pgodm_last_hit - { - get - { - return _pgodm_last_hit; - } - set - { - _pgodm_last_hit = value; - } - } - public bool pnwanted - { - get - { - return _pnwanted; - } - set - { - _pnwanted = value; - } - } - public bool pnwanted_last_hit - { - get - { - return _pnwanted_last_hit; - } - set - { - _pnwanted_last_hit = value; - } - } - public bool pnragdoll - { - get - { - return _pnragdoll; - } - set - { - _pnragdoll = value; - } - } - public bool pnragdoll_last_hit - { - get - { - return _pnragdoll_last_hit; - } - set - { - _pnragdoll_last_hit = value; - } - } - public bool puoffradar - { - get - { - return _puoffradar; - } - set - { - _puoffradar = value; - } - } - public bool puoffradar_last_hit - { - get - { - return _puoffradar_last_hit; - } - set - { - _puoffradar_last_hit = value; - } - } - public bool psbelt - { - get - { - return _psbelt; - } - set - { - _psbelt = value; - } - } - public bool psbelt_last_hit - { - get - { - return _psbelt_last_hit; - } - set - { - _psbelt_last_hit = value; - } - } - public bool psjump - { - get - { - return _psjump; - } - set - { - _psjump = value; - } - } - public bool psjump_last_hit - { - get - { - return _psjump_last_hit; - } - set - { - _psjump_last_hit = value; - } - } - public bool psexammo - { - get - { - return _psexammo; - } - set - { - _psexammo = value; - } - } - public bool psexammo_last_hit - { - get - { - return _psexammo_last_hit; - } - set - { - _psexammo_last_hit = value; - } - } - public bool pdiscol - { - get - { - return _pdiscol; - } - set - { - _pdiscol = value; - } - } - public bool pdiscol_last_hit - { - get - { - return _pdiscol_last_hit; - } - set - { - _pdiscol_last_hit = value; - } - } - public bool vgodm - { - get - { - return _vgodm; - } - set - { - _vgodm = value; - } - } - public bool vgodm_last_hit - { - get - { - return _vgodm_last_hit; - } - set - { - _vgodm_last_hit = value; - } - } - } -}