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

added gun length fixes (cut barrel & muzzle attachments) #46927

Merged
merged 5 commits into from
Feb 8, 2021

Conversation

Jamuro-g
Copy link
Contributor

@Jamuro-g Jamuro-g commented Jan 21, 2021

Summary

SUMMARY: Bugfixes "Cut barrel task & muzzle attachments now change the guns length"

Purpose of change

Cutting the barrel off a gun, didn't change the guns length at all.

  1. This change tries to use the barrel_volume tag to estimate what percentage of the length needs to be cut.
  2. Added/Removed muzzle attachments now will be taken into account and added to the weapons length.

Fixes #45806 (to some extend)

Describe the solution

1. Cutting
The guns barrel_volume (the stat used to reduce volume for guns with a cut barrel) is put in relation to the guns total volume to estimate a baseline of what percentage of the guns length gets cut.
It also should make is realy easy to swap out the current calculation in the future once we have an enforced more functional standard in the json files.

2. Attachments:
Gunmods get searched for the muzzle location and if found the items length will be added (this does not change the possible amount cut from the barrel!)

Describe alternatives you've considered

json md
"barrel_volume": "30 mL", // Amount of volume lost when the barrel is sawn. Approximately 250 ml per inch is a decent approximation.

This standard is neither enforced nor reasonable but that's something that needs fixing on it's own.

Testing

Spawn in 2 of a any rifle you wanna cut.
hacksaw one and compare the two.
Then grab a suppressor and add it to a valid gun. The guns length should be increased by the attachments length.

2 cut examples:
Barret anti material rifle loses 9 inches.
Double barrel shotgun loses 3inches.

Not a lot but working as intended. The error is with the json files having absurd barrel_volume amounts.

@ghost
Copy link

ghost commented Jan 21, 2021

Can you jsonize this for usage with pistol stocks/bayonets/suppressors?

@Jamuro-g
Copy link
Contributor Author

Jamuro-g commented Jan 21, 2021

Can you jsonize this for usage with pistol stocks/bayonets/suppressors?

i ll give it a try and see what i can do

update: i looked at the code and the best i can do is to ensure that the length of muzzle attachments & bayonets in underbarrel slot gets taken into account.
Meaning, suppressors and bayonets should have an effect on a guns length. (the length of items is currently calculated by the cubic root of the volume ... so adjust the volume in the json if you want to change the suppressors length)

Stocks on the other hand replace existing parts of the gun ... those default parts aren't curretly simulated and are just part of the guns core stats.
Sadly that means that stocks and any other replacement parts can't be used for this calculation and would require a complete overhaul of the gun system to implement.

@Jamuro-g Jamuro-g marked this pull request as draft January 21, 2021 22:02
@Jamuro-g Jamuro-g marked this pull request as ready for review January 22, 2021 01:14
@Jamuro-g Jamuro-g changed the title added gun length adjustment for the hacksaws cut barrel task added gun length fixes (cut barrel & muzzle attachments) Jan 22, 2021
@actual-nh
Copy link
Contributor

The "plain" /250 ml idea has the difficulty of not accounting for calibre, nor for multiple barrels (most notably in shotguns, unless a (M61) Vulcan has slipped in while I wasn't looking...). BTW, is the barrel volume for shotguns for one or two barrels (in applicable cases)?

@PatrikLundell
Copy link
Contributor

A quarter of a liter per 25.4 millimeter would mean it's an artillery piece, not something you can lug around. The comment for the json md would mean the example barrel is about 3 millimeters long...

@Jamuro-g
Copy link
Contributor Author

Jamuro-g commented Jan 22, 2021

The "plain" /250 ml idea has the difficulty of not accounting for calibre, nor for multiple barrels (most notably in shotguns, unless a (M61) Vulcan has slipped in while I wasn't looking...). BTW, is the barrel volume for shotguns for one or two barrels (in applicable cases)?

It should be for both barrels together, after all we don't track the number of barrels anywhere and use the stat to reduce the volume of guns with a cut barrel.
and you are right 250ml per inch is weird ... i ll run a few tests with 25ml per inch instead and take a look if that might be more reasonable.(maybe it's just a typo)

@int-ua int-ua added <Bugfix> This is a fix for a bug (or closes open issue) Items: Gunmod / Toolmod Weapon and tool attachments, and add-ons [C++] Changes (can be) made in C++. Previously named `Code` labels Feb 2, 2021
@ZhilkinSerg ZhilkinSerg merged commit 0caee8c into CleverRaven:master Feb 8, 2021
feinorgh pushed a commit to feinorgh/Cataclysm-DDA that referenced this pull request Feb 8, 2021
@kevingranade
Copy link
Member

This pull request has been mentioned on Cataclysm: Dark Days Ahead. There might be relevant details there:

https://discourse.cataclysmdda.org/t/sawing-off-shotguns-no-longer-works/25930/2

Ramza13 pushed a commit to Ramza13/Cataclysm-DDA that referenced this pull request Apr 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` Items: Gunmod / Toolmod Weapon and tool attachments, and add-ons
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Sawing down the barrel of a Barrett anti-materiel rifle doesn't change its length
6 participants