ValveSoftware / halflife

Half-Life 1 engine based games
Other
3.68k stars 624 forks source link

Half-Life 1: Opposing Force autoaim bug #966

Open Ghost99 opened 11 years ago

Ghost99 commented 11 years ago

After autoaim option disabling cursor can be not centered on screen. Steps to reproduce:

  1. Aim somebody with autoaim enabled (cursor is not on center of screen)
  2. Open options and disable autoaim
  3. Cursor will be still not on center of screen, until level will be reloaded

I can confirm that bug on GNU/Linux.

ghost commented 11 years ago

Windows + Half-Life affected too

Xylemon commented 9 years ago

Can we please get this fixed? It's crazy annoying.

SamVanheer commented 3 years ago

This is an issue in all GoldSource engine games that use autoaim since they're all based off of the same thing.

Fixing it is pretty easy. This is the code involved in the bug: https://github.com/ValveSoftware/halflife/blob/c7240b965743a53a29491dd49320c88eecf6257b/dlls/player.cpp#L4319-L4330

Modify it to be like this:

// Don't send across network if sv_aim is 0
if ( g_psv_aim->value != 0 )
{
    if ( m_vecAutoAim.x != m_lastx ||
         m_vecAutoAim.y != m_lasty )
    {
        SET_CROSSHAIRANGLE( edict(), -m_vecAutoAim.x, m_vecAutoAim.y );

        m_lastx = m_vecAutoAim.x;
        m_lasty = m_vecAutoAim.y;
    }
}
else
{
    ResetAutoaim();
}

If sv_aim is set to 0 while the crosshair is autoaiming it will properly reset the angles. Note that the crosshair's current location is considered to be the center of the screen so turning off autoaim will center the screen on the crosshair, not the other way around.