Skip to content

Fix: scattergun that has knockback cannot be fired on preround#1835

Open
M60TM wants to merge 2 commits intoValveSoftware:masterfrom
M60TM:Fix-not-firing-gun-preround
Open

Fix: scattergun that has knockback cannot be fired on preround#1835
M60TM wants to merge 2 commits intoValveSoftware:masterfrom
M60TM:Fix-not-firing-gun-preround

Conversation

@M60TM
Copy link

@M60TM M60TM commented Mar 13, 2026

Description

  • During the pre-round (before setup time finishes), the CTFScattergun with the set_scattergun_has_knockback attribute set to 1 cannot be fired because the code bypasses BaseClass::FireBullet. This PR fixes that behavior.

@JoriKos
Copy link
Contributor

JoriKos commented Mar 13, 2026

I could be 100% wrong but isn't if ( !pOwner ) a check that's seeing if pOwner successfully contains a player, and if it doesn't then it shouldn't proceed with anything below it because the game crashes?

@bakugo
Copy link
Contributor

bakugo commented Mar 13, 2026

That check makes no sense regardless because the pPlayer passed into the function is already the owner of the weapon. So pOwner can be removed entirely and replaced with pPlayer.

@JoriKos
Copy link
Contributor

JoriKos commented Mar 13, 2026

Wouldn't it still, in its current state, cause a crash if it doesn't contain a player?

@bakugo
Copy link
Contributor

bakugo commented Mar 13, 2026

It will always contain a player, as this was already checked higher up in the call stack:

// Get the player owning the weapon.
CTFPlayer *pPlayer = ToTFPlayer( GetPlayerOwner() );
if ( !pPlayer )
return;

@M60TM
Copy link
Author

M60TM commented Mar 14, 2026

Would it be better to replace pOwner with pPlayer? pOwner and pPlayer are used interchangeably in the code.

- They reference same entity in-game
@mastercoms
Copy link
Contributor

Maybe best to just change HasKnockback. Or else some other effects will possibly run in ApplyPostHitEffects and other places.

@M60TM
Copy link
Author

M60TM commented Mar 16, 2026

The codes in FireBullet is intended to prevent movement via knockback before the round starts. Modifying the HasKnockback function could potentially introduce side effects in other parts of the code.

@bakugo
Copy link
Contributor

bakugo commented Mar 16, 2026

Yes, modifying HasKnockback() directly would affect the hardcoded animation overrides in CTFScatterGun::SendWeaponAnim().

Also, it's probably important to note that these changes do not affect the entirety of setup time, only the short freeze time at the start where players cannot move. This check was likely added purely to prevent scouts from boosting themselves forward during that time, and disabling on-hit effects isn't necessary.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants