private void ProcessMissileAtGaze(Vector3 shootMissileCoord, Entity missileTarget)
        {
            if (!_settings.MissilesAtGazeEnabled)
            {
                return;
            }

            if (!(shootMissileCoord.Length() > 0) || !Geometry.IsInFrontOfThePlayer(shootMissileCoord))
            {
                return;
            }

            var controllerState = _controllerEmulation.ControllerState;

            if (Game.IsKeyPressed(Keys.N) ||
                Game.IsKeyPressed(Keys.PageUp) ||
                (!_gameState.IsInCharacterSelectionMenu && !_gameState.IsInRadialMenu && !_gameState.IsMenuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.B)))
            {
                if (missileTarget != null)
                {
                    _aiming.ShootMissile(missileTarget);
                }
                else
                {
                    _aiming.ShootMissile(shootMissileCoord);
                }
            }
        }
示例#2
0
        private void ProcessControls(Vector3 shootCoord, Vector3 shootCoordSnap, Vector3 shootMissileCoord)
        {
            var controllerState = _controllerEmulation.ControllerState;

            var radialMenuActive = (!Game.Player.Character.IsInVehicle() &&
                                    controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder));

            if (controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb) &&
                controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start) &&
                !_menuOpen)
            {
                _settingsMenu.OpenMenu();
            }

            if (shootCoord.Length() > 0 && Geometry.IsInFrontOfThePlayer(shootCoord))
            {
                var injectRightTrigger = 0;
                if (_settings.FreelookDevice == FeeelookDevice.Gamepad &&
                    _settings.AimWithGazeEnabled &&
                    !Game.Player.Character.IsInVehicle() &&
                    Game.IsKeyPressed(Keys.B))
                {
                    injectRightTrigger += 1;
                }

                //if (_settings.FreelookDevice == FeeelookDevice.Mouse)
                //{
                //	Game.Player.Character.Task.AimAt(shootCoord, 250); //raise the gun
                //}

                if (_settings.FreelookDevice == FeeelookDevice.Gamepad &&
                    _settings.ThirdPersonFreelookEnabled &&
                    Game.Player.Character.IsInVehicle() &&
                    Game.IsKeyPressed(Keys.W))
                {
                    _injectRightTrigger += 1;                     //TODO: block keyboard
                }

                _injectRightTrigger = injectRightTrigger;

                if (_settings.AimWithGazeEnabled &&
                    ((!_isInVehicle &&
                      ((!_menuOpen && User32.IsKeyPressed(VirtualKeyStates.VK_LBUTTON)) ||
                       (!radialMenuActive && controllerState.Gamepad.RightTrigger > 0)) ||
                      (Game.IsKeyPressed(Keys.B))) ||
                     (_isInVehicle &&
                      (!_menuOpen && User32.IsKeyPressed(VirtualKeyStates.VK_LBUTTON)))
                    ))
                {
                    var dir = shootCoord - Game.Player.Character.Position;
                    _headingToTarget = Geometry.DirectionToRotation(dir).Z;
                    //Game.Player.Character.Heading = _headingToTarget;

                    //Game.Player.Character.Rotation = new Vector3(Game.Player.Character.Rotation.X, Game.Player.Character.Rotation.Y, _headingToTarget);
                    //UI.ShowSubtitle("he " + Math.Round(Game.Player.Character.Heading,2));
                    Util.SetPedShootsAtCoord(Game.Player.Character, shootCoord);
                    //Game.Player.Character.Rotation = new Vector3(Game.Player.Character.Rotation.X, Game.Player.Character.Rotation.Y, _headingToTarget);
                }

                Vector2 screenCoords;
                if (Geometry.WorldToScreenRel(shootCoord, out screenCoords))
                {
                    _aiming.MoveCrosshair(screenCoords);
                }

                _debugOutput.DebugText2.Caption = "Cr: " + Math.Round(shootCoord.X, 1) + " | " + Math.Round(shootCoord.Y, 1) + " | " +
                                                  Math.Round(shootCoord.Z, 1);

                if (_settings.AimWithGazeEnabled &&
                    _isInVehicle &&
                    (Game.IsKeyPressed(Keys.B) ||
                     (User32.IsKeyPressed(VirtualKeyStates.VK_XBUTTON1)) ||
                     (!_isInAircraft && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder))))
                {
                    _aiming.Shoot(shootCoord);
                }

                if (_settings.IncinerateAtGazeEnabled &&
                    (Game.IsKeyPressed(Keys.J) ||
                     (User32.IsKeyPressed(VirtualKeyStates.VK_XBUTTON2)) ||
                     (!_isInAircraft && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.A)) ||
                     (_isInAircraft && !_menuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.A))))
                {
                    _aiming.Incinerate(shootCoordSnap);
                }

                if (_settings.TaseAtGazeEnabled &&
                    (Game.IsKeyPressed(Keys.H) ||
                     Game.IsKeyPressed(Keys.PageUp) ||
                     (!_isInAircraft && !_menuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.RightShoulder))))
                {
                    _aiming.Tase(shootCoordSnap);
                }

                if (Game.IsKeyPressed(Keys.U))
                {
                    _aiming.Water(shootCoord);
                }
            }
            if (shootMissileCoord.Length() > 0 && Geometry.IsInFrontOfThePlayer(shootMissileCoord))
            {
                if (_settings.MissilesAtGazeEnabled &&
                    (Game.IsKeyPressed(Keys.N) ||
                     Game.IsKeyPressed(Keys.PageDown) ||
                     (!radialMenuActive && !_menuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.B))))
                {
                    _aiming.ShootMissile(shootMissileCoord);
                }
            }
        }
示例#3
0
        public void Process(DateTime tickStopwatch, Vector2 gazePoint, double aspectRatio, Vector3 shootCoord, Vector3 shootCoordSnap, Vector3 shootMissileCoord, Ped ped, Entity missileTarget)
        {
            _lastTickTime            = tickStopwatch;
            _isPaused                = Game.IsPaused;
            _isInVehicle             = Game.Player.Character.IsInVehicle();
            _isInAircraft            = Game.Player.Character.IsInPlane || Game.Player.Character.IsInHeli;
            _isMeleeWeapon           = Util.IsMelee(Game.Player.Character.Weapons.Current.Hash);
            _isThrowableWeapon       = Util.IsThrowable(Game.Player.Character.Weapons.Current.Hash);
            _isSniperWeaponAndZoomed = Util.IsSniper(Game.Player.Character.Weapons.Current.Hash) &&
                                       (GameplayCamera.IsFirstPersonAimCamActive);
            _menuOpen = _menuPool.IsAnyMenuOpen();

            var controllerState = _controllerEmulation.ControllerState;

            if (!_menuOpen &&
                (controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.DPadDown) ||
                 User32.IsKeyPressed(VirtualKeyStates.VK_LMENU)))
            {
                //character selection
                _isInRadialMenu = true;
            }
            else if (!_isInVehicle && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder))
            {
                _isInRadialMenu = true;
                _radialMenu.Process(gazePoint, aspectRatio);
            }
            else
            {
                _isInRadialMenu = false;
                _freelook.Process(gazePoint, ped, aspectRatio);
            }

            if (controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftThumb) &&
                controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.Start) &&
                !_menuOpen)
            {
                _settingsMenu.OpenMenu();
            }

            if (shootCoord.Length() > 0 && Geometry.IsInFrontOfThePlayer(shootCoord))
            {
                var injectRightTrigger = 0;
                if (_settings.FreelookDevice == FeeelookDevice.Gamepad &&
                    _settings.AimWithGazeEnabled &&
                    !Game.Player.Character.IsInVehicle() &&
                    Game.IsKeyPressed(Keys.B))
                {
                    injectRightTrigger += 1;
                }

                if (_settings.FreelookDevice == FeeelookDevice.Gamepad &&
                    _settings.ThirdPersonFreelookEnabled &&
                    Game.Player.Character.IsInVehicle() &&
                    Game.IsKeyPressed(Keys.W))
                {
                    _injectRightTrigger += 1;                     //TODO: block keyboard
                }

                _injectRightTrigger = injectRightTrigger;

                if (_settings.AimWithGazeEnabled &&
                    ((!_isInVehicle &&
                      !_isMeleeWeapon &&
                      !_isThrowableWeapon &&
                      !_isSniperWeaponAndZoomed &&
                      ((!_isInRadialMenu && controllerState.Gamepad.LeftTrigger > 0) ||
                       User32.IsKeyPressed(VirtualKeyStates.VK_RBUTTON)
                      )
                      )))
                {
                    if (!_lastAimCameraAtTarget)
                    {
                        _freelook.AimCameraAtTarget(shootCoordSnap);
                    }
                    _lastAimCameraAtTarget = true;
                }
                else
                {
                    _lastAimCameraAtTarget = false;
                }

                //If you use mouse - shoot in the middle of the screen
                if (!_isInVehicle &&
                    (User32.IsKeyPressed(VirtualKeyStates.VK_LBUTTON) ||
                     User32.IsKeyPressed(VirtualKeyStates.VK_RBUTTON)))
                {
                    Vector3 camPoint;
                    Geometry.ScreenRelToWorld(new Vector2(0, 0), out camPoint, out shootCoord);
                }

                if (_settings.AimWithGazeEnabled &&
                    !_isInVehicle &&
                    (!_isMeleeWeapon &&
                     !_isThrowableWeapon &&
                     !_isSniperWeaponAndZoomed &&
                     ((!_isInRadialMenu && controllerState.Gamepad.RightTrigger > 0) ||
                      (Game.IsKeyPressed(Keys.B))
                     )
                    )
                    )
                {
                    _aiming.Shoot(shootCoord);
                }

                if (_settings.AimWithGazeEnabled &&
                    _isInVehicle &&
                    ((!_menuOpen && User32.IsKeyPressed(VirtualKeyStates.VK_LBUTTON)) ||
                     (Game.IsKeyPressed(Keys.B)) ||
                     (User32.IsKeyPressed(VirtualKeyStates.VK_XBUTTON1)) ||
                     (!_isInAircraft && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.LeftShoulder))
                    )
                    )
                {
                    _aiming.ShootBullet(shootCoord);
                }



                if ((_settings.MissilesAtGazeEnabled &&
                     Game.Player.Character.IsInVehicle()) &&
                    missileTarget != null)
                {
                    Vector2 screenCoords;
                    if (Geometry.WorldToScreenRel(missileTarget.Position, out screenCoords))
                    {
                        _aiming.MoveCrosshair(screenCoords);
                        _aiming.MissileLockedCrosshairVisible = true;
                    }
                }
                else
                {
                    Vector2 screenCoords;
                    if (Geometry.WorldToScreenRel(shootCoord, out screenCoords))
                    {
                        _aiming.MoveCrosshair(screenCoords);
                        _aiming.MissileLockedCrosshairVisible = false;
                    }
                }

                if (_settings.IncinerateAtGazeEnabled &&
                    (Game.IsKeyPressed(Keys.J) ||
                     (User32.IsKeyPressed(VirtualKeyStates.VK_XBUTTON2)) ||
                     (!_menuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.A))))
                {
                    _aiming.Incinerate(shootCoordSnap);
                }

                if (_settings.TaseAtGazeEnabled &&
                    (Game.IsKeyPressed(Keys.H) ||
                     Game.IsKeyPressed(Keys.PageDown) ||
                     (!_isInAircraft && !_menuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.RightShoulder))))
                {
                    _aiming.Tase(shootCoordSnap);
                }

                if (Game.IsKeyPressed(Keys.U))
                {
                    _aiming.Water(shootCoord);
                }
            }

            if (shootMissileCoord.Length() > 0 && Geometry.IsInFrontOfThePlayer(shootMissileCoord))
            {
                if (_settings.MissilesAtGazeEnabled &&
                    (Game.IsKeyPressed(Keys.N) ||
                     Game.IsKeyPressed(Keys.PageUp) ||
                     (!_isInRadialMenu && !_menuOpen && controllerState.Gamepad.Buttons.HasFlag(GamepadButtonFlags.B))))
                {
                    if (missileTarget != null)
                    {
                        _aiming.ShootMissile(missileTarget);
                    }
                    else
                    {
                        _aiming.ShootMissile(shootMissileCoord);
                    }
                }
            }
            _aiming.Process(_isInRadialMenu);
        }