google-site-verification: googlebaca44933768a824.html Removing recoil in DoD:S - Old Royal Hack Forum

Announcement

Collapse
No announcement yet.

Removing recoil in DoD:S

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Removing recoil in DoD:S

    flWpnRecoil

    Code:
    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
    Code:
    if( !p->m_Shared.IsInMGDeploy() )
    {
    	if ( prediction->IsFirstTimePredicted() )
    		p->DoRecoil( GetWeaponID(), m_pWeaponInfo->m_flRecoil );
    }
    As we can see, we have a neat way out, hooking the prediction code. So useful of an interface, could return false and call it a day. Alternatively, we can 0 m_pWeaponInfo->m_flRecoil and just be done with it.

    You can also hook the pointer to the CDODPlayerShared vtable on the Heap to get access to IsInMGDeploy and forge a return true.

    Code:
    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;
    }
    I reversed all of this by hand years ago, but having the leaked SDK is much nicer. So we see several interesting things. We could hook the RandomFloat and return zero and kill the YAW recoil here.

    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.

    Code:
    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;
    }
    Notice the m_flRecoilTimeRemaining, as I told you above, just zero it and be done with it.

    Code:
    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();
    	}
    }
    Good old ClientThink, this is called during Simulation. No surprise how easy it is to do with FrameStageNotify ( FRAME_RENDER_START ) if that's your poison. Zero before and be done with it. Or hook GetViewAngles or SetViewAngles. On and on. The leebest way is to manually calculate the next frame's recoil yourself and set your viewangles before hand to remove it entirely. Think CreateMove here.

    #2
    Re: Removing recoil in DoD:S

    now i can create new pay to hag site. thx!

    Comment


      #3
      Re: Removing recoil in DoD:S

      Originally posted by paacmanacc View Post
      now i can create new pay to hag site. thx!
      I'll use my spambots to advertise it for a cut of the jew golds on the backdeck.

      Comment


        #4
        Re: Removing recoil in DoD:S

        God bless Murika
        lolmaoman: Germans are born with a lifetime x22 login engraved into their birth certificates. True story.
        I DONT HAVE TEAMVIEWER AND IM NOT GOING TO GIVE ANY 24/7 ONLINE SUPPORT VIA STEAM, XFIRE OR OTHER IM PROGRAMS SO DONT BOTHER ASKING. THANKS.

        Comment


          #5
          Re: Removing recoil in DoD:S

          Originally posted by mencore View Post
          God bless Murika
          Damn right.

          Comment


            #6
            Re: Removing recoil in DoD:S

            Originally posted by ph0ne
            i came at this thread
            no homo
            lolmaoman: Germans are born with a lifetime x22 login engraved into their birth certificates. True story.
            I DONT HAVE TEAMVIEWER AND IM NOT GOING TO GIVE ANY 24/7 ONLINE SUPPORT VIA STEAM, XFIRE OR OTHER IM PROGRAMS SO DONT BOTHER ASKING. THANKS.

            Comment


              #7
              Re: Removing recoil in DoD:S

              Originally posted by ph0ne
              i came at this thread
              no homo
              Pressing thanks helps alot!

              Comment

              Working...
              X