Пример #1
0
        private static void Main(string[] args)
        {
            var game_process = GetProcess("csgo", 5000);

            var overlay = new StickyOverlayWindow(game_process.MainWindowHandle, new OverlayCreationOptions
            {
                BypassTopmost = true,
                WindowTitle   = HelperMethods.GenerateRandomString(5, 11)
            });

            overlay.OnWindowBoundsChanged += Overlay_OnWindowBoundsChanged;

            gfx = new Direct2DRenderer(new RendererOptions
            {
                AntiAliasing = true,
                Hwnd         = overlay.WindowHandle,
                MeasureFps   = true,
                VSync        = false
            });

            font            = gfx.CreateFont("Arial", 22);
            brush           = gfx.CreateBrush(255, 0, 0, 255);
            backgroundBrush = gfx.CreateBrush(0xCC, 0xCC, 0xCC, 80);

            var timer = new FrameTimer(60);

            timer.OnFrameStart += Timer_OnFrameStart;
            timer.FPS           = 900;
            timer.Start();

            Console.WriteLine("drawing...");
            Console.ReadLine();
        }
Пример #2
0
        private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
        {
            Stopwatch jew = new Stopwatch();

            var overlay = new OverlayWindow(0, 0, (int)SystemInformation.VirtualScreen.Width, (int)SystemInformation.VirtualScreen.Height);

            var rendererOptions = new Direct2DRendererOptions()
            {
                AntiAliasing = true,
                Hwnd         = overlay.WindowHandle,
                MeasureFps   = true,
                VSync        = false
            };

            var d2d = new Direct2DRenderer(rendererOptions);

            var whiteSmoke = d2d.CreateBrush(0, 0, 0, 0);

            var blackBrush = d2d.CreateBrush(0, 0, 0, 150);
            var redBrush   = d2d.CreateBrush(255, 0, 0, 255);

            jew.Start();
            while (drawRunning)
            {
                d2d.BeginScene();
                d2d.ClearScene(whiteSmoke);
                int temp = findClosestEndPoint(listOfClicks, Form1.MousePosition, 10);
                if (temp != -1 && mousePressed)
                {
                    listOfClicks[temp].x = MousePosition.X;
                    listOfClicks[temp].y = MousePosition.Y;
                }
                d2d.FillCircle(listOfClicks[0].x, listOfClicks[0].y, 7, blackBrush);
                d2d.FillCircle(listOfClicks[1].x, listOfClicks[1].y, 7, blackBrush);
                d2d.FillCircle(listOfClicks[2].x, listOfClicks[2].y, 7, blackBrush);

                d2d.DrawLine(listOfClicks[0].x, listOfClicks[0].y, listOfClicks[1].x, listOfClicks[1].y, 5, redBrush);
                d2d.DrawLine(listOfClicks[0].x, listOfClicks[0].y, listOfClicks[2].x, listOfClicks[2].y, 5, redBrush);

                d2d.EndScene();
            }
            d2d.BeginScene();
            d2d.ClearScene(whiteSmoke);
            d2d.EndScene();
            jew.Stop();
            jew.Reset();
            //running = false;
        }
Пример #3
0
        private static void Main(string[] args)
        {
            Console.WindowHeight = Console.LargestWindowHeight / 2;
            Console.WindowWidth  = Console.LargestWindowWidth / 2;

            OverlayCreationOptions overlayOptions = new OverlayCreationOptions()
            {
                BypassTopmost = true,
                Height        = 600,
                Width         = 600,
                WindowTitle   = HelperMethods.GenerateRandomString(5, 11),
                X             = Console.WindowLeft,
                Y             = Console.WindowTop
            };

            StickyOverlayWindow overlay = new StickyOverlayWindow(Process.GetCurrentProcess().MainWindowHandle, overlayOptions);

            overlay.OnWindowBoundsChanged += Overlay_OnWindowBoundsChanged;

            RendererOptions rendererOptions = new RendererOptions()
            {
                AntiAliasing = true,
                Hwnd         = overlay.WindowHandle,
                MeasureFps   = true,
                VSync        = false
            };

            gfx = new Direct2DRenderer(rendererOptions);

            font            = gfx.CreateFont("Arial", 22);
            brush           = gfx.CreateBrush(255, 0, 0, 255);
            backgroundBrush = gfx.CreateBrush(0xCC, 0xCC, 0xCC, 80);

            FrameTimer timer = new FrameTimer(60);

            timer.OnFrameStart += Timer_OnFrameStart;

            timer.Start();

            Console.ReadLine();

            timer.Stop();

            gfx.Dispose();
            overlay.Dispose();
        }
Пример #4
0
        static void example()
        {
            var overlay = new OverlayWindow(0, 0, 800, 600);

            var rendererOptions = new Direct2DRendererOptions()
            {
                AntiAliasing = true,
                Hwnd         = overlay.WindowHandle,
                MeasureFps   = true,
                VSync        = false
            };

            var d2d = new Direct2DRenderer(rendererOptions);

            var whiteSmoke = d2d.CreateBrush(0xF5, 0xF5, 0xF5, 100);

            var blackBrush = d2d.CreateBrush(0, 0, 0, 255);
            var redBrush   = d2d.CreateBrush(255, 0, 0, 255);
            var greenBrush = d2d.CreateBrush(0, 255, 0, 255);
            var blueBrush  = d2d.CreateBrush(0, 0, 255, 255);

            var font = d2d.CreateFont("Consolas", 22);

            while (true)
            {
                d2d.BeginScene();
                d2d.ClearScene(whiteSmoke);

                d2d.DrawTextWithBackground("FPS: " + d2d.FPS, 20, 40, font, greenBrush, blackBrush);

                d2d.BorderedRectangle(300, 40, 100, 200, 4, redBrush, blackBrush);
                d2d.DrawHorizontalBar(100, 290, 40, 2, 200, 4, greenBrush, blackBrush);
                d2d.DrawHorizontalBar(100, 280, 40, 2, 200, 4, blueBrush, blackBrush);

                d2d.DrawCrosshair(CrosshairStyle.Gap, 400, 300, 25, 4, redBrush);

                d2d.EndScene();
            }
        }
Пример #5
0
        public Overlay(Process gameProcess)
        {
            process = gameProcess;

            // check the game window exists then create the overlay
            while (true)
            {
                handle = NativeMethods.FindWindow(null, "STAR WARS Battlefront II");

                if (handle != IntPtr.Zero)
                {
                    break;
                }
            }

            // check if game running. timed at 2-5ms per call so runs in own thread
            gameCheckThread = new Thread(new ParameterizedThreadStart(GameCheck));
            gameCheckThread.Start();

            // Starting the ESP before the game leaves invalid process info so we'll wait a second to let the game check thread fix that
            if (process.MainWindowHandle == IntPtr.Zero)
            {
                Thread.Sleep(1000);
            }

            // set up the remote process memory class
            RPM.OpenProcess(process.Id);

            // setup the overlay
            var rendererOptions = new Direct2DRendererOptions()
            {
                AntiAliasing = OPTIONS_AA,
                Hwnd         = IntPtr.Zero,
                MeasureFps   = OPTIONS_ShowFPS,
                VSync        = OPTIONS_VSync
            };

            OverlayManager manager = new OverlayManager(handle, rendererOptions);

            overlay    = manager.Window;
            d2d        = manager.Graphics;
            clearBrush = d2d.CreateBrush(0xF5, 0xF5, 0xF5, 0);  // our transparent colour

            // start the update thread
            updateThread = new Thread(new ParameterizedThreadStart(Update));
            updateThread.Start();
        }
        public OverlayManager(IntPtr parentWindowHandle, out OverlayWindow overlay, out Direct2DRenderer d2d)
        {
            Direct2DRendererOptions options = new Direct2DRendererOptions()
            {
                AntiAliasing = true,
                Hwnd         = IntPtr.Zero,
                MeasureFps   = true,
                VSync        = false
            };

            setupInstance(parentWindowHandle, options);

            overlay = Window;
            d2d     = Graphics;

            d2d.whiteSmoke = d2d.CreateBrush(0xF5, 0xF5, 0xF5, 100);

            d2d.blackBrush    = d2d.CreateBrush(0, 0, 0, 255);
            d2d.redBrush      = d2d.CreateBrush(255, 0, 0, 255);
            d2d.lightRedBrush = d2d.CreateBrush(255, 100, 100, 255);
            d2d.greenBrush    = d2d.CreateBrush(0, 255, 0, 255);
            d2d.blueBrush     = d2d.CreateBrush(0, 0, 255, 255);
            d2d.font          = d2d.CreateFont("Consolas", 22);
        }
Пример #7
0
        private void Nampham()
        {
            rect.left   = 0;    //
            rect.right  = 1366; //
            rect.top    = 21;   //
            rect.bottom = 726;  //
            int Width           = rect.right - rect.left;
            int Height          = rect.bottom - rect.top;
            int Width2          = 1382; //
            int Height2         = 744;  //
            var overlay         = new OverlayWindow(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
            var rendererOptions = new Direct2DRendererOptions()
            {
                AntiAliasing = false,
                Hwnd         = overlay.WindowHandle,
                MeasureFps   = true,
                VSync        = true
            };

            var     d2d         = new Direct2DRenderer(rendererOptions);
            var     trains      = d2d.CreateBrush(0, 0, 0, 0);
            var     blackBrush  = d2d.CreateBrush(0, 0, 0, 255);
            var     redBrush    = d2d.CreateBrush(242, 14, 14, 255);
            var     greenBrush  = d2d.CreateBrush(33, 208, 43, 255);
            var     whiteBrush  = d2d.CreateBrush(255, 255, 255, 200);
            var     blueBrush   = d2d.CreateBrush(0, 0, 255, 255);
            var     grenBrush   = d2d.CreateBrush(33, 208, 43, 180);
            var     greenBrush2 = d2d.CreateBrush(0, 188, 0, 255);
            var     font        = d2d.CreateFont("Tahoma", 8, true);
            var     bigfont     = d2d.CreateFont("Tahoma", 14, true);
            Vector2 center      = new Vector2();

            while (true)
            {
                center.X = Width / 2;
                center.Y = (Height / 2) + 20;
                d2d.BeginScene();
                d2d.ClearScene(trains);
                if (Showbone)
                {
                    var m_pWorld = Mem.ReadMemory <int>(Mem.BaseAddress + Offsets.PyGame + 0x410);
                    List <LUPPI.NP.Word> modal = new List <NP.Word>();
                    var m_pSceneContext        = Mem.ReadMemory <int>(m_pWorld + 0x8);
                    var cameraBase             = Mem.ReadMemory <int>(m_pSceneContext + 0x4);
                    var viewMatrix             = Mem.ReadMatrix <float>(cameraBase + 0xC4, 16);
                    var pSkeletonList          = Mem.ReadMemory <int>(m_pWorld + 0x290);
                    int visibleCount           = Mem.ReadMemory <int>(m_pWorld + 0x278);
                    int coutene = 0;
                    for (int i = 0; i < visibleCount; i++)
                    {
                        int r_pModel    = Mem.ReadMemory <int>(pSkeletonList + i);
                        int m_pAnimator = Mem.ReadMemory <int>(r_pModel + 0x328);
                        if (m_pAnimator > 1)
                        {
                            var intt = Mem.ReadMemory <int>(m_pAnimator + 0x528);
                            //var bon = Mem.ReadMemory<int>(m_pAnimator + 0x970);
                            var name = Mem.ReadString(intt, 35);
                            //float[] b = Mem.ReadMatrix<float>(r_pModel + 0x3B0, 16);
                            if (name.Contains("_male"))
                            {
                                coutene += 1;
                                modal.Add(new NP.Word()
                                {
                                    baseAdd = m_pAnimator, baseModal = r_pModel, isMen = true
                                });
                            }
                            else if (name.Contains("_female"))
                            {
                                coutene += 1;
                                modal.Add(new NP.Word()
                                {
                                    baseAdd = m_pAnimator, baseModal = r_pModel, isMen = false
                                });
                            }
                        }
                    }
                    d2d.DrawTextWithBackground("ENERMY : " + (coutene - 1) + " 💩", 10, 400, bigfont, redBrush, whiteBrush);
                    for (int i = 0; i < modal.Count; i++)
                    {
                        if (i == 0)//LOCALPLAYER POS
                        {
                            var m_Position1 = modal[i].pos;
                            MyPosition.X = m_Position1[12];
                            MyPosition.Y = m_Position1[13];
                            MyPosition.Z = m_Position1[14];
                        }
                        //string name = modal[i].TypeName;
                        //if (name.Contains("dataosha_male") || name.Contains("dataosha_female"))
                        {
                            var     m_Position = modal[i].pos;
                            Vector3 position;
                            position.X = m_Position[12];
                            position.Y = m_Position[13];
                            position.Z = m_Position[14];
                            var p = 0;
                            for (int j = 0; j < 0xE80; j += 0x40)
                            {
                                var ab         = Mem.ReadMemory <int>(modal[i].baseAdd + 0x970);
                                var boneMatrix = Mem.ReadMatrix <float>(ab + j, 16);
                                var bone4      = new LUPPI.NP.Matrix(boneMatrix);
                                var bone24     = new LUPPI.NP.Matrix(m_Position);
                                var result     = LUPPI.NP.Matrix.Multiply(bone4, bone24);
                                var vec3a      = new Vector3(result.M41, result.M42, result.M43);
                                Maths.WorldToScreen3(vec3a, viewMatrix, out var testeee, Width, Height);
                                d2d.DrawText(p.ToString(), testeee.X, testeee.Y, font, whiteBrush);
                                p++;
                            }
                            Maths.WorldToScreen(position, out var testee2, Width, Height);
                            int    khoangCach = Helper.GetDistance(MyPosition, position, 20);
                            string tea        = "[" + khoangCach + "m]";
                            if (khoangCach < 150)
                            {
                                d2d.DrawText(tea, testee2.X - tea.Length, testee2.Y, font, greenBrush2);
                            }
                            else
                            {
                                d2d.DrawText(tea, testee2.X - tea.Length, testee2.Y, font, whiteBrush);
                            }
                        }
                    }
                }
                if (isBoxEsp)
                {
                    Vector2 vector3;
                    LocalPlayer = Mem.ReadMemory <int>(Mem.BaseAddress + Offsets.LocalPlayer);
                    Mem.ReadMemory <int>(Mem.BaseAddress + 0x22);
                    MyPosition = GetEncryptedPosition(LocalPlayer);
                    List <Entity> ls = ReadAllEntity();
                    d2d.DrawTextWithBackground("ENERMY : " + enemyCount.ToString() + " 💩", 10, 400, bigfont, redBrush, whiteBrush);
                    d2d.DrawTextWithBackground("AIM LEG: " + aimLeg.ToString(), 10, 370, bigfont, redBrush, whiteBrush);
                    for (int i = 0; i < ls.Count; i++)
                    {
                        //ls[i].Coordinates.Y += 15f;
                        ls[i].Coordinates = ls[i].GetEncryptedPosition();
                        if (Maths.WorldToScreen(ls[i].Coordinates, out vector3, Width2, Height2))
                        {
                            int   khoangCach = Helper.GetDistance(MyPosition, ls[i].Coordinates, 10);
                            var   widthhp    = 0f;
                            var   widthhp2   = 0f;
                            float numaim     = 2f;
                            if (ls[i].isPlayer && ls[i].hp > 0)
                            {
                                float heiadd = 0f;
                                bool  flag3  = ls[i].pose == Pose.Standing;
                                if (flag3)
                                {
                                    heiadd += 18.5f;
                                }
                                bool flag4 = ls[i].pose == Pose.Prone;
                                if (flag4)
                                {
                                    heiadd += 12.5f;
                                    numaim  = 1.6f;
                                }
                                bool flag5 = ls[i].pose == Pose.Crouching;
                                if (flag5)
                                {
                                    heiadd += 4f;
                                    numaim  = 1.1f;
                                }
                                Vector2 line1, line2, line3, line4, line5, line6, line7, line8;
                                if (isBoxEsp)
                                {
                                    var a1  = ls[i].Coordinates.X;
                                    var a2  = ls[i].Coordinates.Y;
                                    var a3  = ls[i].Coordinates.Z;
                                    var v7  = a1 - 5.5f;
                                    var v8  = a2 - 2.5f;
                                    var v9  = a3 - 5.5f;
                                    var v10 = a1 + 5.5f;
                                    var v12 = a3 + 5.5f;
                                    if (Maths.WorldToScreen(new Vector3(v7, v8, v9), out line1, Width, Height))
                                    {
                                        var v4  = a2 + heiadd;
                                        var v11 = a2 + heiadd;
                                        var v13 = v4;
                                        var v14 = v4;
                                        if (Maths.WorldToScreen(new Vector3(v10, v4, v12), out line2, Width, Height))
                                        {
                                            if (Maths.WorldToScreen(new Vector3(v10, v8, v9), out line3, Width, Height))
                                            {
                                                if (Maths.WorldToScreen(new Vector3(v7, v11, v9), out line4, Width, Height))
                                                {
                                                    if (Maths.WorldToScreen(new Vector3(v7, v8, v12), out line5, Width, Height))
                                                    {
                                                        if (Maths.WorldToScreen(new Vector3(v7, v13, v12), out line6, Width, Height))
                                                        {
                                                            if (Maths.WorldToScreen(new Vector3(v10, v8, v12), out line7, Width, Height))
                                                            {
                                                                if (Maths.WorldToScreen(new Vector3(v10, v14, v9), out line8, Width, Height))
                                                                {
                                                                    d2d.DrawLine(line1.X, line1.Y, line4.X, line4.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line3.X, line3.Y, line8.X, line8.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line7.X, line7.Y, line2.X, line2.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line5.X, line5.Y, line6.X, line6.Y, 1, whiteBrush);

                                                                    //Chan
                                                                    d2d.DrawLine(line1.X, line1.Y, line3.X, line3.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line3.X, line3.Y, line7.X, line7.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line7.X, line7.Y, line5.X, line5.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line5.X, line5.Y, line1.X, line1.Y, 1, whiteBrush);

                                                                    //Dau
                                                                    d2d.DrawLine(line4.X, line4.Y, line8.X, line8.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line8.X, line8.Y, line2.X, line2.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line2.X, line2.Y, line6.X, line6.Y, 1, whiteBrush);
                                                                    d2d.DrawLine(line6.X, line6.Y, line4.X, line4.Y, 1, whiteBrush);

                                                                    widthhp  = (float)Helper.GetDistance2(line4, line2, 1);
                                                                    widthhp2 = (float)Helper.GetDistance2(line6, line8, 1);
                                                                    if (widthhp < widthhp2)
                                                                    {
                                                                        widthhp = widthhp2;
                                                                    }
                                                                }
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                                var     dy = ls[i].Coordinates.X;
                                var     dy_4 = ls[i].Coordinates.Y;
                                var     v46 = ls[i].Coordinates.Z;
                                var     v27 = dy_4 + 27.0f;
                                Vector2 aimpoint, aimpoint2;
                                if (Maths.WorldToScreen(new Vector3(dy, v27, v46), out aimpoint, Width, Height))
                                {
                                    string tea = ls[i].PlayerName + " [" + khoangCach + " m]";
                                    if (khoangCach < 150)
                                    {
                                        d2d.DrawText(tea, aimpoint.X - tea.Length * 2, aimpoint.Y - 10, font, redBrush);
                                    }
                                    else
                                    {
                                        d2d.DrawText(tea, aimpoint.X - tea.Length * 2, aimpoint.Y - 10, font, whiteBrush);
                                    }

                                    //Player HP
                                    if (ls[i].hp == 100)
                                    {
                                        d2d.DrawVerticalBar(ls[i].hp, aimpoint.X - widthhp / 2, aimpoint.Y - 15f, widthhp, 1, 3, greenBrush2, blackBrush);
                                    }
                                    else
                                    {
                                        d2d.DrawVerticalBar(ls[i].hp, aimpoint.X - widthhp / 2, aimpoint.Y - 15f, widthhp, 1, 3, redBrush, blackBrush);
                                    }
                                }

                                if (Maths.WorldToScreen(new Vector3(dy, v27, v46), out aimpoint, Width, Height2))
                                {
                                    var v41 = dy_4 + heiadd;
                                    if (Maths.WorldToScreen(new Vector3(dy, v41, v46), out aimpoint2, Width, Height2))
                                    {
                                        if ((Maths.InsideCircle((int)center.X, (int)center.Y, 80, (int)aimpoint2.X, (int)aimpoint2.Y)))
                                        {
                                            if (Keyboard.IsKeyDown(Keys.LShiftKey))
                                            {
                                                Cursor.Position = new Point((int)(aimpoint2.X), (int)(aimpoint2.Y));
                                                if (Keyboard.IsKeyDown(Keys.LButton))
                                                {
                                                    Cursor.Position = new Point((int)(aimpoint2.X), (int)(aimpoint2.Y + ls[i].Pitch));
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (ls[i].isItem)
                            {
                                if (ls[i].dropID == 1001 || ls[i].dropID == 1002 || ls[i].dropID == 1007 || ls[i].dropID == 1026)
                                {
                                    d2d.DrawText2("[GUN]", vector3.X, vector3.Y, font, whiteBrush, greenBrush2);
                                }
                                else if (ls[i].dropID == 1273 || ls[i].dropID == 1274 || ls[i].dropID == 1275)
                                {
                                    d2d.DrawText2("[SCOPE]", vector3.X, vector3.Y, font, whiteBrush, greenBrush2);
                                }
                                else if (khoangCach < 100)
                                {
                                    //d2d.DrawText("[I]", vector3.X, vector3.Y, font, whiteBrush);
                                }
                            }
                            if (ls[i].isItemDie && khoangCach < 100)
                            {
                                d2d.DrawText2("[DIE]", vector3.X, vector3.Y, font, whiteBrush, greenBrush2);
                            }
                        }
                    }
                }

                d2d.EndScene();
                //Thread.Sleep(1);
            }
        }
Пример #8
0
        // Init
        public Overlay(Process process)
        {
            this.process = process;

            // check the game window exists then create the overlay
            while (true)
            {
                handle = NativeMethods.FindWindow(null, "Battlefield 4");

                if (handle != IntPtr.Zero)
                {
                    break;
                }
            }

            gameCheckThread = new Thread(new ParameterizedThreadStart(GameCheck));
            gameCheckThread.Start();
            if (process.MainWindowHandle == IntPtr.Zero)
            {
                Thread.Sleep(1000);
            }

            RPM.OpenProcess(process.Id);

            // setup the overlay
            var rendererOptions = new Direct2DRendererOptions()
            {
                AntiAliasing = OPTIONS_AA,
                Hwnd         = IntPtr.Zero,
                MeasureFps   = OPTIONS_ShowFPS,
                VSync        = OPTIONS_VSync
            };

            OverlayManager manager = new OverlayManager(handle, rendererOptions);

            overlay    = manager.Window;
            d2d        = manager.Graphics;
            clearBrush = d2d.CreateBrush(0xF5, 0xF5, 0xF5, 0);  // our transparent colour



            // Init player array
            localPlayer = new GPlayer();
            //localPlayer.CurrentWeapon = new Weapon();
            localWeapons  = new List <Gun>();
            players       = new List <GPlayer>();
            targetEnimies = new List <GPlayer>();

            // Init update thread
            updateStream = new Thread(new ParameterizedThreadStart(Update));
            updateStream.Start();


            ScreenCapture sc = new ScreenCapture();

            sc.CaptureWindowToFile(process.MainWindowHandle, @"C:\PZ_BF4_FAIRFIGHT_GAME_SS.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);



            // Init Key Listener
            KeyAssign();
        }
Пример #9
0
        private void OverlayControl()
        {
            try
            {
                // and our font
                var font = d2d.CreateFont("Consolas", 11);



                // Check Window State
                if (IsGameRunning)
                {
                    #region Scan Memory & Draw Players
                    MainScan();
                    #endregion

                    #region Drawing Menu
                    if (bMenuControl)
                    {
                        DrawMenu(10, 10);
                    }
                    #endregion

                    if (OPTIONS_ShowFPS)
                    {
                        d2d.DrawTextWithBackground($"Cheat FPS: {d2d.FPS}", 20, 20, font, d2d.CreateBrush(255, 0, 0, 255), d2d.CreateBrush(0, 0, 0, 255));
                    }
                }

                CalculateFrameRate();
            }
            catch (Exception ex)
            {
                WriteOnLogFile(DateTime.Now.ToString() + " - OVERLAY ERROR : " + ex);
            }
        }
Пример #10
0
        private void Update(object sender)
        {
            // set up our colours for drawing
            var blackBrush      = d2d.CreateBrush(0, 0, 0, 255);
            var redBrush        = d2d.CreateBrush(153, 0, 0, 128);
            var yellowBrush     = d2d.CreateBrush(153, 153, 0, 128);
            var orangeBrush     = d2d.CreateBrush(255, 200, 0, 255);
            var darkOrangeBrush = d2d.CreateBrush(255, 100, 0, 255);
            var greenBrush      = d2d.CreateBrush(0, 255, 0, 255);
            var blueBrush       = d2d.CreateBrush(0, 0, 255, 255);
            var whiteBrush      = d2d.CreateBrush(250, 250, 250, 128);
            var vehicleBrush    = d2d.CreateBrush(243, 243, 255, 128);
            var heroVisBrush    = d2d.CreateBrush(240, 0, 255, 255);
            var heroBrush       = d2d.CreateBrush(120, 0, 120, 255);

            // and our font
            var font = d2d.CreateFont("Tahoma", 9);

            Direct2DBrush brush;

            Console.WriteLine("Initialising...");

            // initialise the GameManager class that handles the player data
            gameManager = new GameManager(process, new Rectangle(0, 0, overlay.Width, overlay.Height));

            Console.WriteLine("Ready.");

            // main loop
            while (IsGameRunning)
            {
                if (gameManager.UpdateFrame(new Rectangle(0, 0, overlay.Width, overlay.Height)))
                {
                    d2d.BeginScene();
                    d2d.ClearScene(clearBrush);

                    if (OPTIONS_ShowFPS)
                    {
                        d2d.DrawTextWithBackground($"FPS: {d2d.FPS}", 20, 20, font, greenBrush, blackBrush);
                    }

                    foreach (Player player in gameManager.AllPlayers)
                    {
                        if (!player.IsDead)
                        {
                            if (player.IsVisible)
                            {
                                if (player.MaxHealth < 400)
                                {
                                    brush = yellowBrush;
                                }
                                else
                                {
                                    brush = heroVisBrush;
                                }
                            }
                            else
                            {
                                if (player.MaxHealth < 400)
                                {
                                    brush = redBrush;
                                }
                                else
                                {
                                    brush = heroBrush;
                                }
                            }

                            if (!player.InVehicle)
                            {
                                /*if (!player.IsVisible)*/ DrawAABB(player.TransformAABB, brush);
                            }
                            else
                            {
                                brush = vehicleBrush;

                                DrawAABB(player.TransformAABB, brush);
                            }

                            var name = player.Name;
                            var dist = $"{(int)player.Distance}m";

                            Vector3 textPos = new Vector3(player.Position.X, player.Position.Y, player.Position.Z);
                            if (gameManager.WorldToScreen(textPos, out textPos))
                            {
                                var textPosX = textPos.X - ((name.Length * font.FontSize) / 4);
                                d2d.DrawText(name, textPosX - 1, textPos.Y - 1, font, blackBrush);
                                d2d.DrawText(name, textPosX, textPos.Y, font, whiteBrush);

                                textPosX = textPos.X - ((dist.Length * font.FontSize) / 4);
                                var textPosY = textPos.Y + font.FontSize;

                                d2d.DrawText(dist, textPosX - 1, textPosY - 1, font, blackBrush);
                                d2d.DrawText(dist, textPosX, textPosY, font, whiteBrush);
                            }
                        }
                    }

                    d2d.EndScene();
                }
            }

            // clean up if the game has closed
            RPM.CloseProcess();
            Environment.Exit(0);
        }