Advertisement
Guest User

Main.CS

a guest
May 8th, 2015
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.21 KB | None | 0 0
  1. using System;
  2. using System.Text;
  3. using System.Data;
  4. using System.Drawing;
  5. using System.Threading;
  6. using System.Reflection;
  7. using System.Windows.Forms;
  8. using System.Collections.Generic;
  9. using System.Runtime.InteropServices;
  10. using System.ComponentModel;
  11. using System.Diagnostics;
  12. using SlimDX.Direct3D9;
  13. using SlimDX;
  14. using System.Linq;
  15.  
  16.  
  17. namespace H1Z1ESP
  18. {
  19. public partial class Main : Form
  20. {
  21. private delegate void AsyncWrite(String Text);
  22. private delegate void AsyncClear();
  23.  
  24. public static Boolean IsRunning = false;
  25.  
  26. private static Int64 CGameOffset = 0x1429708D0;
  27. private Int64 GraphicsOffset = 0x142970610;
  28.  
  29. private Hotkey HotKey;
  30. private Settings Settings;
  31.  
  32. private static IntPtr GameWindowHandle;
  33. private MARGIN GameWindowMargin;
  34. private static FastMemory GameMemory = new FastMemory();
  35. private RECT GameWindowRect;
  36. private POINT GameWindowSize;
  37. private POINT GameWindowCenter;
  38.  
  39. public static IniHandler Ini;
  40.  
  41. public static Boolean Aiming = false;
  42.  
  43. public static Boolean ShowESP = false;
  44.  
  45. public static Boolean ShowPlayers = true;
  46. public static Boolean ShowAggressive = true;
  47. public static Boolean ShowAnimals = true;
  48. public static Boolean ShowContainers = true;
  49. public static Boolean ShowWeapons = true;
  50. public static Boolean ShowAmmo = true;
  51. public static Boolean ShowItems = true;
  52. public static Boolean ShowVehicles = true;
  53.  
  54. public static Boolean HideESPWhenAiming = true;
  55. public static Boolean HideDead = true;
  56.  
  57. public static Boolean BoxedPlayers = false;
  58. public static Boolean BoxedAggressive = false;
  59. public static Boolean BoxedAnimals = false;
  60. public static Boolean BoxedItems = false;
  61. public static Boolean BoxedVehicles = false;
  62. public static Boolean Boxed3D = false;
  63.  
  64. public static Boolean ShowMap = false;
  65.  
  66. public static Boolean ShowRadar = false;
  67. public static int RadarTransparency = 210;
  68. public static Boolean RadarPlayers = true;
  69. public static Boolean RadarAggressive = true;
  70. public static Boolean RadarAnimals = true;
  71. public static Boolean RadarVehicles = true;
  72.  
  73. private static Vector2 RadarCenter;
  74.  
  75. public static Boolean ShowMapLarge = false;
  76. public static int MapTransparency = 210;
  77. private static float map_pos_x;
  78. private static float map_pos_z;
  79.  
  80. public static Boolean ShowPosition = false;
  81. public static Boolean ShowCities = true;
  82.  
  83. public static Boolean TextShadow = true;
  84.  
  85. public static POINT TextRegion;
  86.  
  87. public static ENTITY ePlayer;
  88.  
  89. private static SlimDX.Direct3D9.Device DXDevice;
  90. private static SlimDX.Direct3D9.Sprite DXSprite;
  91. private static SlimDX.Direct3D9.Texture DXTextrureMap;
  92. private static SlimDX.Direct3D9.Texture DXTextrureMapLarge;
  93. private static SlimDX.Direct3D9.Line DXLine;
  94. private static SlimDX.Direct3D9.Font DXFont;
  95.  
  96. public Main()
  97. {
  98. String iniPath = System.IO.Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase).Replace(@"file:\", "");
  99. Ini = new IniHandler(iniPath + @"\Settings.ini");
  100.  
  101. #region INI_Offsets
  102. //if (Ini.IniReadValue("Offsets", "CGame") != String.Empty)
  103. // CGameOffset = Convert.ToInt64(Ini.IniReadValue("Offsets", "CGame"), 16);
  104. //if (Ini.IniReadValue("Offsets", "Graphics") != String.Empty)
  105. // GraphicsOffset = Convert.ToInt64(Ini.IniReadValue("Offsets", "Graphics"), 16);
  106. #endregion
  107.  
  108. #region INI_ESP
  109. if (Ini.IniReadValue("ESP", "ShowPlayers") != String.Empty)
  110. ShowPlayers = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowPlayers"));
  111.  
  112. if (Ini.IniReadValue("ESP", "ShowAggressive") != String.Empty)
  113. ShowAggressive = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowAggressive"));
  114.  
  115. if (Ini.IniReadValue("ESP", "ShowAnimals") != String.Empty)
  116. ShowAnimals = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowAnimals"));
  117.  
  118. if (Ini.IniReadValue("ESP", "ShowContainers") != String.Empty)
  119. ShowContainers = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowContainers"));
  120.  
  121. if (Ini.IniReadValue("ESP", "ShowWeapons") != String.Empty)
  122. ShowWeapons = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowWeapons"));
  123.  
  124. if (Ini.IniReadValue("ESP", "ShowAmmo") != String.Empty)
  125. ShowAmmo = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowAmmo"));
  126.  
  127. if (Ini.IniReadValue("ESP", "ShowItems") != String.Empty)
  128. ShowItems = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowItems"));
  129.  
  130. if (Ini.IniReadValue("ESP", "ShowVehicles") != String.Empty)
  131. ShowVehicles = Convert.ToBoolean(Ini.IniReadValue("ESP", "ShowVehicles"));
  132. #endregion
  133.  
  134. #region INI_Boxes
  135. if (Ini.IniReadValue("Boxed", "Players") != String.Empty)
  136. BoxedPlayers = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Players"));
  137.  
  138. if (Ini.IniReadValue("Boxed", "Aggressive") != String.Empty)
  139. BoxedAggressive = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Aggressive"));
  140.  
  141. if (Ini.IniReadValue("Boxed", "Animals") != String.Empty)
  142. BoxedAnimals = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Animals"));
  143.  
  144. if (Ini.IniReadValue("Boxed", "Items") != String.Empty)
  145. BoxedItems = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Items"));
  146.  
  147. if (Ini.IniReadValue("Boxed", "Vehicles") != String.Empty)
  148. BoxedVehicles = Convert.ToBoolean(Ini.IniReadValue("Boxed", "Vehicles"));
  149.  
  150. if (Ini.IniReadValue("Boxed", "3D") != String.Empty)
  151. Boxed3D = Convert.ToBoolean(Ini.IniReadValue("Boxed", "3D"));
  152. #endregion
  153.  
  154. #region INI_Misc
  155. if (Ini.IniReadValue("Misc", "ShowPosition") != String.Empty)
  156. ShowPosition = Convert.ToBoolean(Ini.IniReadValue("Misc", "ShowPosition"));
  157.  
  158. if (Ini.IniReadValue("Misc", "ShowCities") != String.Empty)
  159. ShowCities = Convert.ToBoolean(Ini.IniReadValue("Misc", "ShowCities"));
  160.  
  161. if (Ini.IniReadValue("Misc", "HideDead") != String.Empty)
  162. HideDead = Convert.ToBoolean(Ini.IniReadValue("Misc", "HideDead"));
  163.  
  164. if (Ini.IniReadValue("Misc", "HideESPWhenAiming") != String.Empty)
  165. HideESPWhenAiming = Convert.ToBoolean(Ini.IniReadValue("Misc", "HideESPWhenAiming"));
  166. #endregion
  167.  
  168. #region INI_Map
  169. if (Ini.IniReadValue("Map", "LargeMap") != String.Empty)
  170. ShowMapLarge = Convert.ToBoolean(Ini.IniReadValue("Map", "LargeMap"));
  171.  
  172. if (Ini.IniReadValue("Map", "Transparency") != String.Empty)
  173. MapTransparency = Int32.Parse(Ini.IniReadValue("Map", "Transparency"));
  174. #endregion
  175.  
  176. #region Radar
  177. if (Ini.IniReadValue("Radar", "Show") != String.Empty)
  178. ShowRadar = Convert.ToBoolean(Ini.IniReadValue("Radar", "Show"));
  179.  
  180. if (Ini.IniReadValue("Radar", "Transparency") != String.Empty)
  181. RadarTransparency = Int32.Parse(Ini.IniReadValue("Radar", "Transparency"));
  182.  
  183. if (Ini.IniReadValue("Radar", "Players") != String.Empty)
  184. RadarPlayers = Convert.ToBoolean(Ini.IniReadValue("Radar", "Players"));
  185.  
  186. if (Ini.IniReadValue("Radar", "Aggressive") != String.Empty)
  187. RadarAggressive = Convert.ToBoolean(Ini.IniReadValue("Radar", "Aggressive"));
  188.  
  189. if (Ini.IniReadValue("Radar", "Animals") != String.Empty)
  190. RadarAnimals = Convert.ToBoolean(Ini.IniReadValue("Radar", "Animals"));
  191.  
  192. if (Ini.IniReadValue("Radar", "Vehicles") != String.Empty)
  193. RadarVehicles = Convert.ToBoolean(Ini.IniReadValue("Radar", "Vehicles"));
  194. #endregion
  195.  
  196. InitializeComponent();
  197. }
  198.  
  199. public static RECT GetWindowRect(IntPtr hWnd)
  200. {
  201. RECT lpRect = new RECT();
  202. Native.GetWindowRect(hWnd, out lpRect);
  203. return lpRect;
  204. }
  205.  
  206. private void Main_Load(object sender, EventArgs e)
  207. {
  208. HotKey = new Hotkey();
  209. HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.Insert);
  210. HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F1);
  211. HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F2);
  212. HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F3);
  213. HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F5);
  214.  
  215. Native.SetWindowLong(this.Handle, -20, (IntPtr)((Native.GetWindowLong(this.Handle, -20) ^ 0x80000) ^ 0x20));
  216. Native.SetLayeredWindowAttributes(this.Handle, 0, 0xff, 2);
  217.  
  218. PresentParameters parameters = new SlimDX.Direct3D9.PresentParameters();
  219. parameters.Windowed = true;
  220. parameters.SwapEffect = SwapEffect.Discard;
  221. parameters.BackBufferFormat = Format.A8R8G8B8;
  222. parameters.BackBufferHeight = this.Height;
  223. parameters.BackBufferWidth = this.Width;
  224. parameters.PresentationInterval = PresentInterval.One;
  225.  
  226. DXDevice = new SlimDX.Direct3D9.Device(new Direct3D(), 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[] { parameters });
  227. if (System.IO.File.Exists("map_large.png")) DXTextrureMapLarge = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map_large.png");
  228. if (System.IO.File.Exists("map.png")) DXTextrureMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map.png");
  229. DXSprite = new SlimDX.Direct3D9.Sprite(DXDevice);
  230. DXLine = new SlimDX.Direct3D9.Line(DXDevice);
  231. DXFont = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("Tahoma", 8f));
  232.  
  233. if (GameMemory.Attach("H1Z1 PlayClient (Live)") == false) { Application.Exit(); return; }
  234. Thread dxThread = new Thread(new ThreadStart(DoProcess));
  235. dxThread.IsBackground = true;
  236. dxThread.Start();
  237. }
  238.  
  239. private void Main_Paint(object sender, PaintEventArgs e)
  240. {
  241. this.GameWindowMargin.Top = 0;
  242. this.GameWindowMargin.Left = 0;
  243. this.GameWindowMargin.Right = this.Width;
  244. this.GameWindowMargin.Bottom = this.Height;
  245. Native.DwmExtendFrameIntoClientArea(this.Handle, ref this.GameWindowMargin);
  246. }
  247.  
  248. #region RemapValue
  249. public static float RemapValue(float value, float from1, float to1, float from2, float to2)
  250. {
  251. return ((((value - from1) / (to1 - from1)) * (to2 - from2)) + from2);
  252. }
  253. #endregion
  254.  
  255. #region DrawFilledBox
  256. public static void DrawFilledBox(float x, float y, float w, float h, Color Color, int alpha = 255)
  257. {
  258. Vector2[] vertexList = new Vector2[2];
  259. DXLine.GLLines = true;
  260. DXLine.Antialias = false;
  261. DXLine.Width = w;
  262. vertexList[0].X = x + (w / 2f);
  263. vertexList[0].Y = y;
  264. vertexList[1].X = x + (w / 2f);
  265. vertexList[1].Y = y + h;
  266. DXLine.Begin();
  267. DXLine.Draw(vertexList, Color.FromArgb(alpha, Color.R, Color.G, Color.B));
  268. DXLine.End();
  269. }
  270. #endregion
  271.  
  272. #region RotatePoint
  273. private static Vector2 RotatePoint(Vector2 pointToRotate, Vector2 centerPoint, float angle, bool angleInRadians = false)
  274. {
  275. if (!angleInRadians) angle = (float)(angle * 0.017453292519943295);
  276. float num = (float)Math.Cos((double)angle);
  277. float num2 = (float)Math.Sin((double)angle);
  278. Vector2 vector = new Vector2((num * (pointToRotate.X - centerPoint.X)) - (num2 * (pointToRotate.Y - centerPoint.Y)), (num2 * (pointToRotate.X - centerPoint.X)) + (num * (pointToRotate.Y - centerPoint.Y)));
  279. return (vector + centerPoint);
  280. }
  281. #endregion
  282.  
  283. #region GetMatrixAxis
  284. private static Vector3 GetMatrixAxis(Matrix matrix, int i)
  285. {
  286. switch (i)
  287. {
  288. case 0: return new Vector3(matrix.M11, matrix.M12, matrix.M13);
  289. case 1: return new Vector3(matrix.M21, matrix.M22, matrix.M23);
  290. case 2: return new Vector3(matrix.M31, matrix.M32, matrix.M33);
  291. case 3: return new Vector3(matrix.M41, matrix.M42, matrix.M43);
  292. }
  293. return Vector3.Zero;
  294. }
  295. #endregion
  296.  
  297. #region WorldToScreen
  298. private bool WorldToScreen(Vector3 vector, out Vector3 screen)
  299. {
  300. screen = Vector3.Zero;
  301. long num = GameMemory.ReadInt64(GraphicsOffset);
  302. long num2 = GameMemory.ReadInt64(num + 0x48L);
  303. long num3 = GameMemory.ReadInt64(num2 + 0x20L) + 0x10L;
  304. Matrix4 matrix = GameMemory.ReadMatrix(num3 + 0x1A0);
  305. Matrix matrix2 = new Matrix();
  306. matrix2.M11 = matrix.M11;
  307. matrix2.M12 = matrix.M12;
  308. matrix2.M13 = matrix.M13;
  309. matrix2.M14 = matrix.M14;
  310. matrix2.M21 = matrix.M21;
  311. matrix2.M22 = matrix.M22;
  312. matrix2.M23 = matrix.M23;
  313. matrix2.M24 = matrix.M24;
  314. matrix2.M31 = matrix.M31;
  315. matrix2.M32 = matrix.M32;
  316. matrix2.M33 = matrix.M33;
  317. matrix2.M34 = matrix.M34;
  318. matrix2.M41 = matrix.M41;
  319. matrix2.M42 = matrix.M42;
  320. matrix2.M43 = matrix.M43;
  321. matrix2.M44 = matrix.M44;
  322. Matrix.Transpose(ref matrix2, out matrix2);
  323. matrix2.M21 *= -1f;
  324. matrix2.M22 *= -1f;
  325. matrix2.M23 *= -1f;
  326. matrix2.M24 *= -1f;
  327. float introduced8 = Vector3.Dot(GetMatrixAxis(matrix2, 3), vector);
  328. float num4 = introduced8 + matrix2.M44;
  329. if (num4 < 0.098f) return false;
  330. float introduced9 = Vector3.Dot(GetMatrixAxis(matrix2, 0), vector);
  331. float num5 = introduced9 + matrix2.M14;
  332. float introduced10 = Vector3.Dot(GetMatrixAxis(matrix2, 1), vector);
  333. float num6 = introduced10 + matrix2.M24;
  334. screen.X = ((((this.GameWindowSize.X - 0x10) / 2) * (1f + (num5 / num4))) + this.GameWindowRect.Left) + 8f;
  335. screen.Y = ((((this.GameWindowSize.Y - 0x26) / 2) * (1f - (num6 / num4))) + this.GameWindowRect.Top) + 30f;
  336. return true;
  337. }
  338. #endregion
  339.  
  340. #region DrawLine
  341. public static void DrawLine(float x1, float y1, float x2, float y2, float w, Color Color)
  342. {
  343. Vector2[] vertexList = new Vector2[] { new Vector2(x1, y1), new Vector2(x2, y2) };
  344. DXLine.GLLines = true;
  345. DXLine.Width = w;
  346. DXLine.Antialias = true;
  347. DXLine.Begin();
  348. DXLine.Draw(vertexList, Color);
  349. DXLine.End();
  350. }
  351. #endregion
  352.  
  353. #region DrawText
  354. public static void DrawText(string text, int x, int y, Color color, bool center = false)
  355. {
  356. int offset = center ? (text.Length * 5) / 2 : 0;
  357. if (TextShadow) DXFont.DrawString(null, text, x - offset + 1, y + 1, (Color4)Color.Black);
  358. DXFont.DrawString(null, text, x - offset, y, (Color4)color);
  359. }
  360.  
  361. public static void DrawText(string text, ref POINT point, Color color)
  362. {
  363. if (TextShadow) DXFont.DrawString(null, text, point.X + 1, point.Y + 1, (Color4)Color.Black);
  364. DXFont.DrawString(null, text, point.X, point.Y, (Color4)color); point.Y += 15;
  365. }
  366. #endregion
  367.  
  368. #region DrawBox
  369. public static void DrawBox(float x, float y, float w, float h, float px, Color Color)
  370. {
  371. DrawFilledBox(x - (w / 2f), (y + h) - (h / 2f), w, px, Color);
  372. DrawFilledBox((x - (w / 2f)) - px, y - (h / 2f), px, h, Color);
  373. DrawFilledBox(x - (w / 2f), (y - px) - (h / 2f), w, px, Color);
  374. DrawFilledBox((x - (w / 2f)) + w, y - (h / 2f), px, h, Color);
  375. }
  376. #endregion
  377.  
  378. #region DrawBoxAbs
  379. public static void DrawBoxAbs(float x, float y, float w, float h, float px, Color Color)
  380. {
  381. DrawFilledBox(x, y + h, w, px, Color);
  382. DrawFilledBox(x - px, y, px, h, Color);
  383. DrawFilledBox(x, y - px, w, px, Color);
  384. DrawFilledBox(x + w, y, px, h, Color);
  385. }
  386. #endregion
  387.  
  388. #region EntityToScreen
  389. public void EntityToScreen(Vector3 pos, string name, Color color, bool dist, bool line, bool bounds, float boxHeight, float yaw, float pitch)
  390. {
  391. string text = name;
  392. Vector3 dest = Vector3.Zero;
  393. this.WorldToScreen(pos, out dest);
  394.  
  395. double distX = pos.X - Main.ePlayer.Pos.X;
  396. double distY = pos.Z - Main.ePlayer.Pos.Z;
  397. double distZ = pos.Y - Main.ePlayer.Pos.Y;
  398. double a = Math.Sqrt(((distX * distX) + (distY * distY)) + (distZ * distZ));
  399.  
  400. 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)
  401. {
  402. if (dist)
  403. {
  404. text = text + "\n[" + Math.Round(a).ToString() + "m]";
  405. }
  406.  
  407. if (line)
  408. {
  409. DrawLine(dest.X, dest.Y, this.GameWindowCenter.X, this.GameWindowCenter.Y, 1f, color);
  410. }
  411.  
  412. if (bounds)
  413. {
  414. if (!Boxed3D || a >= 100.0)
  415. {
  416. 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);
  417. }
  418. else if (a < 100.0)
  419. {
  420. float wOffset = (boxHeight < 1f) ? boxHeight : 1f;
  421. float zOffset = (boxHeight > 1f) ? boxHeight / 2 : 0f;
  422. double num5 = pos.Z + ((1.0 * Math.Cos((double)pitch)) * Math.Cos((double)yaw));
  423. double num6 = pos.X + ((1.0 * Math.Cos((double)pitch)) * Math.Sin((double)yaw));
  424. double num7 = pos.Y + (1.0 * Math.Sin((double)pitch));
  425. Vector3 vector = new Vector3((float)num6, (float)num7, (float)num5);
  426. Vector3 zero = Vector3.Zero;
  427. this.WorldToScreen(vector, out zero);
  428. DrawLine(dest.X, dest.Y, zero.X, zero.Y, 1f, color);
  429. num5 = pos.Z + (0.5 * Math.Cos(yaw + 0.78539816339744828));
  430. num6 = pos.X + (0.5 * Math.Sin(yaw + 0.78539816339744828));
  431. Vector3 vector4 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
  432. Vector3 screen = Vector3.Zero;
  433. this.WorldToScreen(vector4, out screen);
  434. num5 = pos.Z + (0.5 * Math.Cos(yaw + 5.497787143782138));
  435. num6 = pos.X + (0.5 * Math.Sin(yaw + 5.497787143782138));
  436. Vector3 vector6 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
  437. Vector3 vector7 = Vector3.Zero;
  438. this.WorldToScreen(vector6, out vector7);
  439. DrawLine(screen.X, screen.Y, vector7.X, vector7.Y, 1f, color);
  440. num5 = pos.Z + (0.5 * Math.Cos(yaw + 3.9269908169872414));
  441. num6 = pos.X + (0.5 * Math.Sin(yaw + 3.9269908169872414));
  442. Vector3 vector8 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
  443. Vector3 vector9 = Vector3.Zero;
  444. this.WorldToScreen(vector8, out vector9);
  445. DrawLine(vector7.X, vector7.Y, vector9.X, vector9.Y, 1f, color);
  446. num5 = pos.Z + (0.5 * Math.Cos(yaw + 2.3561944901923448));
  447. num6 = pos.X + (0.5 * Math.Sin(yaw + 2.3561944901923448));
  448. Vector3 vector10 = new Vector3((float)num6, pos.Y - zOffset, (float)num5);
  449. Vector3 vector11 = Vector3.Zero;
  450. this.WorldToScreen(vector10, out vector11);
  451. DrawLine(vector9.X, vector9.Y, vector11.X, vector11.Y, 1f, color);
  452. DrawLine(vector11.X, vector11.Y, screen.X, screen.Y, 1f, color);
  453. Vector3 vector12 = new Vector3(vector4.X, vector4.Y + boxHeight, vector4.Z);
  454. Vector3 vector13 = Vector3.Zero;
  455. this.WorldToScreen(vector12, out vector13);
  456. DrawLine(screen.X, screen.Y, vector13.X, vector13.Y, 1f, color);
  457. Vector3 vector14 = new Vector3(vector6.X, vector6.Y + boxHeight, vector6.Z);
  458. Vector3 vector15 = Vector3.Zero;
  459. this.WorldToScreen(vector14, out vector15);
  460. DrawLine(vector13.X, vector13.Y, vector15.X, vector15.Y, 1f, color);
  461. DrawLine(vector7.X, vector7.Y, vector15.X, vector15.Y, 1f, color);
  462. Vector3 vector16 = new Vector3(vector8.X, vector8.Y + boxHeight, vector8.Z);
  463. Vector3 vector17 = Vector3.Zero;
  464. this.WorldToScreen(vector16, out vector17);
  465. DrawLine(vector15.X, vector15.Y, vector17.X, vector17.Y, 1f, color);
  466. DrawLine(vector9.X, vector9.Y, vector17.X, vector17.Y, 1f, color);
  467. Vector3 vector18 = new Vector3(vector10.X, vector10.Y + boxHeight, vector10.Z);
  468. Vector3 vector19 = Vector3.Zero;
  469. this.WorldToScreen(vector18, out vector19);
  470. DrawLine(vector17.X, vector17.Y, vector19.X, vector19.Y, 1f, color);
  471. DrawLine(vector11.X, vector11.Y, vector19.X, vector19.Y, 1f, color);
  472. DrawLine(vector19.X, vector19.Y, vector13.X, vector13.Y, 1f, color);
  473. }
  474. }
  475. DrawText(text, (int)dest.X, (int)dest.Y - 20, color, true);
  476. }
  477. }
  478. #endregion
  479.  
  480. public void DoProcess()
  481. {
  482. Main.IsRunning = true;
  483. GameWindowHandle = GameMemory.Process.MainWindowHandle;
  484. Native.SetForegroundWindow(GameWindowHandle);
  485.  
  486. DXDevice.SetRenderState(RenderState.ZEnable, false);
  487. DXDevice.SetRenderState(RenderState.Lighting, false);
  488. DXDevice.SetRenderState<Cull>(RenderState.CullMode, Cull.None);
  489.  
  490. RECT rDone = new RECT();
  491. while (GameWindowHandle != IntPtr.Zero && Main.IsRunning && GameMemory.IsOpen)
  492. {
  493. RECT rCurrent = GetWindowRect(GameWindowHandle);
  494. if (!rCurrent.Equals(rDone))
  495. {
  496. rDone = rCurrent;
  497. this.GameWindowRect = GetWindowRect(GameWindowHandle);
  498. this.GameWindowSize.X = this.GameWindowRect.Right - this.GameWindowRect.Left;
  499. this.GameWindowSize.Y = this.GameWindowRect.Bottom - this.GameWindowRect.Top;
  500. this.GameWindowCenter.X = this.GameWindowRect.Left + (this.GameWindowSize.X / 2);
  501. this.GameWindowCenter.Y = this.GameWindowRect.Top + (this.GameWindowSize.Y / 2) + 11;
  502. }
  503.  
  504. DXDevice.Clear(ClearFlags.Target, Color.Empty, 1f, 0);
  505. DXDevice.BeginScene();
  506.  
  507. long entityOffset = GameMemory.ReadInt64(CGameOffset);
  508.  
  509. // cars //
  510. long playerOffset = GameMemory.ReadInt64(entityOffset + 0x11D8);
  511. long posOffset = GameMemory.ReadInt64(playerOffset + 0x198);
  512. Main.ePlayer = new ENTITY();
  513. Main.ePlayer.Pos = new Vector3()
  514. {
  515. X = GameMemory.ReadFloat(posOffset + 0x100),
  516. Y = GameMemory.ReadFloat(posOffset + 0x104),
  517. Z = GameMemory.ReadFloat(posOffset + 0x108)
  518.  
  519. };
  520. Main.ePlayer.Yaw = GameMemory.ReadFloat(playerOffset + 0x240);
  521.  
  522. if (ShowPosition)
  523. {
  524. TextRegion = new POINT(this.GameWindowRect.Left + 15, this.GameWindowRect.Top + 35);
  525. 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);
  526. }
  527.  
  528. ShowESP = (!HideESPWhenAiming || Convert.ToBoolean(Native.GetAsyncKeyState(2) & 0x8000) == false);
  529.  
  530. List<ENTITY> entity_list = new List<ENTITY>();
  531.  
  532. int entityCount = GameMemory.ReadInt32(entityOffset + 0x688);
  533. long entityEntry = GameMemory.ReadInt64(playerOffset + 0x410);
  534.  
  535. for (int i = 1; i < entityCount; i++)
  536. {
  537. ENTITY n = new ENTITY();
  538. n.Id = GameMemory.ReadInt32(entityEntry + 0x620);
  539. n.Type = GameMemory.ReadInt32(entityEntry + 0x5C8);
  540.  
  541. // Vehicle Position//
  542. if (n.Type == 0x11 || n.Type == 0x72 || n.Type == 0x76)
  543. {
  544. n.Pos.X = GameMemory.ReadFloat(entityEntry + 0x100);
  545. n.Pos.Y = GameMemory.ReadFloat(entityEntry + 0x104);
  546. n.Pos.Z = GameMemory.ReadFloat(entityEntry + 0x108);
  547. }
  548. else // All others //
  549. {
  550. posOffset = GameMemory.ReadInt64(entityEntry + 0x198);
  551. n.Pos.X = GameMemory.ReadFloat(posOffset + 0x100);
  552. n.Pos.Y = GameMemory.ReadFloat(posOffset + 0x104);
  553. n.Pos.Z = GameMemory.ReadFloat(posOffset + 0x108);
  554. }
  555. posOffset = GameMemory.ReadInt64(entityEntry + 0x198);
  556. n.Pos.X = GameMemory.ReadFloat(entityEntry + 0x100);
  557. n.Pos.Y = GameMemory.ReadFloat(entityEntry + 0x104);
  558. n.Pos.Z = GameMemory.ReadFloat(entityEntry + 0x108);
  559.  
  560.  
  561. n.Speed = GameMemory.ReadFloat(entityEntry + 0x2C8);
  562.  
  563. n.Yaw = GameMemory.ReadFloat(entityEntry + 0x2E0);
  564.  
  565. n.Pitch = 0f;
  566.  
  567. n.Name = GameMemory.ReadString(GameMemory.ReadInt64(entityEntry + 0x4E0), GameMemory.ReadInt32(entityEntry + 0x4E8));
  568. //alive bytes
  569. n.IsAlive = Convert.ToBoolean(GameMemory.ReadByte(entityEntry + 0x138C));
  570.  
  571. //HP
  572. n.Health = GameMemory.ReadUInt32(GameMemory.ReadInt64(entityEntry + 0x4076) + 0xB0) / 100;
  573.  
  574.  
  575. entity_list.Add(n);
  576.  
  577. switch (n.Type)
  578. {
  579. case 0x04:
  580. case 0x05: // 0x04 maybe useless, not verified, but players are now 0x05
  581. if (ShowESP && ShowPlayers && n.IsAlive) this.EntityToScreen(n.Pos, n.Name + " " + n.Health, Color.SkyBlue, true, false, BoxedPlayers, 2f, n.Yaw, n.Pitch);
  582. break;
  583. case 0x13/*Deer*/:
  584. case 0x55/*Rabbit*/:
  585. if (ShowESP && ShowAnimals && n.IsAlive) this.EntityToScreen(n.Pos, n.Name, Color.DarkGreen, true, false, BoxedAnimals, 2f, n.Yaw, n.Pitch);
  586. break;
  587. case 0x14/*Wolf*/:
  588. case 0x50/*Bear*/:
  589. case 0x0C/*Zombie*/:
  590. case 0x5b/*Zombie*/:
  591. if (ShowESP && ShowAggressive && n.IsAlive) this.EntityToScreen(n.Pos, n.Name, Color.Red, true, false, BoxedAggressive, 2f, n.Yaw, n.Pitch);
  592. break;
  593. case 0x34: // Weapons
  594. if (ShowESP && ShowWeapons) this.EntityToScreen(n.Pos, n.Name, Color.GreenYellow, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  595. break;
  596. case 0x2E: // Loot
  597. if (ShowESP && ShowItems) this.EntityToScreen(n.Pos, n.Name, Color.GreenYellow, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  598. break;
  599. case 0x6D: // Stash
  600. case 0x9C: // Land Mine
  601. if (ShowESP && ShowItems) this.EntityToScreen(n.Pos, n.Name, Color.SaddleBrown, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  602. break;
  603. case 0x33: // Storage Container
  604. if (ShowESP && ShowContainers) this.EntityToScreen(n.Pos, n.Name, Color.Gray, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  605. break;
  606. case 0x15: // Ammo
  607. if (ShowESP && ShowAmmo) this.EntityToScreen(n.Pos, n.Name, Color.Orange, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  608. break;
  609. case 0x11: // OffRoad
  610. case 0x72: // Pickup
  611. case 0x76: // PoliceCar
  612. if (ShowESP && ShowVehicles) this.EntityToScreen(n.Pos, n.Name, Color.HotPink, true, false, BoxedVehicles, 2f, n.Yaw, n.Pitch);
  613. break;
  614. case 0x2C: // Battery & Sparkplugs
  615. if (ShowESP && ShowItems)
  616. {
  617. if (n.Name.Contains("Battery") || n.Name.Contains("Sparkplugs"))
  618. {
  619. this.EntityToScreen(n.Pos, n.Name, Color.DeepPink, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  620. }
  621. else
  622. {
  623. this.EntityToScreen(n.Pos, n.Name, Color.White, true, false, BoxedItems, 1f, n.Yaw, n.Pitch);
  624. }
  625. }
  626. break;
  627. case 0x16: // Dresser
  628. case 0x17: // Armoire
  629. case 0x19: // World Doors
  630. case 0x1D: // Cabinets
  631. case 0x1E: // Cabinets
  632. case 0x21: // Cabinets
  633. case 0x22: // Cabinets
  634. case 0x23: // Cabinets
  635. case 0x25: // Refrigerator
  636. case 0x26: // Garbage Can
  637. case 0x28: // Cabinets
  638. case 0x29: // Desk
  639. case 0x27: // Dumpster
  640. case 0x30: // File Cabinet
  641. case 0x31: // Tool Cabinet
  642. case 0x37: // Recycle Bin (with fire)
  643. case 0x38: // Punji Sticks
  644. case 0x3D: // Wooded Barricade
  645. case 0x3E: // Water Well
  646. case 0x3F: // Armoire
  647. case 0x40: // Dresser
  648. case 0x42: // Chest
  649. case 0x44: // Wrecked Sedan
  650. case 0x45: // Wrecked Van
  651. case 0x46: // Wrecked Truck
  652. case 0x49: // Ottoman
  653. case 0x4A: // Ottoman
  654. case 0x4F: // Designer-placed(?) Door
  655. case 0x5D: // File Cabinet
  656. case 0x61: // Cabinets
  657. case 0x63: // Cabinets
  658. case 0x6F: // Locker
  659. case 0x70: // Weapon Locker
  660. case 0x71: // Glass Cabinet
  661. case 0x79: // Designer-placed(?) Door
  662. case 0x7A: // Resting (Bed)
  663. case 0x7B: // Designer-placed(?) Door
  664. case 0x7C: // Designer-placed(?) Door
  665. case 0x80: // Cabinets
  666. case 0x81: // Cabinets
  667. case 0x82: // Cabinets
  668. case 0x83: // Cabinets
  669. case 0x84: // Cabinets
  670. case 0x85: // Cabinets
  671. case 0x86: // Cabinets
  672. case 0x87: // Cabinets
  673. case 0x88: // Cabinets
  674. case 0xA1: // Washing Machine
  675. case 0xA2: // Dryer
  676. case 0x7D: // IO.FireHydrant
  677. case 0x7E: // IO.FireHydrant
  678. //this.WorldToScreen(new Vector3(EntityX, EntityY, EntityZ), EntityName + "[" + EntityId.ToString("X2") + "]", Color.Gray, true, false, false, 0f, 0f);
  679. break;
  680.  
  681. case 0x4C: // Shed
  682. case 0x5F: // Metal Wall/Gate
  683. case 0x62: // Basic Shack Door
  684. case 0x6E: // Desk Foundation
  685. case 0x9E: // Metal Door
  686. case 0xA6: // Large Shelter
  687. case 0xA7: // Shed
  688. //this.WorldToScreen(new Vector3(EntityX, EntityY, EntityZ), EntityName + "[" + EntityId.ToString("X2") + "]", Color.Gray, true, false, false, 0f, 0f);
  689. break;
  690.  
  691. default: // Other Items
  692. //if (ShowESP && ShowItems) this.EntityToScreen(n.Pos, n.Name + "[" + n.Type.ToString("X2") + "]", Color.White, true, false, false, 1f, 0f, 0f);
  693. break;
  694.  
  695. }
  696.  
  697. entityEntry = GameMemory.ReadInt64(entityEntry + 0x410);
  698. }
  699.  
  700. if (ShowRadar)
  701. {
  702. DrawFilledBox(this.GameWindowRect.Right - 225, this.GameWindowRect.Top + 50, 201f, 201f, Color.DimGray, RadarTransparency);
  703. DrawBoxAbs(this.GameWindowRect.Right - 225, this.GameWindowRect.Top + 50, 201f, 201f, 1f, Color.Black);
  704. DrawLine(this.GameWindowRect.Right - 125, this.GameWindowRect.Top + 50, this.GameWindowRect.Right - 125, this.GameWindowRect.Top + 251, 1f, Color.Black);
  705. DrawLine(this.GameWindowRect.Right - 225, this.GameWindowRect.Top + 150, this.GameWindowRect.Right - 24, this.GameWindowRect.Top + 150, 1f, Color.Black);
  706. RadarCenter = new Vector2(this.GameWindowRect.Right - 125, this.GameWindowRect.Top + 125 + 25);
  707. DrawFilledBox(RadarCenter.X - 1f, RadarCenter.Y - 1f, 3f, 3f, Color.White);
  708. if (RadarCenter.Length() > 0f)
  709. {
  710. foreach (ENTITY entity in entity_list)
  711. {
  712. Vector2 pointToRotate = new Vector2(entity.Pos.X, entity.Pos.Z);
  713. Vector2 vector3 = new Vector2(Main.ePlayer.Pos.X, Main.ePlayer.Pos.Z);
  714. pointToRotate = vector3 - pointToRotate;
  715. float num30 = pointToRotate.Length() * 0.5f;
  716. num30 = Math.Min(num30, 90f);
  717. pointToRotate.Normalize();
  718. pointToRotate = (Vector2)(pointToRotate * num30);
  719. pointToRotate += RadarCenter;
  720. pointToRotate = RotatePoint(pointToRotate, RadarCenter, Main.ePlayer.Yaw, true);
  721. if (entity.Type == 0x04 && RadarPlayers)
  722. {
  723. DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.SkyBlue);
  724. }
  725. if ((entity.Type == 0x0C || entity.Type == 0x14 || entity.Type == 0x50 || entity.Type == 0x5b) && RadarAggressive)
  726. {
  727. DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.Red);
  728. }
  729. if ((entity.Type == 0x13 || entity.Type == 0x55) && RadarAnimals)
  730. {
  731. DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.LightGreen);
  732. }
  733. if ((entity.Type == 0x11 || entity.Type == 0x72 || entity.Type == 0x76) && RadarVehicles)
  734. {
  735. DrawFilledBox(pointToRotate.X, pointToRotate.Y, 3f, 3f, Color.HotPink);
  736. }
  737. }
  738. }
  739. }
  740.  
  741. entity_list.Clear();
  742.  
  743. if (ShowCities)
  744. {
  745. this.EntityToScreen(new Vector3(-129f, 40f, -1146f), "Pleasant Valley", Color.DarkViolet, true, false, false, 0f, 0f, 0f);
  746. this.EntityToScreen(new Vector3(-1233f, 90f, 1855f), "Cranberry", Color.DarkViolet, true, false, false, 0f, 0f, 0f);
  747. this.EntityToScreen(new Vector3(2003f, 50f, 2221f), "Ranchito", Color.DarkViolet, true, false, false, 0f, 0f, 0f);
  748. }
  749.  
  750. if (Main.ShowMap && (DXTextrureMap != null || DXTextrureMapLarge != null))
  751. {
  752. DXSprite.Begin(SpriteFlags.AlphaBlend);
  753. if (Main.ShowMapLarge && DXTextrureMapLarge != null)
  754. {
  755. map_pos_x = RemapValue(Main.ePlayer.Pos.X, 4000f, -4000f, -512f, 512f);
  756. map_pos_z = RemapValue(Main.ePlayer.Pos.Z, -4000f, 4000f, -512f, 512f);
  757. DXSprite.Draw(DXTextrureMapLarge, new Vector3(512f, 512f, 0f), new Vector3(this.GameWindowCenter.X, this.GameWindowCenter.Y, 0f), Color.FromArgb(MapTransparency, 0xff, 0xff, 0xff));
  758. }
  759. else if (DXTextrureMap != null)
  760. {
  761. map_pos_x = RemapValue(Main.ePlayer.Pos.X, 4000f, -4000f, -265f, 265f);
  762. map_pos_z = RemapValue(Main.ePlayer.Pos.Z, -4000f, 4000f, -265f, 265f);
  763. DXSprite.Draw(DXTextrureMap, new Vector3(256f, 256f, 0f), new Vector3(this.GameWindowCenter.X, this.GameWindowCenter.Y, 0f), Color.FromArgb(MapTransparency, 0xff, 0xff, 0xff));
  764. }
  765. DXSprite.End();
  766. float direction = Main.ePlayer.Yaw * -1f;
  767. float fromX = (float)((this.GameWindowCenter.X + map_pos_z) + (20.0 * Math.Cos(direction)));
  768. float fromY = (float)((this.GameWindowCenter.Y + map_pos_x) + (20.0 * Math.Sin(direction)));
  769. DrawFilledBox((this.GameWindowCenter.X + map_pos_z) - 2f, (this.GameWindowCenter.Y + map_pos_x) - 2f, 6f, 6f, Color.Magenta);
  770. DrawLine(fromX, fromY, (this.GameWindowCenter.X + map_pos_z) + 1f, (this.GameWindowCenter.Y + map_pos_x) + 1f, 1f, Color.PaleVioletRed);
  771. }
  772.  
  773. DXDevice.EndScene();
  774. DXDevice.Present();
  775. }
  776. DXDevice.Dispose();
  777. Application.Exit();
  778. }
  779.  
  780. protected override void WndProc(ref Message m)
  781. {
  782. if (m.Msg == 0x312)
  783. {
  784. switch ((int)m.WParam)
  785. {
  786. case 0:
  787. if (this.Settings != null && this.Settings.Visible)
  788. {
  789. this.Settings.Close();
  790. break;
  791. }
  792. this.Settings = new Settings(); this.Settings.Show();
  793. this.Settings.Location = new Point(this.GameWindowRect.Right - this.Settings.Width - 20, this.GameWindowRect.Top + 200);
  794. Native.SetForegroundWindow(GameMemory.Process.MainWindowHandle);
  795. break;
  796.  
  797. case 1:
  798. ShowRadar = !ShowRadar;
  799. Main.Ini.IniWriteValue("Radar", "Show", ShowRadar.ToString());
  800. break;
  801.  
  802. case 2:
  803. ShowMap = !ShowMap;
  804. break;
  805.  
  806. case 3:
  807. ShowMapLarge = !ShowMapLarge;
  808. Main.Ini.IniWriteValue("Map", "LargeMap", Main.ShowMapLarge.ToString());
  809. break;
  810.  
  811. case 4:
  812. Main.IsRunning = false;
  813. break;
  814. }
  815. }
  816. base.WndProc(ref m);
  817. }
  818.  
  819. public static bool HideESPAiming { get; set; }
  820. }
  821. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement