source-sdk-2013 icon indicating copy to clipboard operation
source-sdk-2013 copied to clipboard

Fix to infinite shotgun reload

Open bruhhhxyt opened this issue 6 months ago • 3 comments

This glitch can be reproduced doing this: Have phys_swap binded, equip the shotgun, shoot and reload, while you're reloading, change to the Gravity Gun via phys_swap, then use phys_swap again to get to the shotgun again. You will see the shotgun having a loop of reloading (you can shoot to interrupt the loop).

Here's a fix so the loop never occurs and fixes the glitch:

Go to weapon_shotgun.cpp, and go to line 753

void CWeaponShotgun::ItemHolsterFrame( void ) {

// Must be player held
if ( GetOwner() && GetOwner()->IsPlayer() == false )
	return;

// We can't be active
if ( GetOwner()->GetActiveWeapon() == this )
	return;

You will see this, so below the last return; add this:

if (m_bInReload) m_bInReload = false;

So now it would look like this:

void CWeaponShotgun::ItemHolsterFrame( void ) {

// Must be player held
if ( GetOwner() && GetOwner()->IsPlayer() == false )
	return;

// We can't be active
if ( GetOwner()->GetActiveWeapon() == this )
	return;

    if (m_bInReload)
      m_bInReload = false;

Now the shotgun will not longer make that loop.

I got this fix from TheMaster974, so credits to him, I guess. Here's the video of TheMaster974: https://www.youtube.com/watch?v=9JZXES3GaWU&list=PL8tDEPB6h7LnslIGAYRsmS-wS5MeorktV&index=3

bruhhhxyt avatar Jun 01 '25 17:06 bruhhhxyt

A PR with this fix is already available https://github.com/ValveSoftware/source-sdk-2013/pull/957/commits/eb02face6855533826313aa1552ea58024687f41

speedvoltage avatar Jun 05 '25 11:06 speedvoltage

@speedvoltage, thank you very much, it's much better than this one. Now, the objective is to get that commit to the actual source sdk 2013 code

bruhhhxyt avatar Jun 05 '25 13:06 bruhhhxyt

Do you have any idea on how to get that commit to the actual code?

bruhhhxyt avatar Jun 05 '25 13:06 bruhhhxyt