Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Text;
- using System.Data;
- using System.Drawing;
- using System.Threading;
- using System.Reflection;
- using System.Windows.Forms;
- using System.Collections.Generic;
- using System.Runtime.InteropServices;
- using System.ComponentModel;
- using System.Diagnostics;
- using SlimDX.Direct3D9;
- using SlimDX;
- using System.Linq;
- namespace H1Z1ESP
- {
- public partial class Main : Form
- {
- private delegate void AsyncWrite(String Text);
- private delegate void AsyncClear();
- public static Boolean IsRunning = false;
- private static Int64 CGameOffset = 0x1429708D0;
- private Int64 GraphicsOffset = 0x142970610;
- private Hotkey HotKey;
- private Settings Settings;
- private static IntPtr GameWindowHandle;
- private MARGIN GameWindowMargin;
- private static FastMemory GameMemory = new FastMemory();
- private RECT GameWindowRect;
- private POINT GameWindowSize;
- private POINT GameWindowCenter;
- public static IniHandler Ini;
- public static Boolean Aiming = false;
- public static Boolean ShowESP = false;
- public static Boolean ShowPlayers = true;
- public static Boolean ShowAggressive = true;
- public static Boolean ShowAnimals = true;
- public static Boolean ShowContainers = true;
- public static Boolean ShowWeapons = true;
- public static Boolean ShowAmmo = true;
- public static Boolean ShowItems = true;
- public static Boolean ShowVehicles = true;
- public static Boolean HideESPWhenAiming = true;
- public static Boolean HideDead = true;
- public static Boolean BoxedPlayers = false;
- public static Boolean BoxedAggressive = false;
- public static Boolean BoxedAnimals = false;
- public static Boolean BoxedItems = false;
- public static Boolean BoxedVehicles = false;
- public static Boolean Boxed3D = false;
- public static Boolean ShowMap = false;
- public static Boolean ShowRadar = false;
- public static int RadarTransparency = 210;
- public static Boolean RadarPlayers = true;
- public static Boolean RadarAggressive = true;
- public static Boolean RadarAnimals = true;
- public static Boolean RadarVehicles = true;
- private static Vector2 RadarCenter;
- public static Boolean ShowMapLarge = false;
- public static int MapTransparency = 210;
- private static float map_pos_x;
- private static float map_pos_z;
- public static Boolean ShowPosition = false;
- public static Boolean ShowCities = true;
- public static Boolean TextShadow = true;
- public static POINT TextRegion;
- public static ENTITY ePlayer;
- private static SlimDX.Direct3D9.Device DXDevice;
- private static SlimDX.Direct3D9.Sprite DXSprite;
- private static SlimDX.Direct3D9.Texture DXTextrureMap;
- private static SlimDX.Direct3D9.Texture DXTextrureMapLarge;
- private static SlimDX.Direct3D9.Line DXLine;
- private static SlimDX.Direct3D9.Font DXFont;
- public Main()
- {
- String iniPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace(@"file:\", "");
- Ini = new IniHandler(iniPath + @"\Settings.ini");
- #region INI_Offsets
- //if (Ini.IniReadValue("Offsets", "CGame") != String.Empty)
- // CGameOffset = Convert.ToInt64(Ini.IniReadValue("Offsets", "CGame"), 16);
- //if (Ini.IniReadValue("Offsets", "Graphics") != String.Empty)
- // GraphicsOffset = Convert.ToInt64(Ini.IniReadValue("Offsets", "Graphics"), 16);
- #endregion
- #region INI_ESP
- if (Ini.IniReadValue("ESP", "ShowPlayers") != String.Empty)
- ShowPlayers = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowPlayers"));
- if (Ini.IniReadValue("ESP", "ShowAggressive") != String.Empty)
- ShowAggressive = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowAggressive"));
- if (Ini.IniReadValue("ESP", "ShowAnimals") != String.Empty)
- ShowAnimals = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowAnimals"));
- if (Ini.IniReadValue("ESP", "ShowContainers") != String.Empty)
- ShowContainers = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowContainers"));
- if (Ini.IniReadValue("ESP", "ShowWeapons") != String.Empty)
- ShowWeapons = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowWeapons"));
- if (Ini.IniReadValue("ESP", "ShowAmmo") != String.Empty)
- ShowAmmo = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowAmmo"));
- if (Ini.IniReadValue("ESP", "ShowItems") != String.Empty)
- ShowItems = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowItems"));
- if (Ini.IniReadValue("ESP", "ShowVehicles") != String.Empty)
- ShowVehicles = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowVehicles"));
- #endregion
- #region INI_Boxes
- if (Ini.IniReadValue("Boxed", "Players") != String.Empty)
- BoxedPlayers = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Players"));
- if (Ini.IniReadValue("Boxed", "Aggressive") != String.Empty)
- BoxedAggressive = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Aggressive"));
- if (Ini.IniReadValue("Boxed", "Animals") != String.Empty)
- BoxedAnimals = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Animals"));
- if (Ini.IniReadValue("Boxed", "Items") != String.Empty)
- BoxedItems = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Items"));
- if (Ini.IniReadValue("Boxed", "Vehicles") != String.Empty)
- BoxedVehicles = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Vehicles"));
- if (Ini.IniReadValue("Boxed", "3D") != String.Empty)
- Boxed3D = Convert.ToBoolean(Ini.IniReadValue("Boxed", "3D"));
- #endregion
- #region INI_Misc
- if (Ini.IniReadValue("Misc", "ShowPosition") != String.Empty)
- ShowPosition = Convert.ToBoolean(Ini.IniReadValue("Misc", "ShowPosition"));
- if (Ini.IniReadValue("Misc", "ShowCities") != String.Empty)
- ShowCities = Convert.ToBoolean(Ini.IniReadValue("Misc", "ShowCities"));
- if (Ini.IniReadValue("Misc", "HideDead") != String.Empty)
- HideDead = Convert.ToBoolean(Ini.IniReadValue("Misc", "HideDead"));
- if (Ini.IniReadValue("Misc", "HideESPWhenAiming") != String.Empty)
- HideESPWhenAiming = Convert.ToBoolean(Ini.IniReadValue("Misc", "HideESPWhenAiming"));
- #endregion
- #region INI_Map
- if (Ini.IniReadValue("Map", "LargeMap") != String.Empty)
- ShowMapLarge = Convert.ToBoolean(Ini.IniReadValue("Map", "LargeMap"));
- if (Ini.IniReadValue("Map", "Transparency") != String.Empty)
- MapTransparency = Int32.Parse(Ini.IniReadValue("Map", "Transparency"));
- #endregion
- #region Radar
- if (Ini.IniReadValue("Radar", "Show") != String.Empty)
- ShowRadar = Convert.ToBoolean(Ini.IniReadValue("Radar", "Show"));
- if (Ini.IniReadValue("Radar", "Transparency") != String.Empty)
- RadarTransparency = Int32.Parse(Ini.IniReadValue("Radar", "Transparency"));
- if (Ini.IniReadValue("Radar", "Players") != String.Empty)
- RadarPlayers = Convert.ToBoolean(Ini.IniReadValue("Radar", "Players"));
- if (Ini.IniReadValue("Radar", "Aggressive") != String.Empty)
- RadarAggressive = Convert.ToBoolean(Ini.IniReadValue("Radar", "Aggressive"));
- if (Ini.IniReadValue("Radar", "Animals") != String.Empty)
- RadarAnimals = Convert.ToBoolean(Ini.IniReadValue("Radar", "Animals"));
- if (Ini.IniReadValue("Radar", "Vehicles") != String.Empty)
- RadarVehicles = Convert.ToBoolean(Ini.IniReadValue("Radar", "Vehicles"));
- #endregion
- InitializeComponent();
- }
- public static RECT GetWindowRect(IntPtr hWnd)
- {
- RECT lpRect = new RECT();
- Native.GetWindowRect(hWnd, out lpRect);
- return lpRect;
- }
- private void Main_Load(object sender, EventArgs e)
- {
- HotKey = new Hotkey();
- HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.Insert);
- HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F1);
- HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F2);
- HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F3);
- HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F5);
- Native.SetWindowLong(this.Handle, -20, (IntPtr)((Native.GetWindowLong(this.Handle, -20) ^ 0x80000) ^ 0x20));
- Native.SetLayeredWindowAttributes(this.Handle, 0, 0xff, 2);
- PresentParameters parameters = new SlimDX.Direct3D9.PresentParameters();
- parameters.Windowed = true;
- parameters.SwapEffect = SwapEffect.Discard;
- parameters.BackBufferFormat = Format.A8R8G8B8;
- parameters.BackBufferHeight = this.Height;
- parameters.BackBufferWidth = this.Width;
- parameters.PresentationInterval = PresentInterval.One;
- DXDevice = new SlimDX.Direct3D9.Device(new Direct3D(), 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[] { parameters });
- if (System.IO.File.Exists("map_large.png")) DXTextrureMapLarge = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map_large.png");
- if (System.IO.File.Exists("map.png")) DXTextrureMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map.png");
- DXSprite = new SlimDX.Direct3D9.Sprite(DXDevice);
- DXLine = new SlimDX.Direct3D9.Line(DXDevice);
- DXFont = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("Tahoma", 8f));
- if (GameMemory.Attach("H1Z1 PlayClient (Live)") == false) { Application.Exit(); return; }
- Thread dxThread = new Thread(new ThreadStart(DoProcess));
- dxThread.IsBackground = true;
- dxThread.Start();
- }
- private void Main_Paint(object sender, PaintEventArgs e)
- {
- this.GameWindowMargin.Top = 0;
- this.GameWindowMargin.Left = 0;
- this.GameWindowMargin.Right = this.Width;
- this.GameWindowMargin.Bottom = this.Height;
- Native.DwmExtendFrameIntoClientArea(this.Handle, ref this.GameWindowMargin);
- }
- #region RemapValue
- public static float RemapValue(float value, float from1, float to1, float from2, float to2)
- {
- return ((((value - from1) / (to1 - from1)) * (to2 - from2)) + from2);
- }
- #endregion
- #region DrawFilledBox
- public static void DrawFilledBox(float x, float y, float w, float h, Color Color, int alpha = 255)
- {
- Vector2[] vertexList = new Vector2[2];
- DXLine.GLLines = true;
- DXLine.Antialias = false;
- DXLine.Width = w;
- vertexList[0].X = x + (w / 2f);
- vertexList[0].Y = y;
- vertexList[1].X = x + (w / 2f);
- vertexList[1].Y = y + h;
- DXLine.Begin();
- DXLine.Draw(vertexList, Color.FromArgb(alpha, Color.R, Color.G, Color.B));
- DXLine.End();
- }
- #endregion
- #region RotatePoint
- private static Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerPoint, float angle, bool angleInRadians = false)
- {
- if (!angleInRadians) angle = (float)(angle * 0.017453292519943295);
- float num = (float)Math.Cos((double)angle);
- float num2 = (float)Math.Sin((double)angle);
- Vector2 vector = new Vector2((num * (pointToRotate.X - centerPoint.X)) - (num2 * (pointToRotate.Y - centerPoint.Y)), (num2 * (pointToRotate.X - centerPoint.X)) + (num * (pointToRotate.Y - centerPoint.Y)));
- return (vector + centerPoint);
- }
- #endregion
- #region GetMatrixAxis
- private static Vector3 GetMatrixAxis(Matrix matrix, int i)
- {
- switch (i)
- {
- case 0: return new Vector3(matrix.M11, matrix.M12, matrix.M13);
- case 1: return new Vector3(matrix.M21, matrix.M22, matrix.M23);
- case 2: return new Vector3(matrix.M31, matrix.M32, matrix.M33);
- case 3: return new Vector3(matrix.M41, matrix.M42, matrix.M43);
- }
- return Vector3.Zero;
- }
- #endregion
- #region WorldToScreen
- private bool WorldToScreen(Vector3 vector, out Vector3 screen)
- {
- screen = Vector3.Zero;
- long num = GameMemory.ReadInt64(GraphicsOffset);
- long num2 = GameMemory.ReadInt64(num + 0x48L);
- long num3 = GameMemory.ReadInt64(num2 + 0x20L) + 0x10L;
- Matrix4 matrix = GameMemory.ReadMatrix(num3 + 0x1A0);
- Matrix matrix2 = new Matrix();
- matrix2.M11 = matrix.M11;
- matrix2.M12 = matrix.M12;
- matrix2.M13 = matrix.M13;
- matrix2.M14 = matrix.M14;
- matrix2.M21 = matrix.M21;
- matrix2.M22 = matrix.M22;
- matrix2.M23 = matrix.M23;
- matrix2.M24 = matrix.M24;
- matrix2.M31 = matrix.M31;
- matrix2.M32 = matrix.M32;
- matrix2.M33 = matrix.M33;
- matrix2.M34 = matrix.M34;
- matrix2.M41 = matrix.M41;
- matrix2.M42 = matrix.M42;
- matrix2.M43 = matrix.M43;
- matrix2.M44 = matrix.M44;
- Matrix.Transpose(ref matrix2, out matrix2);
- matrix2.M21 *= -1f;
- matrix2.M22 *= -1f;
- matrix2.M23 *= -1f;
- matrix2.M24 *= -1f;
- float introduced8 = Vector3.Dot(GetMatrixAxis(matrix2, 3), vector);
- float num4 = introduced8 + matrix2.M44;
- if (num4 < 0.098f) return false;
- float introduced9 = Vector3.Dot(GetMatrixAxis(matrix2, 0), vector);
- float num5 = introduced9 + matrix2.M14;
- float introduced10 = Vector3.Dot(GetMatrixAxis(matrix2, 1), vector);
- float num6 = introduced10 + matrix2.M24;
- screen.X = ((((this.GameWindowSize.X - 0x10) / 2) * (1f + (num5 / num4))) + this.GameWindowRect.Left) + 8f;
- screen.Y = ((((this.GameWindowSize.Y - 0x26) / 2) * (1f - (num6 / num4))) + this.GameWindowRect.Top) + 30f;
- return true;
- }
- #endregion
- #region DrawLine
- public static void DrawLine(float x1, float y1, float x2, float y2, float w, Color Color)
- {
- Vector2[] vertexList = new Vector2[] { new Vector2(x1, y1), new Vector2(x2, y2) };
- DXLine.GLLines = true;
- DXLine.Width = w;
- DXLine.Antialias = true;
- DXLine.Begin();
- DXLine.Draw(vertexList, Color);
- DXLine.End();
- }
- #endregion
- #region DrawText
- public static void DrawText(string text, int x, int y, Color color, bool center = false)
- {
- int offset = center ? (text.Length * 5) / 2 : 0;
- if (TextShadow) DXFont.DrawString(null, text, x - offset + 1, y + 1, (Color4)Color.Black);
- DXFont.DrawString(null, text, x - offset, y, (Color4)color);
- }
- public static void DrawText(string text, ref POINT point, Color color)
- {
- if (TextShadow) DXFont.DrawString(null, text, point.X + 1, point.Y + 1, (Color4)Color.Black);
- DXFont.DrawString(null, text, point.X, point.Y, (Color4)color); point.Y += 15;
- }
- #endregion
- #region DrawBox
- public static void DrawBox(float x, float y, float w, float h, float px, Color Color)
- {
- DrawFilledBox(x - (w / 2f), (y + h) - (h / 2f), w, px, Color);
- DrawFilledBox((x - (w / 2f)) - px, y - (h / 2f), px, h, Color);
- DrawFilledBox(x - (w / 2f), (y - px) - (h / 2f), w, px, Color);
- DrawFilledBox((x - (w / 2f)) + w, y - (h / 2f), px, h, Color);
- }
- #endregion
- #region DrawBoxAbs
- public static void DrawBoxAbs(float x, float y, float w, float h, float px, Color Color)
- {
- DrawFilledBox(x, y + h, w, px, Color);
- DrawFilledBox(x - px, y, px, h, Color);
- DrawFilledBox(x, y - px, w, px, Color);
- DrawFilledBox(x + w, y, px, h, Color);
- }
- #endregion
- #region EntityToScreen
- public void EntityToScreen(Vector3 pos, string name, Color color, bool dist, bool line, bool bounds, float boxHeight, float yaw, float pitch)
- {
- string text = name;
- Vector3 dest = Vector3.Zero;
- this.WorldToScreen(pos, out dest);
- double distX = pos.X - Main.ePlayer.Pos.X;
- double distY = pos.Z - Main.ePlayer.Pos.Z;
- double distZ = pos.Y - Main.ePlayer.Pos.Y;
- double a = Math.Sqrt(((distX * distX) + (distY * distY)) + (distZ * distZ));
- if (dest.Y > 0f && dest.X > 0f && dest.Y >= this.GameWindowRect.Top + 20 && dest.X >= this.GameWindowRect.Left && dest.X <= this.GameWindowRect.Right && dest.Y <= this.GameWindowRect.Bottom)
- {
- if (dist)
- {
- text = text + "\n[" + Math.Round(a).ToString() + "m]";
- }
- if (line)
- {
- DrawLine(dest.X, dest.Y, this.GameWindowCenter.X, this.GameWindowCenter.Y, 1f, color);
- }
- if (bounds)
- {
- if (!Boxed3D || a >= 100.0)
- {
- DrawBox(dest.X, dest.Y, 65f / Math.Max((float)(((float)a) / 10f), (float)0.2f), 150f / Math.Max((float)(((float)a) / 10f), (float)0.2f), 1f, color);
- }
- else if (a < 100.0)
- {
- float wOffset = (boxHeight < 1f) ? boxHeight : 1f;
- float zOffset = (boxHeight > 1f) ? boxHeight / 2 : 0f;
- double num5 = pos.Z + ((1.0 * Math.Cos((double)pitch)) * Math.Cos((double)yaw));
- double num6 = pos.X + ((1.0 * Math.Cos((double)pitch)) * Math.Sin((double)yaw));
- double num7 = pos.Y + (1.0 * Math.Sin((double)pitch));
- Vector3 vector = new Vector3((float)num6, (float)num7, (float)num5);
- Vector3 zero = Vector3.Zero;
- this.WorldToScreen(vector, out zero);
- DrawLine(dest.X, dest.Y, zero.X, zero.Y, 1f, color);
- num5 = pos.Z + (0.5 * Math.Cos(yaw + 0.78539816339744828));
- num6 = pos.X + (0.5 * Math.Sin(yaw + 0.78539816339744828));
- Vector3 vector4 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
- Vector3 screen = Vector3.Zero;
- this.WorldToScreen(vector4, out screen);
- num5 = pos.Z + (0.5 * Math.Cos(yaw + 5.497787143782138));
- num6 = pos.X + (0.5 * Math.Sin(yaw + 5.497787143782138));
- Vector3 vector6 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
- Vector3 vector7 = Vector3.Zero;
- this.WorldToScreen(vector6, out vector7);
- DrawLine(screen.X, screen.Y, vector7.X, vector7.Y, 1f, color);
- num5 = pos.Z + (0.5 * Math.Cos(yaw + 3.9269908169872414));
- num6 = pos.X + (0.5 * Math.Sin(yaw + 3.9269908169872414));
- Vector3 vector8 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
- Vector3 vector9 = Vector3.Zero;
- this.WorldToScreen(vector8, out vector9);
- DrawLine(vector7.X, vector7.Y, vector9.X, vector9.Y, 1f, color);
- num5 = pos.Z + (0.5 * Math.Cos(yaw + 2.3561944901923448));
- num6 = pos.X + (0.5 * Math.Sin(yaw + 2.3561944901923448));
- Vector3 vector10 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
- Vector3 vector11 = Vector3.Zero;
- this.WorldToScreen(vector10, out vector11);
- DrawLine(vector9.X, vector9.Y, vector11.X, vector11.Y, 1f, color);
- DrawLine(vector11.X, vector11.Y, screen.X, screen.Y, 1f, color);
- Vector3 vector12 = new Vector3(vector4.X, vector4.Y + boxHeight, vector4.Z);
- Vector3 vector13 = Vector3.Zero;
- this.WorldToScreen(vector12, out vector13);
- DrawLine(screen.X, screen.Y, vector13.X, vector13.Y, 1f, color);
- Vector3 vector14 = new Vector3(vector6.X, vector6.Y + boxHeight, vector6.Z);
- Vector3 vector15 = Vector3.Zero;
- this.WorldToScreen(vector14, out vector15);
- DrawLine(vector13.X, vector13.Y, vector15.X, vector15.Y, 1f, color);
- DrawLine(vector7.X, vector7.Y, vector15.X, vector15.Y, 1f, color);
- Vector3 vector16 = new Vector3(vector8.X, vector8.Y + boxHeight, vector8.Z);
- Vector3 vector17 = Vector3.Zero;
- this.WorldToScreen(vector16, out vector17);
- DrawLine(vector15.X, vector15.Y, vector17.X, vector17.Y, 1f, color);
- DrawLine(vector9.X, vector9.Y, vector17.X, vector17.Y, 1f, color);
- Vector3 vector18 = new Vector3(vector10.X, vector10.Y + boxHeight, vector10.Z);
- Vector3 vector19 = Vector3.Zero;
- this.WorldToScreen(vector18, out vector19);
- DrawLine(vector17.X, vector17.Y, vector19.X, vector19.Y, 1f, color);
- DrawLine(vector11.X, vector11.Y, vector19.X, vector19.Y, 1f, color);
- DrawLine(vector19.X, vector19.Y, vector13.X, vector13.Y, 1f, color);
- }
- }
- DrawText(text, (int)dest.X, (int)dest.Y - 20, color, true);
- }
- }
- #endregion
- public void DoProcess()
- {
- Main.IsRunning = true;
- GameWindowHandle = GameMemory.Process.MainWindowHandle;
- Native.SetForegroundWindow(GameWindowHandle);
- DXDevice.SetRenderState(RenderState.ZEnable, false);
- DXDevice.SetRenderState(RenderState.Lighting, false);
- DXDevice.SetRenderState<Cull>(RenderState.CullMode, Cull.None);
- RECT rDone = new RECT();
- while (GameWindowHandle != IntPtr.Zero && Main.IsRunning && GameMemory.IsOpen)
- {
- RECT rCurrent = GetWindowRect(GameWindowHandle);
- if (!rCurrent.Equals(rDone))
- {
- rDone = rCurrent;
- this.GameWindowRect = GetWindowRect(GameWindowHandle);
- this.GameWindowSize.X = this.GameWindowRect.Right - this.GameWindowRect.Left;
- this.GameWindowSize.Y = this.GameWindowRect.Bottom - this.GameWindowRect.Top;
- this.GameWindowCenter.X = this.GameWindowRect.Left + (this.GameWindowSize.X / 2);
- this.GameWindowCenter.Y = this.GameWindowRect.Top + (this.GameWindowSize.Y / 2) + 11;
- }
- DXDevice.Clear(ClearFlags.Target, Color.Empty, 1f, 0);
- DXDevice.BeginScene();
- long entityOffset = GameMemory.ReadInt64(CGameOffset);
- // cars //
- long playerOffset = GameMemory.ReadInt64(entityOffset + 0x11D8);
- long posOffset = GameMemory.ReadInt64(playerOffset + 0x198);
- Main.ePlayer = new ENTITY();
- Main.ePlayer.Pos = new Vector3()
- {
- X = GameMemory.ReadFloat(posOffset + 0x100),
- Y = GameMemory.ReadFloat(posOffset + 0x104),
- Z = GameMemory.ReadFloat(posOffset + 0x108)
- };
- Main.ePlayer.Yaw = GameMemory.ReadFloat(playerOffset + 0x240);
- if (ShowPosition)
- {
- TextRegion = new POINT(this.GameWindowRect.Left + 15, this.GameWindowRect.Top + 35);
- DrawText(Main.ePlayer.Pos.X.ToString("F1") + "\n" + Main.ePlayer.Pos.Y.ToString("F1") + "\n" + Main.ePlayer.Pos.Z.ToString("F1"), ref TextRegion, Color.White);
- }
- ShowESP = (!HideESPWhenAiming || Convert.ToBoolean(Native.GetAsyncKeyState(2) & 0x8000) == false);
- List<ENTITY> entity_list = new List<ENTITY>();
- int entityCount = GameMemory.ReadInt32(entityOffset + 0x688);
- long entityEntry = GameMemory.ReadInt64(playerOffset + 0x410);
- for (int i = 1; i < entityCount; i++)
- {
- ENTITY n = new ENTITY();
- n.Id = GameMemory.ReadInt32(entityEntry + 0x620);
- n.Type = GameMemory.ReadInt32(entityEntry + 0x5C8);
- // Vehicle Position//
- if (n.Type == 0x11 || n.Type == 0x72 || n.Type == 0x76)
- {
- n.Pos.X = GameMemory.ReadFloat(entityEntry + 0x100);
- n.Pos.Y = GameMemory.ReadFloat(entityEntry + 0x104);
- n.Pos.Z = GameMemory.ReadFloat(entityEntry + 0x108);
- }
- else // All others //
- {
- posOffset = GameMemory.ReadInt64(entityEntry + 0x198);
- n.Pos.X = GameMemory.ReadFloat(posOffset + 0x100);
- n.Pos.Y = GameMemory.ReadFloat(posOffset + 0x104);
- n.Pos.Z = GameMemory.ReadFloat(posOffset + 0x108);
- }
- posOffset = GameMemory.ReadInt64(entityEntry + 0x198);
- n.Pos.X = GameMemory.ReadFloat(entityEntry + 0x100);
- n.Pos.Y = GameMemory.ReadFloat(entityEntry + 0x104);
- n.Pos.Z = GameMemory.ReadFloat(entityEntry + 0x108);
- n.Speed = GameMemory.ReadFloat(entityEntry + 0x2C8);
- n.Yaw = GameMemory.ReadFloat(entityEntry + 0x2E0);
- n.Pitch = 0f;
- n.Name = GameMemory.ReadString(GameMemory.ReadInt64(entityEntry + 0x4E0), GameMemory.ReadInt32(entityEntry + 0x4E8));
- //alive bytes
- n.IsAlive = Convert.ToBoolean(GameMemory.ReadByte(entityEntry + 0x138C));
- //HP
- n.Health = GameMemory.ReadUInt32(GameMemory.ReadInt64(entityEntry + 0x4076) + 0xB0) / 100;
- entity_list.Add(n);
- switch (n.Type)
- {
- case 0x04:
- case 0x05: // 0x04 maybe useless, not verified, but players are now 0x05
- if (ShowESP && ShowPlayers && n.IsAlive) this.EntityToScreen(n.Pos, n.Name + " " + n.Health, Color.SkyBlue, true, false, BoxedPlayers, 2f, n.Yaw, n.Pitch);
- break;
- case 0x13/*Deer*/:
- case 0x55/*Rabbit*/:
- if (ShowESP && ShowAnimals && n.IsAlive) this.EntityToScreen(n.Pos, n.Name, Color.DarkGreen, true, false, BoxedAnimals, 2f, n.Yaw, n.Pitch);
- break;
- case 0x14/*Wolf*/:
- case 0x50/*Bear*/:
- case 0x0C/*Zombie*/:
- case 0x5b/*Zombie*/:
- if (ShowESP && ShowAggressive && n.IsAlive) this.EntityToScreen(n.Pos, n.Name, Color.Red, true, false, BoxedAggressive, 2f, n.Yaw, n.Pitch);
- break;
- case 0x34: // Weapons
- if (ShowESP && ShowWeapons) this.EntityToScreen(n.Pos, n.Name, Color.GreenYellow, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- break;
- case 0x2E: // Loot
- if (ShowESP && ShowItems) this.EntityToScreen(n.Pos, n.Name, Color.GreenYellow, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- break;
- case 0x6D: // Stash
- case 0x9C: // Land Mine
- if (ShowESP && ShowItems) this.EntityToScreen(n.Pos, n.Name, Color.SaddleBrown, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- break;
- case 0x33: // Storage Container
- if (ShowESP && ShowContainers) this.EntityToScreen(n.Pos, n.Name, Color.Gray, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- break;
- case 0x15: // Ammo
- if (ShowESP && ShowAmmo) this.EntityToScreen(n.Pos, n.Name, Color.Orange, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- break;
- case 0x11: // OffRoad
- case 0x72: // Pickup
- case 0x76: // PoliceCar
- if (ShowESP && ShowVehicles) this.EntityToScreen(n.Pos, n.Name, Color.HotPink, true, false, BoxedVehicles, 2f, n.Yaw, n.Pitch);
- break;
- case 0x2C: // Battery & Sparkplugs
- if (ShowESP && ShowItems)
- {
- if (n.Name.Contains("Battery") || n.Name.Contains("Sparkplugs"))
- {
- this.EntityToScreen(n.Pos, n.Name, Color.DeepPink, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- }
- else
- {
- this.EntityToScreen(n.Pos, n.Name, Color.White, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
- }
- }
- break;
- case 0x16: // Dresser
- case 0x17: // Armoire
- case 0x19: // World Doors
- case 0x1D: // Cabinets
- case 0x1E: // Cabinets
- case 0x21: // Cabinets
- case 0x22: // Cabinets
- case 0x23: // Cabinets
- case 0x25: // Refrigerator
- case 0x26: // Garbage Can
- case 0x28: // Cabinets
- case 0x29: // Desk
- case 0x27: // Dumpster
- case 0x30: // File Cabinet
- case 0x31: // Tool Cabinet
- case 0x37: // Recycle Bin (with fire)
- case 0x38: // Punji Sticks
- case 0x3D: // Wooded Barricade
- case 0x3E: // Water Well
- case 0x3F: // Armoire
- case 0x40: // Dresser
- case 0x42: // Chest
- case 0x44: // Wrecked Sedan
- case 0x45: // Wrecked Van
- case 0x46: // Wrecked Truck
- case 0x49: // Ottoman
- case 0x4A: // Ottoman
- case 0x4F: // Designer-placed(?) Door
- case 0x5D: // File Cabinet
- case 0x61: // Cabinets
- case 0x63: // Cabinets
- case 0x6F: // Locker
- case 0x70: // Weapon Locker
- case 0x71: // Glass Cabinet
- case 0x79: // Designer-placed(?) Door
- case 0x7A: // Resting (Bed)
- case 0x7B: // Designer-placed(?) Door
- case 0x7C: // Designer-placed(?) Door
- case 0x80: // Cabinets
- case 0x81: // Cabinets
- case 0x82: // Cabinets
- case 0x83: // Cabinets
- case 0x84: // Cabinets
- case 0x85: // Cabinets
- case 0x86: // Cabinets
- case 0x87: // Cabinets
- case 0x88: // Cabinets
- case 0xA1: // Washing Machine
- case 0xA2: // Dryer
- case 0x7D: // IO.FireHydrant
- case 0x7E: // IO.FireHydrant
- //this.WorldToScreen(new Vector3(EntityX, EntityY, EntityZ), EntityName + "[" + EntityId.ToString("X2") + "]", Color.Gray, true, false, false, 0f, 0f);
- break;
- case 0x4C: // Shed
- case 0x5F: // Metal Wall/Gate
- case 0x62: // Basic Shack Door
- case 0x6E: // Desk Foundation
- case 0x9E: // Metal Door
- case 0xA6: // Large Shelter
- case 0xA7: // Shed
- //this.WorldToScreen(new Vector3(EntityX, EntityY, EntityZ), EntityName + "[" + EntityId.ToString("X2") + "]", Color.Gray, true, false, false, 0f, 0f);
- break;
- default: // Other Items
- //if (ShowESP && ShowItems) this.EntityToScreen(n.Pos, n.Name + "[" + n.Type.ToString("X2") + "]", Color.White, true, false, false, 1f, 0f, 0f);
- break;
- }
- entityEntry = GameMemory.ReadInt64(entityEntry + 0x410);
- }
- if (ShowRadar)
- {
- DrawFilledBox(this.GameWindowRect.Right - 225, this.GameWindowRect.Top + 50, 201f, 201f, Color.DimGray, RadarTransparency);
- DrawBoxAbs(this.GameWindowRect.Right - 225, this.GameWindowRect.Top + 50, 201f, 201f, 1f, Color.Black);
- DrawLine(this.GameWindowRect.Right - 125, this.GameWindowRect.Top + 50, this.GameWindowRect.Right - 125, this.GameWindowRect.Top + 251, 1f, Color.Black);
- DrawLine(this.GameWindowRect.Right - 225, this.GameWindowRect.Top + 150, this.GameWindowRect.Right - 24, this.GameWindowRect.Top + 150, 1f, Color.Black);
- RadarCenter = new Vector2(this.GameWindowRect.Right - 125, this.GameWindowRect.Top + 125 + 25);
- DrawFilledBox(RadarCenter.X - 1f, RadarCenter.Y - 1f, 3f, 3f, Color.White);
- if (RadarCenter.Length() > 0f)
- {
- foreach (ENTITY entity in entity_list)
- {
- Vector2 pointToRotate = new Vector2(entity.Pos.X, entity.Pos.Z);
- Vector2 vector3 = new Vector2(Main.ePlayer.Pos.X, Main.ePlayer.Pos.Z);
- pointToRotate = vector3 - pointToRotate;
- float num30 = pointToRotate.Length() * 0.5f;
- num30 = Math.Min(num30, 90f);
- pointToRotate.Normalize();
- pointToRotate = (Vector2)(pointToRotate * num30);
- pointToRotate += RadarCenter;
- pointToRotate = RotatePoint(pointToRotate, RadarCenter, Main.ePlayer.Yaw, true);
- if (entity.Type == 0x04 && RadarPlayers)
- {
- DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.SkyBlue);
- }
- if ((entity.Type == 0x0C || entity.Type == 0x14 || entity.Type == 0x50 || entity.Type == 0x5b) && RadarAggressive)
- {
- DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.Red);
- }
- if ((entity.Type == 0x13 || entity.Type == 0x55) && RadarAnimals)
- {
- DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.LightGreen);
- }
- if ((entity.Type == 0x11 || entity.Type == 0x72 || entity.Type == 0x76) && RadarVehicles)
- {
- DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.HotPink);
- }
- }
- }
- }
- entity_list.Clear();
- if (ShowCities)
- {
- this.EntityToScreen(new Vector3(-129f, 40f, -1146f), "Pleasant Valley", Color.DarkViolet, true, false, false, 0f, 0f, 0f);
- this.EntityToScreen(new Vector3(-1233f, 90f, 1855f), "Cranberry", Color.DarkViolet, true, false, false, 0f, 0f, 0f);
- this.EntityToScreen(new Vector3(2003f, 50f, 2221f), "Ranchito", Color.DarkViolet, true, false, false, 0f, 0f, 0f);
- }
- if (Main.ShowMap && (DXTextrureMap != null || DXTextrureMapLarge != null))
- {
- DXSprite.Begin(SpriteFlags.AlphaBlend);
- if (Main.ShowMapLarge && DXTextrureMapLarge != null)
- {
- map_pos_x = RemapValue(Main.ePlayer.Pos.X, 4000f, -4000f, -512f, 512f);
- map_pos_z = RemapValue(Main.ePlayer.Pos.Z, -4000f, 4000f, -512f, 512f);
- DXSprite.Draw(DXTextrureMapLarge, new Vector3(512f, 512f, 0f), new Vector3(this.GameWindowCenter.X, this.GameWindowCenter.Y, 0f), Color.FromArgb(MapTransparency, 0xff, 0xff, 0xff));
- }
- else if (DXTextrureMap != null)
- {
- map_pos_x = RemapValue(Main.ePlayer.Pos.X, 4000f, -4000f, -265f, 265f);
- map_pos_z = RemapValue(Main.ePlayer.Pos.Z, -4000f, 4000f, -265f, 265f);
- DXSprite.Draw(DXTextrureMap, new Vector3(256f, 256f, 0f), new Vector3(this.GameWindowCenter.X, this.GameWindowCenter.Y, 0f), Color.FromArgb(MapTransparency, 0xff, 0xff, 0xff));
- }
- DXSprite.End();
- float direction = Main.ePlayer.Yaw * -1f;
- float fromX = (float)((this.GameWindowCenter.X + map_pos_z) + (20.0 * Math.Cos(direction)));
- float fromY = (float)((this.GameWindowCenter.Y + map_pos_x) + (20.0 * Math.Sin(direction)));
- DrawFilledBox((this.GameWindowCenter.X + map_pos_z) - 2f, (this.GameWindowCenter.Y + map_pos_x) - 2f, 6f, 6f, Color.Magenta);
- DrawLine(fromX, fromY, (this.GameWindowCenter.X + map_pos_z) + 1f, (this.GameWindowCenter.Y + map_pos_x) + 1f, 1f, Color.PaleVioletRed);
- }
- DXDevice.EndScene();
- DXDevice.Present();
- }
- DXDevice.Dispose();
- Application.Exit();
- }
- protected override void WndProc(ref Message m)
- {
- if (m.Msg == 0x312)
- {
- switch ((int)m.WParam)
- {
- case 0:
- if (this.Settings != null && this.Settings.Visible)
- {
- this.Settings.Close();
- break;
- }
- this.Settings = new Settings(); this.Settings.Show();
- this.Settings.Location = new Point(this.GameWindowRect.Right - this.Settings.Width - 20, this.GameWindowRect.Top + 200);
- Native.SetForegroundWindow(GameMemory.Process.MainWindowHandle);
- break;
- case 1:
- ShowRadar = !ShowRadar;
- Main.Ini.IniWriteValue("Radar", "Show", ShowRadar.ToString());
- break;
- case 2:
- ShowMap = !ShowMap;
- break;
- case 3:
- ShowMapLarge = !ShowMapLarge;
- Main.Ini.IniWriteValue("Map", "LargeMap", Main.ShowMapLarge.ToString());
- break;
- case 4:
- Main.IsRunning = false;
- break;
- }
- }
- base.WndProc(ref m);
- }
- public static bool HideESPAiming { get; set; }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement