Skip to content
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

fix: wielded weapon show correct ammocount when selecting gunmod, default firemode name for gunmods #4183

Conversation

chaosvolt
Copy link
Member

Purpose of change

This helps make it a bit more visible when your wielded weapon is currently set to fire an attached gunmod, because it's easy to look at the wield query after flipping past full-auto, forgetting that the next fire mode is an M203 and not returning to semi-auto, and oops I exploded again.

Describe the solution

  1. In character_functions.cpp, set fmt_wielded_weapon so that the ammo counter for the currently wielded weapon actually matches the ammo count of the current fire mode used, meaning the number of shots shown will properly change when you switch from a gun's normal firing modes to any attached gunmods.
  2. In item_factory.cpp, set defmode_name so that gunmods will generate a default fire mode name telling you at a glance that the selected fire mode has you switched to a gunmod. This can of course be override by any gunmods that define their own fire modes, such as with bayonets.

Describe alternatives you've considered

  1. Also someday coding in minimum arming distance for muh realisms.
  2. Figuring out how to make ammo counter say n/a instead of zero when a bayonet is selected.
  3. Continuing to blow myself up :<

Testing

  1. Compiled and load-tested.
  2. Spawned in as a grenadier, confirmed that switching my M4 to use the M203 shows the correct ammo count and says the fire mode is gunmod
  3. Swapped the M203 out for a bayonet and switched fire mode to it, confirmed it doesn't do anything weird. Shows no ammo since bayonet is melee, and fire mode listed is bayonet instead of gunmod since not a default fire mode name.
  4. Checked affected file for syntax and lint errors.

1

2

Additional context

Having stuff like more than one shootable gunmod installed (like an M203 and a rail-mounted crossbow for example) can still potentially confuse the player since chances are they'll both show as (1) [gunmod] etcetc but it's still more information than the player got previously. :3

Checklist

@github-actions github-actions bot added the src changes related to source code. label Feb 1, 2024
@chaosvolt chaosvolt merged commit 05cb054 into cataclysmbnteam:main Feb 7, 2024
12 checks passed
@chaosvolt chaosvolt deleted the make-the-ui-get-me-blown-up-less-often branch February 7, 2024 04:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants