public void SetupOSDWindow() { int screenWidth = (int)SystemParameters.PrimaryScreenWidth; int screenHeight = (int)SystemParameters.PrimaryScreenHeight; Console.WriteLine($"Screen Resolution: {screenWidth}x{screenHeight}"); osdWindow = new OverlayWindow(0, 0, screenWidth, screenHeight) { IsTopmost = true, IsVisible = true }; osdGraphics = new GameOverlay.Drawing.Graphics { MeasureFPS = false, Height = osdWindow.Height, Width = osdWindow.Width, PerPrimitiveAntiAliasing = true, TextAntiAliasing = true, UseMultiThreadedFactories = false, VSync = true, WindowHandle = IntPtr.Zero }; osdWindow.CreateWindow(); osdGraphics.WindowHandle = osdWindow.Handle; osdGraphics.Setup(); //testFont = osdGraphics.CreateFont(osdFont, 16f); }
public Visuals() { _window = new OverlayWindow(Main.ScreenRect.left, Main.ScreenRect.top, Main.ScreenSize.Width, Main.ScreenSize.Height) { IsTopmost = true, IsVisible = true }; _window.SizeChanged += _window_SizeChanged; _graphics = new GameOverlay.Drawing.Graphics() { MeasureFPS = true, Height = _window.Height, PerPrimitiveAntiAliasing = true, TextAntiAliasing = true, UseMultiThreadedFactories = false, VSync = true, Width = _window.Width, WindowHandle = IntPtr.Zero }; }
private void _window_DrawGraphics(object sender, DrawGraphicsEventArgs e) { try { Graphics gfx = e.Graphics; if (_window.X != config.Overlay_x || _window.Y != config.Overlay_y || _window.Width != config.Overlay_width || _window.Height != config.Overlay_height) { _window.X = config.Overlay_x; _window.Y = config.Overlay_y; _window.Width = config.Overlay_width; _window.Height = config.Overlay_height; _window.Recreate(); } if (_fonts["consolas"].FontSize != config.Overlay_FontSize) { SetOverlayFonts(); } var infoText = new StringBuilder().ToString(); foreach (string s in LastLines) { string newLine = $"{s}\r\n"; Point p = gfx.MeasureString(_fonts["consolas"], config.Overlay_FontSize, newLine); if (p.X > _window.Width) { string newLines = ""; newLine = s; float ratio = _window.Width / p.X; float part = p.X / _window.Width; float lenString = ratio * newLine.Length; for (int i = 1; i < part + 1; i++) { float lenNewLines = (newLine.Length < lenString ? newLine.Length - 1 : (int)lenString);; newLines += $"{newLine.Substring(0, (int)lenNewLines)}\r\n"; newLine = newLine[(int)lenNewLines..];
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); using (FileStream fs = new FileStream("config.json", FileMode.OpenOrCreate)) { if (fs.Length == 0) { Settings.WriteObject(fs, new Settings[1] { auto_config }); MessageBox.Show($"Created auto-config, change whatever settings you want and restart."); return; } else { settings = (Settings[])Settings.ReadObject(fs); } } //Vars size.X = settings[0].SizeX; size.Y = settings[0].SizeY; string game = settings[0].Game; bool SimpleRCS = settings[0].SimpleRCS; Keys ShootKey = settings[0].ShootKey; Keys TrainModeKey = settings[0].TrainModeKey; Keys ScreenshotKey = settings[0].ScreenshotKey; Keys ScreenshotModeKey = settings[0].ScreenshotModeKey; float SmoothAim = settings[0].SmoothAim; bool Information = settings[0].Information; bool Head = settings[0].Head; 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 if (Process.GetProcessesByName(game).Count() == 0) { MessageBox.Show($"You have not launched {game}..."); 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) { Console.WriteLine("Install CUDA 10"); Process.GetCurrentProcess().Kill(); } if (yoloWrapper.EnvironmentReport.CudnnExists == false) { Console.WriteLine("Cudnn doesn't exist"); Process.GetCurrentProcess().Kill(); } if (yoloWrapper.EnvironmentReport.MicrosoftVisualCPlusPlus2017RedistributableExists == false) { Console.WriteLine("Install Microsoft Visual C++ 2017 Redistributable"); Process.GetCurrentProcess().Kill(); } if (yoloWrapper.DetectionSystem.ToString() != "GPU") { MessageBox.Show("No GPU card detected. Exiting..."); Process.GetCurrentProcess().Kill(); } 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.Graphics gfx = _graphics; System.Drawing.Rectangle trainBox = new System.Drawing.Rectangle(0, 0, size.X / 2, size.Y / 2); while (true) { coordinates = 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 (User32.GetAsyncKeyState(TrainModeKey) == -32767) { if (yoloWrapper != null) { objects = File.ReadAllLines($"trainfiles/{game}.names"); trainingMode = trainingMode == true ? false : true; } } if (User32.GetAsyncKeyState(ScreenshotModeKey) == -32767) { if (yoloWrapper != null) { objects = File.ReadAllLines($"trainfiles/{game}.names"); screenshotMode = screenshotMode == true ? false : true; } } _window.X = coordinates.X - size.X / 2; _window.Y = coordinates.Y - size.Y / 2; gfx.BeginScene(); gfx.ClearScene(); gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Green), 0, 0, size.X, size.Y, 2); if (trainingMode) { int rand = random.Next(5000, 999999); if (User32.GetAsyncKeyState(Keys.Left) != 0) { if (trainBox.Width <= 0) { continue; } else { trainBox.Width -= 1; } } if (User32.GetAsyncKeyState(Keys.Down) != 0) { if (trainBox.Height >= size.Y) { continue; } else { trainBox.Height += 1; } } if (User32.GetAsyncKeyState(Keys.Right) != 0) { if (trainBox.Width >= size.X) { continue; } else { trainBox.Width += 1; } } if (User32.GetAsyncKeyState(Keys.Up) != 0) { if (trainBox.Height <= 0) { continue; } else { trainBox.Height -= 1; } } 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; gfx.DrawTextWithBackground(_graphics.CreateFont("Arial", 14), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), _graphics.CreateSolidBrush(0, 0, 0), new GameOverlay.Drawing.Point(0, 0), "Training mode. Object: " + objects[selectedObject] + Environment.NewLine + "ScreenshotMode: " + (screenshotMode == true ? "following" : "centered")); gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), GameOverlay.Drawing.Rectangle.Create(trainBox.X, trainBox.Y, trainBox.Width, trainBox.Height), 1); gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), GameOverlay.Drawing.Rectangle.Create(trainBox.X + Convert.ToInt32(trainBox.Width / 2.9), trainBox.Y, Convert.ToInt32(trainBox.Width / 3), trainBox.Height / 7), 2); if (User32.GetAsyncKeyState(Keys.PageUp) == -32767) { selectedObject = selectedObject + 1 == objects.Count() ? 0 : selectedObject + 1; } if (User32.GetAsyncKeyState(Keys.PageDown) == -32767) { selectedObject = selectedObject == 0 ? objects.Count() - 1 : selectedObject - 1; } if (User32.GetAsyncKeyState(ScreenshotKey) == -32767) { 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 (User32.GetAsyncKeyState(Keys.Back) == -32767) { 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 (User32.GetAsyncKeyState(Keys.End) == -32767) { 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); 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!"); } } else { if (User32.GetAsyncKeyState(Keys.PageUp) == -32767) { selectedObject = selectedObject + 1 == objects.Count() ? 0 : selectedObject + 1; } if (User32.GetAsyncKeyState(Keys.Up) == -32767) { SmoothAim = SmoothAim >= 1 ? SmoothAim : SmoothAim + 0.05f; } if (User32.GetAsyncKeyState(Keys.Down) == -32767) { SmoothAim = SmoothAim <= 0 ? SmoothAim : SmoothAim - 0.05f; } if (User32.GetAsyncKeyState(Keys.Delete) == -32767) { Head = Head == true ? false : true; } if (User32.GetAsyncKeyState(Keys.Home) == -32767) { shooting = 0; SimpleRCS = SimpleRCS == true ? false : true; } if (User32.GetAsyncKeyState(Keys.PageDown) == -32767) { selectedObject = selectedObject == 0 ? objects.Count() - 1 : selectedObject - 1; } gfx.DrawText(_graphics.CreateFont("Arial", 10), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), new GameOverlay.Drawing.Point(0, 0), $"Object {objects[selectedObject]}; SmoothAim {Math.Round(SmoothAim, 2)}; Head {Head}; SimpleRCS {SimpleRCS}"); 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(ShootKey) == 0) { shooting = 0; } } if (items.Count() > 0) { foreach (var item in items) { if (item.Confidence > (double)0.4) { GameOverlay.Drawing.Rectangle head = GameOverlay.Drawing.Rectangle.Create(item.X + Convert.ToInt32(item.Width / 2.9), item.Y, Convert.ToInt32(item.Width / 3), item.Height / 7); GameOverlay.Drawing.Rectangle body = GameOverlay.Drawing.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), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), _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), _graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), _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(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Red), GameOverlay.Drawing.Rectangle.Create(item.X, item.Y, item.Width, item.Height), 2); if (Head) { gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), head, 2); gfx.DrawCrosshair(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), head.Left + head.Width / 2, head.Top + head.Height / 2 + Convert.ToInt32(1 * shooting), 2, 2, CrosshairStyle.Cross); gfx.DrawLine(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), size.X / 2, size.Y / 2, head.Left + head.Width / 2, head.Top + head.Height / 2 + Convert.ToInt32(1 * shooting), 2); } else { gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), body, 2); gfx.DrawCrosshair(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), body.Left + body.Width / 2, body.Top + body.Height / 2 + Convert.ToInt32(1 * shooting), 2, 2, CrosshairStyle.Cross); gfx.DrawLine(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), size.X / 2, size.Y / 2, body.Left + body.Width / 2, body.Top + body.Height / 2 + Convert.ToInt32(1 * shooting), 2); } if (User32.GetAsyncKeyState(ShootKey) != 0) { 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(); GameOverlay.Drawing.Rectangle nearestEnemyHead = GameOverlay.Drawing.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); User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); } 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 { 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(); GameOverlay.Drawing.Rectangle nearestEnemyBody = GameOverlay.Drawing.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); User32.mouse_event(0x02, 0, 0, 0, (UIntPtr)0); User32.mouse_event(0x04, 0, 0, 0, (UIntPtr)0); } 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 { 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 { gfx.DrawRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Green), GameOverlay.Drawing.Rectangle.Create(item.X, item.Y, item.Width, item.Height), 2); } } } } else { if (SimpleRCS) { shooting = 0; } } } } gfx.FillRectangle(_graphics.CreateSolidBrush(GameOverlay.Drawing.Color.Blue), GameOverlay.Drawing.Rectangle.Create(size.X / 2, size.Y / 2, 4, 4)); gfx.EndScene(); } }
private static void DrawBlip(GameOverlay.Drawing.Graphics gfx, FlatSDKInternal.Entity go) { }
public SHubMain(SHubConfig cfg) { InitializeComponent(); #region Load Configuration cfg = cfg ?? new SHubConfig(); config = cfg; config.Overlay_FontSize = (config.Overlay_FontSize == 0 ? 14 : config.Overlay_FontSize); SHubConfigPanel ConfigPannel = new SHubConfigPanel(config); while (!config.isSetup()) { DialogResult r = MessageBox.Show("Setting incomplete. Retry or Quit software ?", "Configuration issue", MessageBoxButtons.RetryCancel); if (r == DialogResult.Retry) { ConfigPannel.ShowDialog(); } else { Load += (s, e) => Close(); break; } } Text = $"{config.BotName}"; #endregion #region Twitch client = new TwitchClient(); try { var clientOptions = new ClientOptions { MessagesAllowedInPeriod = 750, ThrottlingPeriod = TimeSpan.FromSeconds(30) }; WebSocketClient customClient = new WebSocketClient(clientOptions); client = new TwitchClient(customClient); client.Initialize(config.GetCredential(), config.ChannelName); client.OnLog += Client_OnLog; client.OnJoinedChannel += Client_OnJoinedChannel; client.OnMessageReceived += Client_OnMessageReceived; client.OnWhisperReceived += Client_OnWhisperReceived; client.OnNewSubscriber += Client_OnNewSubscriber; client.OnConnected += Client_OnConnected; client.OnUserJoined += Client_OnUserJoined; client.OnUserLeft += Client_OnUserLeft; client.Connect(); ExcludedNames.Add(client.TwitchUsername); //ExcludedNames.Add(client.JoinedChannels) } catch (Exception e) { Debug.WriteLine(e); } #endregion #region Twitch_Features c_GTAPool.AutoGenerateColumns = true; //Bindings GTAList = new BindingList <GTA_User>(GTAPoolList); BindingSource source = new BindingSource(GTAList, null); c_GTAPool.DataSource = source; VoteList = new BindingList <RoleVote>(config.RoleVotes); BindingSource sourceVoteRole = new BindingSource(VoteList, null); c_VotesRoles.DataSource = sourceVoteRole; UsersList = new BindingList <GameUser>(ConnectedUsers); BindingSource sourceUsers = new BindingSource(UsersList, null); c_ConnectedUsers.DataSource = sourceUsers; //txt File output for OBS UpdateObsFiles(); UpdateGTACount(); #endregion #region Overlay _brushes = new Dictionary <string, SolidBrush>(); _fonts = new Dictionary <string, Font>(); _images = new Dictionary <string, Image>(); var gfx = new Graphics() { MeasureFPS = true, PerPrimitiveAntiAliasing = true, TextAntiAliasing = true }; _window = new GraphicsWindow(config.Overlay_width, 1080 - config.Overlay_height, config.Overlay_width, config.Overlay_height, gfx) { FPS = 30, IsTopmost = true, IsVisible = true }; _window.DestroyGraphics += _window_DestroyGraphics; _window.DrawGraphics += _window_DrawGraphics; _window.SetupGraphics += _window_SetupGraphics; _window.Create(); //_window.Join(); //seems to replace or take over the WinForm #endregion #region Discord _client = new DiscordSocketClient(); _client.Log += LogAsync; _client.Ready += ReadyAsync; _client.MessageReceived += MessageReceivedAsync; _ = DiscordTask(); #endregion #region RolesVoteFeature #endregion }
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} "); } } }
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); 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($"Criação automática de configuração, altere as configurações desejadas e reinicie."); return; } else { settings = ((Settings[])Settings.ReadObject(fs))[0]; } } 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; 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; while (Process.GetProcessesByName(game).Count() == 0) { DialogResult dialogResult = MessageBox.Show($"Você não iniciou o {game} ainda.", "Game não encontrado ", 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("Instale CUDA 10"); } if (yoloWrapper.EnvironmentReport.CudnnExists == false) { giveErrorMessage("Cudnn não"); } if (yoloWrapper.EnvironmentReport.MicrosoftVisualCPlusPlus2017RedistributableExists == false) { giveErrorMessage("Instale Microsoft Visual C++ 2017 Redistributable"); } if (yoloWrapper.DetectionSystem.ToString() != "GPU") { giveErrorMessage("Não foi detectado uma GPU. Fechando..."); } objects = File.ReadAllLines($"trainfiles/{game}.names"); } else { trainingMode = true; MessageBox.Show($"Parece que você não definiu configurações para { game}... Vamos treinar a Neural Network! :)\n Preparando arquivos para treinamento...."); Console.Write("Quantos objetos a NN estará analisando e treinando? Escreva o nome de cada objeto através do separador ',' sem espaços (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 = 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 (CursorToCenter) { Cursor.Position = CenterScreen; } 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, nós temos as fotos para treinamento. Vamos treinar a 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($"O treinamento vai exigir da sua gpu. Quer fechar o jogo?", "Fechar jogo", 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("^Quando terminar o treinamento digite \"done\" no 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("Quando terminar o treinamento digite \"done\" no console."); } } Console.WriteLine("Okay! O treinamento esta finalizado. Vamos testar agora no 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]};" + $"SmoothAim {Math.Round(SmoothAim, 2)};" + $"Head {Head};" + $"SimpleRCS {SimpleRCS};" + Environment.NewLine + $"AutoShoot {AutoShoot};" + $"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 { 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(); } }
private void DrawItemWeapon(GameOverlay.Drawing.Graphics gfx, FlatSDKInternal.Entity go, string itemId) { 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); float x = MinOutput.X - lootItems[itemId].fontSize - 10; float y = MinOutput.Y; if (ESPXOptions.bFixOverview == 1) { y = findFreeAreaForDraw(x, y, x + lootItems[itemId].textWidth + 8f, y + lootItems[itemId].fontSize + 8f); } float padding = 0f; if (ESPXOptions.bTextWithBg == 1) { padding = 8f; } float r = x + lootItems[itemId].textWidth + padding; float b = y + lootItems[itemId].fontSize + padding; if (ESPXOptions.bLockInScreen == 1) { if (x < 0) { x = 0; } if (y < 0) { y = 0; } if (r > FlatSDK.Overlay.Width) { x = FlatSDK.Overlay.Width + x - r; } if (b > FlatSDK.Overlay.Height) { y = FlatSDK.Overlay.Height + y - b; } } try { if (ESPXOptions.bShowAllItems == 1 || lootItems[itemId].view) { if (ESPXOptions.bTextWithBg == 1) { gfx.DrawTextWithBackground(FlatSDKInternal.IRenderer._font, lootItems[itemId].fontSize, lootItems[itemId].fontBrush, lootItems[itemId].bgBrush, x, y, lootItems[itemId].name.ToString()); } else { gfx.DrawText(FlatSDKInternal.IRenderer._font, lootItems[itemId].fontSize, lootItems[itemId].fontBrush, x, y, lootItems[itemId].name.ToString()); } } if (ESPXOptions.bFixOverview == 1) { entityDrawPositions.Add(new float[] { x, y, r, b }); } } catch { } }