Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zoom Sensitivity Multiplier persists after unzooming #279

Open
Herobrine24 opened this issue Jan 1, 2025 · 1 comment
Open

Zoom Sensitivity Multiplier persists after unzooming #279

Herobrine24 opened this issue Jan 1, 2025 · 1 comment
Milestone

Comments

@Herobrine24
Copy link

Herobrine24 commented Jan 1, 2025

File: SFXGame.pcc

Export ID/Instanced Full Path:
16477 / BioPlayerInput.AdjustMouseSensitivity
16471 / BioPlayerInput.PreProcessInput

Description of fix:
The function AdjustMouseSensitivity runs every tick, adjusting the mouse sensitivity as needed.
When the player zooms in with their weapon, it pulls the CameraSensitivityMultiplier from the weapon's AimModes array.
The Sniper Rifle has 2 AimModes entries, each corresponding to the zoom level adjustable with the Middle Mouse Button. The furthest zoom has a multiplier that is less than 1. When the player uses the second zoom on the sniper rifle, this non-1 multiplier persists until you swap weapons.
The fix addresses this by explicitly checking if the weapon is currently zoomed before retrieving the multiplier, otherwise setting it to 1.0.

Corrected Function Code:

public function AdjustMouseSensitivity(float FOVScale)
{
    local SFXCameraInput Input;
    local float CameraSensitivityMultiplier;
    local BioWeaponRanged Weapon;
    local SFXPlayerCamera CamManager;
    
    Super.AdjustMouseSensitivity(FOVScale);
    aGuiMouseX *= MouseSensitivity * FOVScale;
    aGuiMouseY *= MouseSensitivity * FOVScale;
    Weapon = BioWeaponRanged(Outer.Pawn.Weapon);
    if (Weapon != None && Weapon.bIsZoomed == TRUE)
    {
        CameraSensitivityMultiplier = Weapon.GetCameraSensitivityMultiplier();
    }
    else
    {
        CameraSensitivityMultiplier = 1.0;
    }
    CamManager = SFXPlayerCamera(Outer.PlayerCamera);
    if (CamManager != None && CamManager.CurrentCameraMode != None)
    {
        Input = CamManager.CurrentCameraMode.Input;
        if (Input != None)
        {
            aMouseX *= Input.CameraSensitivity.X * CameraSensitivityMultiplier;
            aMouseY *= Input.CameraSensitivity.Y * CameraSensitivityMultiplier;
            if (Input.bClampMouse)
            {
                aMouseX = FClamp(aMouseX, -Input.MouseClampMax, Input.MouseClampMax);
                aMouseY = FClamp(aMouseY, -Input.MouseClampMax, Input.MouseClampMax);
            }
        }
    }
}

Presumably this function is used for controllers. I don't have any to validate this:

