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

Player weapons still receive input when starting to use a func_tank #3345

Open
SamVanheer opened this issue Apr 1, 2023 · 0 comments
Open

Comments

@SamVanheer
Copy link

When the player is using a func_tank they normally can't send inputs to their weapons. This is because of this check here:

halflife/dlls/player.cpp

Lines 3866 to 3885 in c7240b9

// check if the player is using a tank
if ( m_pTank != NULL )
return;
#if defined( CLIENT_WEAPONS )
if ( m_flNextAttack > 0 )
#else
if ( gpGlobals->time < m_flNextAttack )
#endif
{
return;
}
ImpulseCommands();
if (!m_pActiveItem)
return;
m_pActiveItem->ItemPostFrame( );
}

But the player starts using a func_tank in PlayerUse, called by ImpulseCommands. The very first frame that the player starts using a func_tank or other controllable gun the remaining code in the ItemPostFrame function will still execute, causing weapons to respond to inputs after being holstered.

In the Gauss gun's case holding down secondary attack, using the gun and then moving away causes the Gauss gun to discharge.

To fix this an additional check is needed:

ImpulseCommands();

// check again if the player is using a tank if they started using it in PlayerUse
if (m_pTank != NULL)
	return;

if (!m_pActiveItem)
	return;

m_pActiveItem->ItemPostFrame( );

Originally found by Oxofemple.

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