private void DrawPlayerBlood(float x, float y, float h, float w, float fBlood) { if (fBlood > 70.0) { //FillRGB(x, y, 5, h, TextBlack); //FillRGB(x, y, 5, h * fBlood / 100.0, TextGreen); _graphics.FillRectangle(_black, Rectangle.Create(x, y, w, h)); _graphics.FillRectangle(_green, Rectangle.Create(x, y, w, h * fBlood / 100)); } if (fBlood > 30.0 && fBlood <= 70.0) { //FillRGB(x, y, 5, h, TextBlack); //FillRGB(x, y, 5, h * fBlood / 100.0, TextYellow); _graphics.FillRectangle(_black, Rectangle.Create(x, y, w, h)); _graphics.FillRectangle(_yellow, Rectangle.Create(x, y, w, h * fBlood / 100)); } if (fBlood > 0.0 && fBlood <= 30.0) { //FillRGB(x, y, 5, h, TextBlack); //FillRGB(x, y, 5, h * fBlood / 100.0, TextRed); _graphics.FillRectangle(_black, Rectangle.Create(x, y, w, h)); _graphics.FillRectangle(_red, Rectangle.Create(x, y, w, h * fBlood / 100)); } }
/// <summary> /// Creates a new RoundedRectangle using the given dimension and radius. /// </summary> /// <param name="x">The x-coordinate of the upper-left corner of the Rectangle.</param> /// <param name="y">The y-coordinate of the upper-left corner of the Rectangle.</param> /// <param name="width">The width of the Rectangle.</param> /// <param name="height">The height of the Rectangle.</param> /// <param name="radius">A value indicating the radius of the corners of a RoundedRectangle.</param> /// <returns>The RoundedRectangle this method creates.</returns> public static RoundedRectangle Create(float x, float y, float width, float height, float radius) { return(new RoundedRectangle(Rectangle.Create(x, y, width, height), radius)); }
private static void Main(string[] args) { // Read settings DataContractJsonSerializer Settings = new DataContractJsonSerializer(typeof(Settings[])); Settings settings = null; Settings auto_config = new Settings(320, 320, "game", true, Keys.MButton, Keys.Insert, Keys.Home, Keys.NumPad9, 0.1f, true, false, true, Keys.XButton1); using (FileStream fs = new FileStream("config.json", FileMode.OpenOrCreate)) { if (fs.Length == 0) { Settings.WriteObject(fs, new Settings[1] { auto_config }); fs.Close(); File.WriteAllText("config.json", File.ReadAllText("config.json").Replace(",", ",\n")); MessageBox.Show($"Created auto-config, change whatever settings you want and restart."); return; } else { settings = ((Settings[])Settings.ReadObject(fs))[0]; } } //Vars size.X = settings.SizeX; size.Y = settings.SizeY; string game = settings.Game; bool SimpleRCS = settings.SimpleRCS; Keys AimKey = settings.AimKey; Keys TrainModeKey = settings.TrainModeKey; Keys ScreenshotKey = settings.ScreenshotKey; Keys ScreenshotModeKey = settings.ScreenshotModeKey; float SmoothAim = settings.SmoothAim; bool Information = settings.Information; bool Head = settings.Head; bool AutoShoot = settings.AutoShoot; Keys TriggerBotKey = settings.TriggerBotKey; System.Drawing.Point CenterScreen = new System.Drawing.Point(Screen.PrimaryScreen.Bounds.Width / 2, Screen.PrimaryScreen.Bounds.Height / 2); bool CursorToCenter = false; int i = 0; int selectedObject = 0; int shooting = 0; string[] objects = null; OverlayWindow _window; GameOverlay.Drawing.Graphics _graphics; bool trainingMode = false; screenshotMode = false; YoloWrapper yoloWrapper = null; //Check compatibility while (Process.GetProcessesByName(game).Count() == 0) { DialogResult dialogResult = MessageBox.Show($"You have not launched {game} yet.", "Game not found", MessageBoxButtons.RetryCancel); if (dialogResult == DialogResult.Retry) { continue; } else { Process.GetCurrentProcess().Kill(); } } if (File.Exists($"trainfiles/{game}.cfg") && File.Exists($"trainfiles/{game}.weights") && File.Exists($"trainfiles/{game}.names")) { yoloWrapper = new YoloWrapper($"trainfiles/{game}.cfg", $"trainfiles/{game}.weights", $"trainfiles/{game}.names"); Console.Clear(); if (yoloWrapper.EnvironmentReport.CudaExists == false) { giveErrorMessage("Install CUDA 10"); } if (yoloWrapper.EnvironmentReport.CudnnExists == false) { giveErrorMessage("Cudnn doesn't exist"); } if (yoloWrapper.EnvironmentReport.MicrosoftVisualCPlusPlus2017RedistributableExists == false) { giveErrorMessage("Install Microsoft Visual C++ 2017 Redistributable"); } if (yoloWrapper.DetectionSystem.ToString() != "GPU") { giveErrorMessage("No GPU card detected. Exiting..."); } objects = File.ReadAllLines($"trainfiles/{game}.names"); } else { trainingMode = true; MessageBox.Show($"Looks like you have not configured settings for {game}... Let's train the Neural Network! :)\n Preparing files for training...."); Console.Write("How many objects will the NN be analyzing and training on? Write each object's name via the separator ',' without spaces (EX: 1,2): "); objects = Console.ReadLine().Split(','); } PrepareFiles(game); Random random = new Random(); //Make transparent window for drawing _window = new OverlayWindow(0, 0, size.X, size.Y) { IsTopmost = true, IsVisible = true }; _graphics = new GameOverlay.Drawing.Graphics() { MeasureFPS = true, Height = _window.Height, PerPrimitiveAntiAliasing = true, TextAntiAliasing = true, UseMultiThreadedFactories = false, VSync = true, Width = _window.Width, WindowHandle = IntPtr.Zero }; _window.CreateWindow(); _graphics.WindowHandle = _window.Handle; _graphics.Setup(); GameOverlay.Drawing.SolidBrush greenbrush = _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Green); GameOverlay.Drawing.SolidBrush redbrush = _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red); GameOverlay.Drawing.SolidBrush bluebrush = _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue); GameOverlay.Drawing.Graphics gfx = _graphics; System.Drawing.Rectangle trainBox = new System.Drawing.Rectangle(0, 0, size.X / 2, size.Y / 2); while (true) { coordinates = CursorToCenter ? CenterScreen : Cursor.Position; if (screenshotMode) { bitmap = new Bitmap(CaptureWindow(game, true), size.X, size.Y); } else { bitmap = new Bitmap(CaptureWindow(game, false), size.X, size.Y); } trainBox.X = size.X / 2 - trainBox.Width / 2; trainBox.Y = size.Y / 2 - trainBox.Height / 2; if (isKeyToggled(TrainModeKey)) { if (yoloWrapper != null) { objects = File.ReadAllLines($"trainfiles/{game}.names"); trainingMode = !trainingMode; } } if (isKeyToggled(ScreenshotModeKey)) { screenshotMode = !screenshotMode; } _window.X = coordinates.X - size.X / 2; _window.Y = coordinates.Y - size.Y / 2; gfx.BeginScene(); gfx.ClearScene(); gfx.DrawRectangle(greenbrush, 0, 0, size.X, size.Y, 2); if (isKeyToggled(Keys.NumPad0)) { CursorToCenter = !CursorToCenter; } if (trainingMode) { int rand = random.Next(5000, 999999); if (isKeyPressed(Keys.Left)) { if (trainBox.Width <= 0) { continue; } trainBox.Width -= 1; } if (isKeyPressed(Keys.Down)) { if (trainBox.Height >= size.Y) { continue; } trainBox.Height += 1; } if (isKeyPressed(Keys.Right)) { if (trainBox.Width >= size.X) { continue; } trainBox.Width += 1; } if (isKeyPressed(Keys.Up)) { if (trainBox.Height <= 0) { continue; } trainBox.Height -= 1; } gfx.DrawText(_graphics.CreateFont("Arial", 14), redbrush, new GameOverlay.Drawing.Point(0, 0), $"Training mode. Object: {objects[selectedObject]}" + Environment.NewLine + $"ScreenshotMode: {(screenshotMode == true ? "following" : "centered")}" + Environment.NewLine + $"CursorToCenter: {CursorToCenter}"); gfx.DrawRectangle(bluebrush, Rectangle.Create(trainBox.X, trainBox.Y, trainBox.Width, trainBox.Height), 1); gfx.DrawRectangle(redbrush, Rectangle.Create(trainBox.X + Convert.ToInt32(trainBox.Width / 2.9), trainBox.Y, Convert.ToInt32(trainBox.Width / 3), trainBox.Height / 7), 2); if (isKeyToggled(Keys.PageUp)) { selectedObject = (selectedObject + 1) % objects.Count(); } if (isKeyToggled(Keys.PageDown)) { selectedObject = (selectedObject - 1 + objects.Count()) % objects.Count(); } if (isKeyToggled(ScreenshotKey)) { float relative_center_x = (float)(trainBox.X + trainBox.Width / 2) / size.X; float relative_center_y = (float)(trainBox.Y + trainBox.Height / 2) / size.Y; float relative_width = (float)trainBox.Width / size.X; float relative_height = (float)trainBox.Height / size.Y; bitmap.Save($"darknet/data/img/{game}{i.ToString()}{rand}.png", System.Drawing.Imaging.ImageFormat.Png); File.WriteAllText($"darknet/data/img/{game}{i.ToString()}{rand}.txt", string.Format("{0} {1} {2} {3} {4}", selectedObject, relative_center_x, relative_center_y, relative_width, relative_height).Replace(",", ".")); i++; Console.Beep(); } if (isKeyToggled(Keys.Back)) { bitmap.Save($"darknet/data/img/{game}{i.ToString()}{rand}.png", System.Drawing.Imaging.ImageFormat.Png); File.WriteAllText($"darknet/data/img/{game}{i.ToString()}{rand}.txt", ""); i++; Console.Beep(); } if (isKeyToggled(Keys.End)) { gfx.ClearScene(); gfx.EndScene(); Console.WriteLine("Okay, we have the pictures for training. Let's train the Neural Network...."); File.WriteAllText($"darknet/{game}.cfg", File.ReadAllText($"darknet/{game}.cfg").Replace("NUMBER", objects.Count().ToString()).Replace("FILTERNUM", ((objects.Count() + 5) * 3).ToString())); File.WriteAllText($"darknet/{game}.cfg", File.ReadAllText($"darknet/{game}.cfg").Replace("batch=1", "batch=64").Replace("subdivisions=1", "subdivisions=8")); File.WriteAllText($"darknet/data/{game}.data", File.ReadAllText($"darknet/data/{game}.data").Replace("NUMBER", objects.Count().ToString()).Replace("GAME", game)); File.WriteAllText($"darknet/{game}.cmd", File.ReadAllText($"darknet/{game}.cmd").Replace("GAME", game)); File.WriteAllText($"darknet/{game}_trainmore.cmd", File.ReadAllText($"darknet/{game}_trainmore.cmd").Replace("GAME", game)); File.WriteAllText($"darknet/data/{game}.names", string.Join("\n", objects)); // DirectoryInfo d = ;//Assuming Test is your Folder FileInfo[] Files = new DirectoryInfo(Application.StartupPath + @"\darknet\data\img").GetFiles($"{game}*.png"); //Getting Text files string PathOfImg = ""; foreach (FileInfo file in Files) { PathOfImg += $"data/img/{file.Name}\r\n"; } File.WriteAllText($"darknet/data/{game}.txt", PathOfImg); DialogResult dialogResult = MessageBox.Show($"Traing requires your gpu. Do you want to close the game?", "Close game", MessageBoxButtons.YesNo); if (dialogResult == DialogResult.Yes) { Process.GetProcessesByName(game)[0].Kill(); } if (File.Exists($"trainfiles/{game}.weights")) { File.Copy($"trainfiles/{game}.weights", $"darknet/{game}.weights", true); Process.Start("cmd", @"/C cd " + Application.StartupPath + $"/darknet/ & {game}_trainmore.cmd"); } else { Process.Start("cmd", @"/C cd " + Application.StartupPath + $"/darknet/ & {game}.cmd"); } Console.WriteLine("When you have finished training the NN, write \"done\" in this console."); while (true) { if (Console.ReadLine() == "done") { File.Copy($"darknet/data/backup/{game}_last.weights", $"trainfiles/{game}.weights", true); File.Copy($"darknet/data/{game}.names", $"trainfiles/{game}.names", true); File.Copy($"darknet/{game}.cfg", $"trainfiles/{game}.cfg", true); File.WriteAllText($"trainfiles/{game}.cfg", File.ReadAllText($"trainfiles/{game}.cfg").Replace("batch=64", "batch=1").Replace("subdivisions=8", "subdivisions=1")); yoloWrapper = new YoloWrapper($"trainfiles/{game}.cfg", $"trainfiles/{game}.weights", $"trainfiles/{game}.names"); trainingMode = false; break; } else { Console.WriteLine("When you have finished training the NN, write \"done\" in this console."); } } Console.WriteLine("Okay! Training has finished. Let's check detection in the game!"); gfx.BeginScene(); } } else { if (isKeyToggled(Keys.PageUp)) { selectedObject = (selectedObject + 1) % objects.Count(); } if (isKeyToggled(Keys.Up)) { SmoothAim = Math.Min(SmoothAim + 0.05f, 1); } if (isKeyToggled(Keys.Down)) { SmoothAim = Math.Max(SmoothAim - 0.05f, 0); } if (isKeyToggled(Keys.Delete)) { Head = !Head; } if (isKeyToggled(Keys.Home)) { shooting = 0; SimpleRCS = !SimpleRCS; } if (isKeyToggled(Keys.End)) { AutoShoot = !AutoShoot; } if (isKeyToggled(Keys.PageDown)) { selectedObject = (selectedObject - 1 + objects.Count()) % objects.Count(); } gfx.DrawText(_graphics.CreateFont("Arial", 10), redbrush, new GameOverlay.Drawing.Point(0, 0), $"Object {objects[selectedObject]};" + Environment.NewLine + $"SmoothAim {Math.Round(SmoothAim, 2)};" + Environment.NewLine + $"Head {Head};" + Environment.NewLine + $"SimpleRCS {SimpleRCS};" + Environment.NewLine + $"AutoShoot {AutoShoot};" + Environment.NewLine + $"TriggerBot {isKeyPressed(TriggerBotKey)};" + Environment.NewLine + $"CursorToCenter: {CursorToCenter}"); using (MemoryStream ms = new MemoryStream()) { bitmap.Save(ms, System.Drawing.Imaging.ImageFormat.Png); IEnumerable <Alturos.Yolo.Model.YoloItem> items = yoloWrapper.Detect(ms.ToArray()); if (SimpleRCS) { if (User32.GetAsyncKeyState(AimKey) == 0) { shooting = 0; } } if (items.Count() > 0) { foreach (var item in items) { if (item.Confidence > 0.4d) { Rectangle head = Rectangle.Create(item.X + Convert.ToInt32(item.Width / 2.9), item.Y, Convert.ToInt32(item.Width / 3), item.Height / 7); Rectangle body = Rectangle.Create(item.X + Convert.ToInt32(item.Width / 6), item.Y + item.Height / 6, Convert.ToInt32(item.Width / 1.5f), item.Height / 3); if (Information) { if (Head) { gfx.DrawTextWithBackground(_graphics.CreateFont("Arial", 12), redbrush, _graphics.CreateSolidBrush(0, 0, 0), new GameOverlay.Drawing.Point(item.X + item.Width, item.Y + item.Width), $"{item.Type} {DistanceBetweenCross(head.Left + head.Width / 2, head.Top + head.Height / 2)}"); } else { gfx.DrawTextWithBackground(_graphics.CreateFont("Arial", 12), redbrush, _graphics.CreateSolidBrush(0, 0, 0), new GameOverlay.Drawing.Point(item.X + item.Width, item.Y + item.Width), $"{item.Type} {DistanceBetweenCross(body.Left + body.Width / 2, body.Top + body.Height / 2)}"); } } if (item.Type == objects[selectedObject]) { gfx.DrawRectangle(redbrush, Rectangle.Create(item.X, item.Y, item.Width, item.Height), 2); if (Head) { gfx.DrawRectangle(bluebrush, head, 2); gfx.DrawCrosshair(bluebrush, head.Left + head.Width / 2, head.Top + head.Height / 2 + Convert.ToInt32(1 * shooting), 2, 2, CrosshairStyle.Cross); gfx.DrawLine(bluebrush, size.X / 2, size.Y / 2, head.Left + head.Width / 2, head.Top + head.Height / 2 + Convert.ToInt32(1 * shooting), 2); } else { gfx.DrawRectangle(bluebrush, body, 2); gfx.DrawCrosshair(bluebrush, body.Left + body.Width / 2, body.Top + body.Height / 2 + Convert.ToInt32(1 * shooting), 2, 2, CrosshairStyle.Cross); gfx.DrawLine(bluebrush, size.X / 2, size.Y / 2, body.Left + body.Width / 2, body.Top + body.Height / 2 + Convert.ToInt32(1 * shooting), 2); } if (isKeyPressed(AimKey)) { if (Head) { Alturos.Yolo.Model.YoloItem nearestEnemy = items.Where(x => x.Type == objects[selectedObject]).OrderByDescending(x => DistanceBetweenCross(x.X + Convert.ToInt32(x.Width / 2.9) + (x.Width / 3) / 2, x.Y + (x.Height / 7) / 2)).Last(); Rectangle nearestEnemyHead = Rectangle.Create(nearestEnemy.X + Convert.ToInt32(nearestEnemy.Width / 2.9), nearestEnemy.Y, Convert.ToInt32(nearestEnemy.Width / 3), nearestEnemy.Height / 7 + (float)2 * shooting); if (SmoothAim <= 0) { User32.mouse_event(0x01, Convert.ToInt32(((nearestEnemyHead.Left - size.X / 2) + (nearestEnemyHead.Width / 2))), Convert.ToInt32((nearestEnemyHead.Top - size.Y / 2 + nearestEnemyHead.Height / 7 + 1 * shooting)), 0, (UIntPtr)0); if (AimKey != Keys.LButton && AutoShoot) { User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); if (SimpleRCS) { shooting += 2; } } } else { if (size.X / 2 < nearestEnemyHead.Left | size.X / 2 > nearestEnemyHead.Right | size.Y / 2 < nearestEnemyHead.Top | size.Y / 2 > nearestEnemyHead.Bottom) { User32.mouse_event(0x01, Convert.ToInt32(((nearestEnemyHead.Left - size.X / 2) + (nearestEnemyHead.Width / 2)) * SmoothAim), Convert.ToInt32((nearestEnemyHead.Top - size.Y / 2 + nearestEnemyHead.Height / 7 + 1 * shooting) * SmoothAim), 0, (UIntPtr)0); } else { if (AimKey != Keys.LButton && AutoShoot) { User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); } if (SimpleRCS) { shooting += 2; } } } } else { Alturos.Yolo.Model.YoloItem nearestEnemy = items.Where(x => x.Type == objects[selectedObject]).OrderByDescending(x => DistanceBetweenCross(x.X + Convert.ToInt32(x.Width / 6) + (x.Width / 1.5f) / 2, x.Y + x.Height / 6 + (x.Height / 3) / 2)).Last(); Rectangle nearestEnemyBody = Rectangle.Create(nearestEnemy.X + Convert.ToInt32(nearestEnemy.Width / 6), nearestEnemy.Y + nearestEnemy.Height / 6 + (float)2 * shooting, Convert.ToInt32(nearestEnemy.Width / 1.5f), nearestEnemy.Height / 3 + (float)2 * shooting); if (SmoothAim <= 0) { User32.mouse_event(0x01, Convert.ToInt32(((nearestEnemyBody.Left - size.X / 2) + (nearestEnemyBody.Width / 2))), Convert.ToInt32((nearestEnemyBody.Top - size.Y / 2 + nearestEnemyBody.Height / 7 + 1 * shooting)), 0, (UIntPtr)0); if (AimKey != Keys.LButton && AutoShoot) { User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); if (SimpleRCS) { shooting += 2; } } } else { if (size.X / 2 < nearestEnemyBody.Left | size.X / 2 > nearestEnemyBody.Right | size.Y / 2 < nearestEnemyBody.Top | size.Y / 2 > nearestEnemyBody.Bottom) { User32.mouse_event(0x01, Convert.ToInt32(((nearestEnemyBody.Left - size.X / 2) + (nearestEnemyBody.Width / 2)) * SmoothAim), Convert.ToInt32((nearestEnemyBody.Top - size.Y / 2 + nearestEnemyBody.Height / 7 + 1 * shooting) * SmoothAim), 0, (UIntPtr)0); } else { if (AimKey != Keys.LButton && AutoShoot) { User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); } if (SimpleRCS) { shooting += 2; } } } } //System.Threading.Thread.Sleep(120); } else if (isKeyPressed(TriggerBotKey)) { if (Head) { Alturos.Yolo.Model.YoloItem nearestEnemy = items.Where(x => x.Type == objects[selectedObject]).OrderByDescending(x => DistanceBetweenCross(x.X + Convert.ToInt32(x.Width / 2.9) + (x.Width / 3) / 2, x.Y + (x.Height / 7) / 2)).Last(); Rectangle nearestEnemyHead = Rectangle.Create(nearestEnemy.X + Convert.ToInt32(nearestEnemy.Width / 2.9), nearestEnemy.Y, Convert.ToInt32(nearestEnemy.Width / 3), nearestEnemy.Height / 7 + (float)2 * shooting); if (!(size.X / 2 < nearestEnemyHead.Left | size.X / 2 > nearestEnemyHead.Right | size.Y / 2 < nearestEnemyHead.Top | size.Y / 2 > nearestEnemyHead.Bottom)) { if (AutoShoot) { User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); if (SimpleRCS) { shooting += 2; } } } } else { Alturos.Yolo.Model.YoloItem nearestEnemy = items.Where(x => x.Type == objects[selectedObject]).OrderByDescending(x => DistanceBetweenCross(x.X + Convert.ToInt32(x.Width / 6) + (x.Width / 1.5f) / 2, x.Y + x.Height / 6 + (x.Height / 3) / 2)).Last(); Rectangle nearestEnemyBody = Rectangle.Create(nearestEnemy.X + Convert.ToInt32(nearestEnemy.Width / 6), nearestEnemy.Y + nearestEnemy.Height / 6 + (float)2 * shooting, Convert.ToInt32(nearestEnemy.Width / 1.5f), nearestEnemy.Height / 3 + (float)2 * shooting); if (!(size.X / 2 < nearestEnemyBody.Left | size.X / 2 > nearestEnemyBody.Right | size.Y / 2 < nearestEnemyBody.Top | size.Y / 2 > nearestEnemyBody.Bottom)) { if (AutoShoot) { User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); if (SimpleRCS) { shooting += 2; } } } } } } else { gfx.DrawRectangle(greenbrush, Rectangle.Create(item.X, item.Y, item.Width, item.Height), 2); } } } } else { if (SimpleRCS) { shooting = 0; } } } } gfx.FillRectangle(bluebrush, Rectangle.Create(size.X / 2, size.Y / 2, 4, 4)); gfx.EndScene(); } }
public void Update() { var gfx = _graphics; gfx.BeginScene(); gfx.ClearScene(_transparent); // Draw FPS //gfx.DrawTextWithBackground(_font, _red, _black, 10, 10, "FPS: " + gfx.FPS); // Draw Menu if (Settings.ShowMenu) { //gfx.FillRectangle(_menuBrush, 10f, _window.Height / 2 - 75, 180, _window.Height / 2 + 165); DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 65), " [ AM7 PUBG ] "); DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 50), "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"); DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 35), "ESP Menu"); if (Settings.PlayerESP) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 - 20), "Player ESP (Num1) : " + Settings.PlayerESP.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 20), "Player ESP (Num1) : " + Settings.PlayerESP.ToString()); } if (Settings.PlayerBox) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 - 5), "Player Box (Num2) : " + Settings.PlayerBox.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 - 5), "Player Box (Num2) : " + Settings.PlayerBox.ToString()); } if (Settings.PlayerBone) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 10), "Player Bone (Num3) : " + Settings.PlayerBone.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 10), "Player Bone (Num3) : " + Settings.PlayerBone.ToString()); } if (Settings.PlayerLines) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 25), "Player Line (Num4) : " + Settings.PlayerLines.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 25), "Player Line (Num4) : " + Settings.PlayerLines.ToString()); } if (Settings.PlayerHealth) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 40), "Player Health (Num5) : " + Settings.PlayerHealth.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 40), "Player Health (Num5) : " + Settings.PlayerHealth.ToString()); } if (Settings.ItemESP) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 55), "Item ESP (Num6) : " + Settings.ItemESP.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 55), "Item ESP (Num6) : " + Settings.ItemESP.ToString()); } if (Settings.VehicleESP) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 70), "Vehicle ESP (Num7) : " + Settings.VehicleESP.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 70), "Vehicle ESP (Num7) : " + Settings.VehicleESP.ToString()); } if (Settings.Player3dBox) { DrawShadowText(gfx, _font, _red, new Point(20f, _window.Height / 2 + 85), "Player 3D Box (Num8) : " + Settings.Player3dBox.ToString()); } else { DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 85), "Player 3D Box (Num8) : " + Settings.Player3dBox.ToString()); } DrawShadowText(gfx, _font, _green, new Point(20f, _window.Height / 2 + 100), "┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈┈"); } if (_data.Players.Length > 0) { playerCount = _data.Players.Length; DrawShadowText(gfx, _bigfont, _red, new Point(_window.Width / 2 - 40f, 40f), "Enemy near : " + playerCount); } // Read View Matrix long viewMatrixAddr = Mem.ReadMemory <int>(Mem.ReadMemory <int>(_data.ViewMatrixBase) + 32) + 512; D3DMatrix viewMatrix = Algorithms.ReadViewMatrix(viewMatrixAddr); // Draw Player ESP if (Settings.PlayerESP) { foreach (var player in _data.Players) { //if (player.Health <= 0) continue; if (Algorithms.WorldToScreenPlayer(viewMatrix, player.Position, out ShpVector3 playerScreen, out int distance, _window.Width, _window.Height)) { // Too Far not render if (distance > 500) { continue; } float x = playerScreen.X; float y = playerScreen.Y; float h = playerScreen.Z; float w = playerScreen.Z / 2; try { _boxBrush = _randomBrush[player.TeamID % 7]; } catch (IndexOutOfRangeException) { _boxBrush = _green; } //DrawShadowText(gfx,_font, _green, new Point((x - playerScreen.Z / 4) - 3, y - 15), player.Pose.ToString()); // Adjust Box if (player.Pose == 1114636288) { y = playerScreen.Y + playerScreen.Z / 5; h -= playerScreen.Z / 5; } if (player.Pose == 1112014848 || player.Status == 7) { y = playerScreen.Y + playerScreen.Z / 4; h -= playerScreen.Z / 4; } // Draw Info StringBuilder sb = new StringBuilder("["); if (player.IsRobot) { sb.Append("[Bot] "); } sb.Append(player.Name); DrawShadowText(gfx, _infoFont, _boxBrush, new Point(x + w / 2, y - 5), sb.ToString()); // Draw Distance sb = new StringBuilder("["); sb.Append(distance).Append("M]"); DrawShadowText(gfx, _font, _boxBrush, new Point(x + w / 2, y + 7), sb.ToString()); if (Settings.PlayerBox) { // Draw Box gfx.DrawRectangle(_boxBrush, Rectangle.Create(x - playerScreen.Z / 4 - 3, y - 5, w + 3, h + 5), 1); } if (Settings.Player3dBox) { Draw3DBox(viewMatrix, player, playerScreen, _window.Width, _window.Height, 180f); // Draw Box //gfx.DrawRectangle(_boxBrush, Rectangle.Create(x - playerScreen.Z / 4 - 3, y - 5, w + 3, h + 5), 1); } if (Settings.PlayerBone) { // Draw Bone long tmpAddv = Mem.ReadMemory <int>(player.Address + tmpOffset); long bodyAddv = tmpAddv + actorOffset; long boneAddv = Mem.ReadMemory <int>(tmpAddv + boneOffset) + 48; DrawPlayerBone(bodyAddv, boneAddv, w, viewMatrix, _window.Width, _window.Height); } if (Settings.PlayerHealth) { // Draw Health DrawPlayerBlood((x - playerScreen.Z / 4) - 8, y - 5, h + 5, 3, player.Health); } if (Settings.PlayerLines) { // Draw Line gfx.DrawLine(_white, new Line(_window.Width / 2, 0, x, y), 2); } } } } // Draw Item ESP if (Settings.ItemESP) { foreach (var item in _data.Items) { if (Algorithms.WorldToScreenItem(viewMatrix, item.Position, out ShpVector2 itemScreen, out int distance, _window.Width, _window.Height)) { // Too Far not render if (distance > 100) { continue; } // Draw Item string disStr = string.Format("[{0}m]", distance); DrawShadowText(gfx, _font, _yellow, new Point(itemScreen.X, itemScreen.Y), item.Name); DrawShadowText(gfx, _font, _yellow, new Point(itemScreen.X, itemScreen.Y + 10), disStr); } } foreach (var box in _data.Boxes) { if (Algorithms.WorldToScreenItem(viewMatrix, box.Position, out ShpVector2 itemScreen, out int distance, _window.Width, _window.Height)) { // Too Far not render if (distance > 100) { continue; } DrawShadowText(gfx, _font, _yellow, new Point(itemScreen.X, itemScreen.Y), "Lootbox [" + distance.ToString() + "M]"); } } } // Draw Vehicle ESP if (Settings.VehicleESP) { foreach (var car in _data.Vehicles) { if (Algorithms.WorldToScreenItem(viewMatrix, car.Position, out ShpVector2 carScreen, out int distance, _window.Width, _window.Height)) { // Too Far not render if (distance > 300) { continue; } string disStr = string.Format("[{0}m]", distance); // Draw Car DrawShadowText(gfx, _font, _blue, new Point(carScreen.X, carScreen.Y), car.Name); DrawShadowText(gfx, _font, _blue, new Point(carScreen.X, carScreen.Y + 10), disStr); } } } // Grenade alert foreach (var gre in _data.Grenades) { if (Algorithms.WorldToScreenItem(viewMatrix, gre.Position, out ShpVector2 greScreen, out int distance, _window.Width, _window.Height)) { DrawShadowText(gfx, _font, 15, _red, new Point(greScreen.X, greScreen.Y), string.Format("!!! {0} !!! [{1}M]", gre.Type.GetDescription(), distance)); } } gfx.EndScene(); }
private static void DrawBlip(GameOverlay.Drawing.Graphics gfx, FlatSDKInternal.Entity go) { FlatSDK.WorldToScreen(FlatSDK.Overlay.Width, FlatSDK.Overlay.Height, go.extra.FootPos, out Vector2 MaxOutput); bool w2s = FlatSDK.WorldToScreen(FlatSDK.Overlay.Width, FlatSDK.Overlay.Height, go.position, out Vector2 MinOutput); var distance = (go.position - LocalPlayer.position).Length() / 100; var fark2 = (go.extra.FootPos - go.position).Length() / 100; var fark = MinOutput.Y - MaxOutput.Y; string state = string.Empty; var FontSize = Math.Max(10, Math.Min(fark, 16.0f)); string HealthDSTR = ESPOptions.bShowHealth == 1 ? Math.Round(go.extra.health) + "hp" : string.Empty; string DistanceDSTR = ESPOptions.bShowDistance == 1? Math.Round(distance) + "mt" : string.Empty; if (ESPOptions.bShowState == 1) { if (fark2 > 3) { state = "| Driving |" + Environment.NewLine; } else if (fark2 > 0.88f && fark2 < 3) { state = "| Running |" + Environment.NewLine; } else if (fark2 < 0.5f && fark2 < 3) { state = "| Snake |" + Environment.NewLine; } else if (fark2 == 0.6f) { state = "| Crouch |" + Environment.NewLine; } else if (fark2 == 0.88f) { state = "| Stand |" + Environment.NewLine; } } if (w2s) { var topx = FlatSDK.Overlay.Width / 2; var topy = 0; if (ESPOptions.bSnapLines == 1) { if (fark2 > 3) { gfx.DrawLine(FlatSDKInternal.IRenderer._opakwhite, topx, topy, MinOutput.X, MinOutput.Y, 1); } else { gfx.DrawLine(FlatSDKInternal.IRenderer._opakwhite, topx, topy, MinOutput.X, MinOutput.Y - fark * 2.2f, 1); } } // 2DBOX if (ESPOptions.bShowBox == 1) { if (fark2 > 3) { gfx.OutlineRectangle(FlatSDKInternal.IRenderer._black, FlatSDKInternal.IRenderer._blue, Rectangle.Create(MinOutput.X, MinOutput.Y, 5, 5), 2); } else { gfx.OutlineRectangle(FlatSDKInternal.IRenderer._black, FlatSDKInternal.IRenderer._blue, Rectangle.Create(MinOutput.X - (fark / 2), MinOutput.Y - fark * 2.2f, fark, fark * 2.2f), 2); } } // TEXT if (ESPOptions.bShowState == 1 || ESPOptions.bShowDistance == 1 || ESPOptions.bShowHealth == 1) { gfx.DrawText(FlatSDKInternal.IRenderer._font, FontSize, FlatSDKInternal.IRenderer._white, MinOutput.X - FontSize - 10, MinOutput.Y, $"{DistanceDSTR} {HealthDSTR} {Environment.NewLine + state} "); } } }