Fix Ubercharge drain prediction errors

Shoutouts to @JustYourOrdinaryNormie for making me aware that my PR didn't fix ubercharge drain prediction errors!

Fixes prediction errors caused by Ubercharge draining by adding client only `DrainCharge`  functioncalls to the medi-gun's `ItemPostFrame` and newly added `ItemBusyFrame` functions.

Additionally, moved the Vaccinator charge removal outside of a server only #ifdef to fix prediction errors from using charges with the Vaccinator.
This commit is contained in:
treacherousfiend 2025-05-02 20:45:00 -06:00
parent 1b2c454e22
commit 436a84ec5c
2 changed files with 18 additions and 1 deletions

View File

@ -1610,9 +1610,25 @@ void CWeaponMedigun::ItemPostFrame( void )
m_bReloadDown = false;
}
#ifdef CLIENT_DLL
DrainCharge();
#endif
WeaponIdle();
}
//-----------------------------------------------------------------------------
// Purpose: Drain Ubercharge on client during weapon draw to fix prediction errors
//-----------------------------------------------------------------------------
void CWeaponMedigun::ItemBusyFrame( void )
{
#ifdef CLIENT_DLL
DrainCharge();
#endif
BaseClass::ItemBusyFrame();
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
@ -1963,11 +1979,11 @@ void CWeaponMedigun::SecondaryAttack( void )
{
// Remove charge immediately and just give target and yourself the conditions
m_bChargeRelease = false;
SetChargeLevel( m_flChargeLevel - flChunkSize );
#ifdef GAME_DLL
float flResistDuration = weapon_vaccinator_resist_duration.GetFloat();
CALL_ATTRIB_HOOK_FLOAT_ON_OTHER( pOwner, flResistDuration, add_uber_time );
pOwner->m_Shared.AddCond( g_MedigunResistConditions[GetResistType()].uberCond, flResistDuration, pOwner );
m_flChargeLevel -= flChunkSize;
if ( pTFPlayerPatient )
{
pTFPlayerPatient->m_Shared.AddCond( g_MedigunResistConditions[GetResistType()].uberCond, flResistDuration, pOwner );

View File

@ -73,6 +73,7 @@ public:
virtual void UpdateOnRemove( void );
virtual void ItemHolsterFrame( void );
virtual void ItemPostFrame( void );
virtual void ItemBusyFrame( void );
virtual bool Lower( void );
virtual void PrimaryAttack( void );
virtual void SecondaryAttack( void );