Fix client-side reload animation with the RPG

► Fixed an issue where the client treated the rocket as dead and would reload client-side.
This commit is contained in:
speedvoltage 2025-03-11 21:49:01 +01:00
parent a62efecf62
commit eb1efc500a
2 changed files with 18 additions and 4 deletions

View file

@ -1262,7 +1262,7 @@ IMPLEMENT_NETWORKCLASS_ALIASED( WeaponRPG, DT_WeaponRPG )
#ifdef CLIENT_DLL
void RecvProxy_MissileDied( const CRecvProxyData *pData, void *pStruct, void *pOut )
{
CWeaponRPG *pRPG = ((CWeaponRPG*)pStruct);
CWeaponRPG *pRPG = ( ( CWeaponRPG * ) pStruct );
RecvProxy_IntToEHandle( pData, pStruct, pOut );
@ -1272,11 +1272,18 @@ void RecvProxy_MissileDied( const CRecvProxyData *pData, void *pStruct, void *pO
{
if ( pRPG->GetOwner() && pRPG->GetOwner()->GetActiveWeapon() == pRPG )
{
if ( pRPG->IsPredictingMissile() )
{
pRPG->SetPredictingMissile( false );
return; // Ignore this frame's `NotifyRocketDied()`
}
pRPG->NotifyRocketDied();
}
}
}
#endif
BEGIN_NETWORK_TABLE( CWeaponRPG, DT_WeaponRPG )
@ -1426,7 +1433,7 @@ void CWeaponRPG::PrimaryAttack( void )
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
if ( !pPlayer )
return;
// Can't have an active missile out
@ -1443,12 +1450,11 @@ void CWeaponRPG::PrimaryAttack( void )
m_flNextPrimaryAttack = gpGlobals->curtime + 0.5f;
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner == NULL )
return;
Vector vForward, vRight, vUp;
pOwner->EyeVectors( &vForward, &vRight, &vUp );
Vector muzzlePoint = pOwner->Weapon_ShootPosition() + vForward * 12.0f + vRight * 6.0f + vUp * -3.0f;
@ -1472,6 +1478,8 @@ void CWeaponRPG::PrimaryAttack( void )
pMissile->SetDamage( GetHL2MPWpnData().m_iPlayerDamage );
m_hMissile = pMissile;
#else
SetPredictingMissile( true );
#endif
DecrementAmmo( GetOwner() );

View file

@ -233,6 +233,8 @@ public:
void GetWeaponAttachment( int attachmentId, Vector &outVector, Vector *dir = NULL );
void DrawEffects( void );
// void DrawLaserDot( void );
bool IsPredictingMissile() const { return m_bClientPredictingMissile; }
void SetPredictingMissile( bool enabled ) { m_bClientPredictingMissile = enabled; }
CMaterialReference m_hSpriteMaterial; // Used for the laser glint
CMaterialReference m_hBeamMaterial; // Used for the laser beam
@ -262,6 +264,10 @@ protected:
private:
CWeaponRPG( const CWeaponRPG & );
#ifdef CLIENT_DLL
bool m_bClientPredictingMissile; // Tracks if the client should treat a missile as active
#endif
};
#endif // WEAPON_RPG_H