Colt: 1.4f Garand: 6.0f Thompson: 2.15f BAR: 5.0f Springfield: 5.6f 30cal: 20.0f Bazooka: 10.0f M1carbine: 1.4f P38: 1.4f K98: 8.0f MP40: 2.2f StG44: 5.0f Scoped98K: 6.0f Mg42: 20.0f Panzerschreck: 10.0f MauserM1932: 3.0f
if( !p->m_Shared.IsInMGDeploy() ) { if ( prediction->IsFirstTimePredicted() ) p->DoRecoil( GetWeaponID(), m_pWeaponInfo->m_flRecoil ); }
You can also hook the pointer to the CDODPlayerShared vtable on the Heap to get access to IsInMGDeploy and forge a return true.
void C_DODPlayer::DoRecoil( int iWpnID, float flWpnRecoil ) { float flPitchRecoil = flWpnRecoil; float flYawRecoil = flPitchRecoil / 4; if( iWpnID == WEAPON_BAR ) flYawRecoil = min( flYawRecoil, 1.3 ); if ( m_Shared.IsInMGDeploy() ) { flPitchRecoil = 0.0; flYawRecoil = 0.0; } else if ( m_Shared.IsProne() && iWpnID != WEAPON_30CAL && iWpnID != WEAPON_MG42 ) //minor hackage { flPitchRecoil = flPitchRecoil / 4; flYawRecoil = flYawRecoil / 4; } else if ( m_Shared.IsDucking() ) { flPitchRecoil = flPitchRecoil / 2; flYawRecoil = flYawRecoil / 2; } SetRecoilAmount( flPitchRecoil, flYawRecoil ); } void C_DODPlayer::SetRecoilAmount( float flPitchRecoil, float flYawRecoil ) { //Slam the values, abandon previous recoils m_flPitchRecoilAccumulator = flPitchRecoil; flYawRecoil = flYawRecoil * random->RandomFloat( 0.8, 1.1 ); if( random->RandomInt( 0,1 ) <= 0 ) m_flYawRecoilAccumulator = flYawRecoil; else m_flYawRecoilAccumulator = -flYawRecoil; m_flRecoilTimeRemaining = RECOIL_DURATION; }
RECOIL_DURATION is 0.1. Useful to know since you can 0 that as well, and the recoil will be multiplied by zero removing it entirely. Notwithstanding you can hook the C_DODPlayer, and go that route if you care to.
void C_DODPlayer::GetRecoilToAddThisFrame( float &flPitchRecoil, float &flYawRecoil ) { if( m_flRecoilTimeRemaining <= 0 ) { flPitchRecoil = 0.0; flYawRecoil = 0.0; return; } float flRemaining = min( m_flRecoilTimeRemaining, gpGlobals->frametime ); float flRecoilProportion = ( flRemaining / RECOIL_DURATION ); flPitchRecoil = m_flPitchRecoilAccumulator * flRecoilProportion; flYawRecoil = m_flYawRecoilAccumulator * flRecoilProportion; m_flRecoilTimeRemaining -= gpGlobals->frametime; }
void C_DODPlayer::ClientThink() { BaseClass::ClientThink(); if ( gpGlobals->curtime >= m_fNextThinkPushAway ) { PerformObstaclePushaway( this ); m_fNextThinkPushAway = gpGlobals->curtime + PUSHAWAY_THINK_INTERVAL; } if ( IsLocalPlayer() ) { UpdateIDTarget(); StaminaSoundThink(); // Recoil QAngle viewangles; engine->GetViewAngles( viewangles ); float flYawRecoil; float flPitchRecoil; GetRecoilToAddThisFrame( flPitchRecoil, flYawRecoil ); // Recoil if( flPitchRecoil > 0 ) { //add the recoil pitch viewangles[PITCH] -= flPitchRecoil; viewangles[YAW] += flYawRecoil; } // Sniper sway if( m_Shared.IsSniperZoomed() && GetFOV() <= 20 ) { //multiply by frametime to balance for framerate changes float x = gpGlobals->frametime * cos( gpGlobals->curtime ); float y = gpGlobals->frametime * 2 * cos( 2 * gpGlobals->curtime ); float scale; if( m_Shared.IsDucking() ) //duck scale = ZOOM_SWAY_DUCKING; else if( m_Shared.IsProne() ) scale = ZOOM_SWAY_PRONE; else //standing scale = ZOOM_SWAY_STANDING; if( GetAbsVelocity().Length() > 10 ) scale += ZOOM_SWAY_MOVING_PENALTY; viewangles[PITCH] += y * scale; viewangles[YAW] += x * scale; } engine->SetViewAngles( viewangles ); } else { // Cold breath. UpdateColdBreath(); } }
Comment