[ALL] Add the ability to override weapon slot and position, with very basic TF2 UI support #1202
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
andm_iPosition
as networked properties onCBaseCombatWeapon
, which are initialized to the values previously returned byGetSlot()
andGetPosition()
. 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 withSelectItem()
behavior, if the vscript/mod so desires (lack of networking meant that overriding this during runtime would result in the client attempting to callSelectItem()
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 totf_weapon_builder
's unique setup, it is not affected by these changes (yet).tf_weapon_builder
's slot/pos netprops are updated wheneverSetSubType()
is called on it but otherwise function as other weapons do.Demonstration:
TF2: https://youtu.be/glJDdKqSIrU
HL2DM: https://youtu.be/XsAfBYtv54w