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: secondary magazine gunmods can inherit more behaviors from parent gun #6083

Merged

Conversation

chaosvolt
Copy link
Member

Purpose of change (The Why)

This makes it so that gunmods whose gimmick is just "I'm actually a second magazine on this gun, not a real auxillery weapon" will act more like it, inheriting behaviors from the gun it's installed on.

Describe the solution (The How)

C++ changes:

  1. In flag.cpp and flag.h, added a new flag USE_PARENT_GUN for use below.
  2. In ranged.cpp, ranged::handle_gun_damage now tracks and applies fouling to the parent item if a gunmod with the USE_PARENT_GUN flag is the one firing.
  3. Also in ranged.cpp, calc_gun_volume likewise gains special handling for gunmods that having USE_PARENT_GUN, making it borrow the base loudness and loudness modifiers of any gunmods from the gun it's installed on, while still using the loudness value of its own ammo.
  4. In ranged.cpp, cycle_action likewise checks for if the item it's processing is a gunmod with USE_PARENT_GUN, and if so will check the parent item for whether to do RELOAD_EJECT and brass catcher functions, and additionally offload its spent cases/links to the parent item instead of loading itself with them.

JSON changes:

  1. Added JSON entry for new item flag.
  2. Added USE_PARENT_GUN flag to KSG second magazine, KSG-25 second magazine, TS12 second magazine, and TS12 third magazine.

Documentation changes:

  1. Documented new item flag in json_flags.md

Describe alternatives you've considered

Just doing the hackery route of making the KSG a 14-round shotgun and the Tavor a 15-round shotgun, like DDA ended up doing. That's boring and lame, so I dun wanna. :D

Testing

  1. Checked affected JSON files for syntax and lint errors.
  2. Compiled and load-tested.
  3. Spawned in an 870 and a KSG.
  4. Confirmed nothing weird happens when I fire either unmodded, hulls still spawn on the ground as normal.
  5. Installed brass catchers on both, Remington correctly catches and stores the hulls as expected.
  6. Fired the KSG both in its default mode and the second magazine, it correctly catches and stores the hulls with either firemode.
  7. Slapped a shotgun suppressor on the KSG, it now lowers the firing volume of both firemodes from 160 to 85 instead of only affecting the default firemode.
  8. Ran a bunch of blackpowder ammo through the KSG's second mag, the KSG itself now shows fouling instead of being hidden inside the second magazine.
  9. Ran some blackpowder ammo through both before cleaning and lubing the gun, it now only prints a message for the gun itself being cleaned, confirming the second mag received no fouling.
  10. Ran some dirty ammo through a combination gun and its second barrel to confirm it still treats the second barrel on it as a separate gun for the purpose of fouling.
  11. Checked affected C++ files for astyle.

It's hard to tell but it seems like dispersion and handling already uses the parent item, as can be verified by installing proper sights on the TS12 (which starts off with HORRENDOUS sight dispersion evidently due to not coming with iron sights by default). Shots tend to swing wide for all firemodes with it by default, while slapping proper sights on it makes it able to hit the broad side of a barn even with the secondary fire modes.

Additional context

Fun fact, auxiliary guns can also accept magazines, so this would make cursed things like this a bit more feasible:
AFDP-45-SS-14_3_HR

If anyone can find other properties involving gunmods that absolutely should apply to second-mag gunmods but don't, please do point me to where the offending code may be.

Checklist

Mandatory

@github-actions github-actions bot added docs PRs releated to docs page src changes related to source code. JSON related to game datas in JSON format. labels Feb 13, 2025
OrenAudeles
OrenAudeles previously approved these changes Feb 18, 2025
Copy link
Collaborator

@OrenAudeles OrenAudeles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code looks good, got a few questions but nothing that's absolutely required to change.

Co-authored-by: OrenAudeles <orenaudeles@gmail.com>
Copy link
Contributor

autofix-ci bot commented Feb 18, 2025

Autofix has formatted code style violation in this PR.

I edit commits locally (e.g: git, github desktop) and want to keep autofix
  1. Run git pull. this will merge the automated commit into your local copy of the PR branch.
  2. Continue working.
I do not want the automated commit
  1. Format your code locally, then commit it.
  2. Run git push --force to force push your branch. This will overwrite the automated commit on remote with your local one.
  3. Continue working.

If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT.

Copy link
Collaborator

@OrenAudeles OrenAudeles left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good 👍 I don't see anything else funky, and I said in the previous review it looked good anyway other than those few things so I don't see any reason to not approve it now.

@chaosvolt chaosvolt merged commit b23f214 into cataclysmbnteam:main Feb 21, 2025
16 checks passed
@chaosvolt chaosvolt deleted the ksg-finally-gets-gunmod-inheritance branch February 21, 2025 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs PRs releated to docs page JSON related to game datas in JSON format. src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants