Example #1
0
        private static void Do(object sender, EventArgs f)
        {
            _timer.Stop();
            try {
                if (Program.OverallActive && 0 < (KeyStateManager.GetAsyncKeyState(Program.Settings.Aimkey) & 0x8000) &&
                    GameData.LocalPlayer.Health > 0 &&
                    !GameData.LocalPlayer.NotUseable())
                {
                    var fov = Program.Settings.FOV + GameData.LocalPlayer.ShotsFired * 3;
                    if (fov > 30)
                    {
                        fov = 30;
                    }

                    var target = GetNearestTargetByFov(fov);

                    if (target != null && target != _lastTarget &&
                        (DateTime.Now - _lastTimeAimed).TotalMilliseconds < 500)
                    {
                        target = null;
                    }

                    if (target != null)
                    {
                        if (DoAim())
                        {
                            _lastTarget     = target;
                            _lastTimeAimed  = DateTime.Now;
                            _timer.Interval = (int)HackMath.RandomNumber(Program.Settings.PausesBetweenAiming
                                                                         , Program.Settings.PausesBetweenAiming + 2);
                        }
                        else
                        {
                            _timer.Interval = 1;
                        }
                    }
                    else
                    {
                        _timer.Interval = 1;
                    }
                }
                else if (GameData.LocalPlayer.IsSniper() || GameData.LocalPlayer.IsPistol())
                {
                    _timer.Interval = 1;
                }
                else
                {
                    _timer.Interval = 20;
                }
            } catch {
                _timer.Interval = 1;
            }

            _timer.Start();
        }
Example #2
0
        private static void UpdateKeys()
        {
            while (true)
            {
                try {
                    if ((KeyStateManager.GetAsyncKeyState(Settings.KillKey) & 0x8000) > 0)
                    {
                        if (Settings.UseSounds)
                        {
                            Console.Beep(200, 100);
                        }
                        Environment.Exit(0);
                    }
                    else if ((KeyStateManager.GetAsyncKeyState(Settings.DeactivateKey) & 0x8000) > 0)
                    {
                        OverallActive = false;
                        if (Settings.UseSounds)
                        {
                            Console.Beep(400, 100);
                        }
                        Thread.Sleep(300);
                    }
                    else if ((KeyStateManager.GetAsyncKeyState(Settings.ReactivateKey) & 0x8000) > 0 &&
                             (KeyStateManager.GetAsyncKeyState(0x11) & 0x8000) > 0)
                    {
                        OverallActive = true;
                        if (Settings.UseSounds)
                        {
                            Console.Beep(1000, 100);
                        }
                        Thread.Sleep(300);
                    }
                    else if ((KeyStateManager.GetAsyncKeyState(Settings.UpperPauseKey) & 0x8000) > 0)
                    {
                        Settings.PausesBetweenAiming += 1;
                        if (Settings.UseSounds)
                        {
                            Console.Beep(1000, 100);
                        }
                        Thread.Sleep(300);
                    }
                    else if ((KeyStateManager.GetAsyncKeyState(Settings.LowerPauseKey) & 0x8000) > 0)
                    {
                        Settings.PausesBetweenAiming -= 1;
                        if (Settings.UseSounds)
                        {
                            Console.Beep(400, 100);
                        }
                        Thread.Sleep(300);
                    }
                    else if ((KeyStateManager.GetAsyncKeyState(Settings.ReloadSettingsKey) & 0x8000) > 0)
                    {
                        LoadConfig();
                        Thread.Sleep(300);
                    }
                } catch {
                    // ignored
                }

                Thread.Sleep(20);
            }
        }