diff --git a/src/game/shared/hl2mp/weapon_rpg.cpp b/src/game/shared/hl2mp/weapon_rpg.cpp index 1859958e3..23ce83f88 100644 --- a/src/game/shared/hl2mp/weapon_rpg.cpp +++ b/src/game/shared/hl2mp/weapon_rpg.cpp @@ -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() ); diff --git a/src/game/shared/hl2mp/weapon_rpg.h b/src/game/shared/hl2mp/weapon_rpg.h index bbd6f2dd2..e314071c3 100644 --- a/src/game/shared/hl2mp/weapon_rpg.h +++ b/src/game/shared/hl2mp/weapon_rpg.h @@ -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