public function PreProcessInput(float DeltaTime)
{
    local SFXCameraInput Input;
    local float RawStickFactor;
    local float StickFactor;
    local float fRemappedX;
    local float fRemappedY;
    local float StickMag;
    local float X;
    local float Y;
    local int Idx;
    local SFXPlayerCamera CamManager;
    local float CameraSensitivityMultiplier;
    local BioWeaponRanged Weapon;
    
    if (bUseMouseDampening)
    {
        Class'BioInterpolator'.static.InterpolateFloatCurve(fRemappedX, MouseDampeningCurve, 0.0, 1.0, Abs(aMouseX));
        Class'BioInterpolator'.static.InterpolateFloatCurve(fRemappedY, MouseDampeningCurve, 0.0, 1.0, Abs(aMouseY));
        aMouseX = (aMouseX > float(0) ? 1.0 : -1.0) * fRemappedX;
        aMouseY = (aMouseY > float(0) ? 1.0 : -1.0) * fRemappedY;
        Class'BioInterpolator'.static.InterpolateFloatCurve(fRemappedX, MouseDampeningCurve, 0.0, 1.0, Abs(aGuiMouseX));
        Class'BioInterpolator'.static.InterpolateFloatCurve(fRemappedY, MouseDampeningCurve, 0.0, 1.0, Abs(aGuiMouseY));
        aGuiMouseX = (aGuiMouseX > float(0) ? 1.0 : -1.0) * fRemappedX;
        aGuiMouseY = (aGuiMouseY > float(0) ? 1.0 : -1.0) * fRemappedY;
    }
    RawStickFactor = Sqrt(aTurn * aTurn + aLookUp * aLookUp);
    CamManager = SFXPlayerCamera(Outer.PlayerCamera);
    if (CamManager.CurrentCameraMode != None)
    {
        Weapon = BioWeaponRanged(Outer.Pawn.Weapon);
        if (Weapon != None && Weapon.bIsZoomed == TRUE)
        {
            CameraSensitivityMultiplier = Weapon.GetCameraSensitivityMultiplier();
        }
        else
        {
            CameraSensitivityMultiplier = 1.0;
        }
        Input = CamManager.CurrentCameraMode.Input;
        if (Input != None && RawStickFactor > Input.StickDeadZone)
        {
            StickFactor = ComputeStickResponse(RawStickFactor, Input, DeltaTime) / RawStickFactor;
            aTurn = aTurn * Input.CameraSensitivity.X * CameraSensitivityMultiplier * GlobalStickFactor * StickFactor * Outer.GetSensitivityScaling();
            aLookUp = aLookUp * Input.CameraSensitivity.Y * CameraSensitivityMultiplier * GlobalStickFactor * StickFactor * Outer.GetSensitivityScaling();
        }
    }
    if (AxisBuffer[0] != float(0) || AxisBuffer[1] != float(0) || AxisBuffer[0] != LastAxisBuffer[0] || AxisBuffer[1] != LastAxisBuffer[1])
    {
        X = AxisBuffer[0];
        Y = AxisBuffer[1];
        StickMag = Sqrt(X * X + Y * Y);
        if (StickMag <= GuiDeadzone)
        {
            X = 0.0;
            Y = 0.0;
        }
        Outer.GetScaleFormManager().HandleInputEvent(2, 0.0, X, X);
        Outer.GetScaleFormManager().HandleInputEvent(3, 0.0, Y, Y);
    }
    if (AxisBuffer[2] != float(0) || AxisBuffer[3] != float(0) || AxisBuffer[2] != LastAxisBuffer[2] || AxisBuffer[3] != LastAxisBuffer[3])
    {
        X = AxisBuffer[2];
        Y = AxisBuffer[3];
        StickMag = Sqrt(X * X + Y * Y);
        if (StickMag <= GuiDeadzone)
        {
            X = 0.0;
            Y = 0.0;
        }
        Outer.GetScaleFormManager().HandleInputEvent(4, 0.0, X, X);
        Outer.GetScaleFormManager().HandleInputEvent(5, 0.0, Y, Y);
    }
    if (AxisBuffer[4] != LastAxisBuffer[4] || AxisBuffer[5] != LastAxisBuffer[5])
    {
        X = AxisBuffer[4];
        Y = AxisBuffer[5];
        Outer.GetScaleFormManager().HandleInputEvent(6, 0.0, X, X);
        Outer.GetScaleFormManager().HandleInputEvent(7, 0.0, Y, Y);
    }
    for (Idx = 0; Idx < 6; Idx++)
    {
        LastAxisBuffer[Idx] = AxisBuffer[Idx];
        AxisBuffer[Idx] = 0.0;
    }
}

Fix as standalone mod: https://mega.nz/file/V2oHUDYB#zy9O7MEgsgo5YwnguZzE7TXfFptKZ--BKmk6YxyrqOU

Credit: https://www.reddit.com/r/masseffect/comments/1hp8nt9/le1_mouse_sensitivity_issues/

@henbagle
Copy link
Owner

henbagle commented Jan 6, 2025

Great fix! I think editing GetCameraSensitivityMultiplier to check for bIsZoomed would be an easier way to fix this - much smaller function and would cover both controller and mouse with one edit. Testing with the following

public function float GetCameraSensitivityMultiplier()
{
    if (Stats == None || bIsZoomed == FALSE)
    {
        return 1.0;
    }
    return Stats.AimModes[CurrentAimMode].CameraSensitivityMultiplier;
}

@henbagle henbagle added this to the 2.0 milestone Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants