Skip to content

[ALL] Add the ability to override weapon slot and position, with very basic TF2 UI support #1202

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

FlaminSarge
Copy link

@FlaminSarge FlaminSarge commented Apr 16, 2025

Description

This PR adds the ability for vscript/mods/etc. to override the slot and position in which a weapon will appear in a player's weapon selection HUD for all games.
It does this by adding m_iSlot and m_iPosition as networked properties on CBaseCombatWeapon, which are initialized to the values previously returned by GetSlot() and GetPosition(). These two methods now return those properties (and have been moved to be inlined in the header file; this can be reverted if needed).
It also makes m_iSubType networked so that multiple weapons of the same class can be used by one player without any conflicts with SelectItem() behavior, if the vscript/mod so desires (lack of networking meant that overriding this during runtime would result in the client attempting to call SelectItem() on a subtype that may have desynced from server).

This PR also updates the TF2 weapon selection HUD to display the currently-selected weapon for the active slot if there are more than one weapon in that position, as well as updating the implementation for the TF2 Plus-type fastswitch HUD so that it can function even with multiple weapons in one slot. This includes a fix where slot5/slot6 inputs would cause the Plus-type HUD to function incorrectly.

If vscript/etc. do not touch these properties, all behavior remains the same as stock for all games.

Note that due to tf_weapon_builder's unique setup, it is not affected by these changes (yet).
tf_weapon_builder's slot/pos netprops are updated whenever SetSubType() is called on it but otherwise function as other weapons do.

Demonstration:
TF2: https://youtu.be/glJDdKqSIrU
HL2DM: https://youtu.be/XsAfBYtv54w

…UI support

Also make m_iSubType networked so that multiple of the same weapon type can be set up on players
@FlaminSarge FlaminSarge changed the title Add the ability to override weapon slot and position, with very basic TF2 UI support [ALL] Add the ability to override weapon slot and position, with very basic TF2 UI support Apr 16, 2025
… one slot for TF2

HL2 already handles this case but TF2 does not handle the empty weapon positions well.
@FlaminSarge FlaminSarge marked this pull request as ready for review April 27, 2025 04:06
@FlaminSarge
Copy link
Author

FlaminSarge commented Apr 27, 2025

The intent behind this PR is to provide base functionality with semi-functional UI for VScript to start working with in the base (live) game.

Because GetSlot() and GetPosition() are strictly used for clientside weapon HUD selection, these new properties shouldn't break demos, as far as I can tell.

The followup change to fully implement a custom UI for extra weapon positions is a longer-term goal that may or may not be viable to merge into live game. I mainly plan to make it available for TF2 community mods to pull in, currently WIP at https://github.com/FlaminSarge/source-sdk-2013/tree/buckets, but if it's something that merges cleanly into base game, all the better.

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.

1 participant