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

[CR] Implement blackpowder fouling mechanics #30985

Merged
merged 9 commits into from
Jun 15, 2019

Conversation

Rail-Runner
Copy link
Contributor

@Rail-Runner Rail-Runner commented May 30, 2019

Summary

SUMMARY: Features "Implement blackpowder fouling mechanics"

Purpose of change

The main reason is to allow firing blackpowder loads from guns not meant for that (though they will become jammed pretty quickly). Another is to be able to specify which guns can and can't (reasonably) handle blackpowder without just completely removing blackpowder from ammo recipe.

Describe the solution

First, I had to generalize fault mechanics to work for all items, not just engines.
Added two new flags (both were also added to gun classes and all 9x19mm guns):

Blackpowder fouling: slightly reduces gun reliability (by 1) while present on a gun, and adds a chance (1 in 2000) for gun to rust (increasing damage level by 1, capped at max damage before breaking) every turn (via item processing function). Always added to the gun upon firing ammo with BLACKPOWDER effect.

Clogged: prevents gun from firing until it is cleaned. May be added to the gun upon firing ammo with BLACKPOWDER effect, chance of that happening is 1 in (BT), where BT is a new JSON value named "blackpowder_tolerance", which equals 8 by default.

Added a new flag:

"BLACKPOWDER_CYCLE": any gun with this flag will properly cycle (allow firing multiple shots per attack) while firing blackpowder loads. Otherwise, gun will only fire a single shot and stop, effectively making it semi-auto-only.

Added a new ammo effect:

"BLACKPOWDER": notes that the ammo was loaded with blackpowder, causing all the above effects. This applies to ALL guns, not only those not designed to fire blackpowder (muzzleloaders need cleaning too, and will rust otherwise). But such resistant guns could have higher blackpowder tolerance.

Add a new "pipe cleaner" item (+ recipe) to remove both of faults upon use (one at a time). Currently it doesn't use power (because old blackpowder firearms apparently didn't need any to clean them)

Add new JSON value to some 9x19mm guns, and add blackpowder variants of 9x19mm cartridges, and crafting recipes for them (if this PR gets in, this could easily be expanded to other calibers).

Blackpowder loads currently have 30% price, 65% damage and recoil, 50% pierce, and 120% dispersion of equivalent smokeless powder ammo; they also get RECYCLED, BLACKPOWDER and MUZZLE_SMOKE flags, and NEVER_MISFIRES is removed if it was present.

Describe alternatives you've considered

Way too many to list all of them here. Neither of them made much sense or worked well enough, though.

Additional context

Current numbers are very arbitrary, and will likely need some adjusting.

@ifreund ifreund added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Items / Item Actions / Item Qualities Items and how they work and interact Ranged Ranged (firearms, bows, crossbows, throwing), balance, tactics labels May 30, 2019
@ymber
Copy link
Member

ymber commented May 30, 2019

Could this be generalized into weapon faults like engines have?

@Rail-Runner
Copy link
Contributor Author

Could this be generalized into weapon faults like engines have?

What for? I can't think of a reason for this.

@ymber
Copy link
Member

ymber commented May 30, 2019

There are a lot of ways a gun can get damaged in use, especially if you're abusing it. It's technically possible to fire .380 ACP from a 9x19mm pistol but it will probably damage the extractor. Even with normal use parts are going to wear out sooner or later and you're always going to have to do basic cleaning and maintenance. If we have a system to model this kind of thing for black powder effects it would be most useful generalized so it can be extended later.

@Rail-Runner
Copy link
Contributor Author

There are a lot of ways a gun can get damaged in use, especially if you're abusing it. It's technically possible to fire .380 ACP from a 9x19mm pistol but it will probably damage the extractor. Even with normal use parts are going to wear out sooner or later and you're always going to have to do basic cleaning and maintenance. If we have a system to model this kind of thing for black powder effects it would be most useful generalized so it can be extended later.

Just looked at it, and seems like it could indeed be implemented in a less invasive way with those. Will tinker with it tomorrow.

@esotericist
Copy link
Contributor

Glad to see someone starting on this. And yeah, this kind of thing is actually why mend is in the list of options when examining an item in your inventory, so if this could be set up to use the faults mechanic, that would be ideal.

@Rail-Runner
Copy link
Contributor Author

Rail-Runner commented May 31, 2019

Done, the same thing is now done via the fault system.

As a bonus, it also opens up the way for any items to have faults, so flashlight lightbulbs could burn out as they are used, bladed weapons could be dulled if used a lot (and that'll need a whetstone or something to fix, not a soldering iron), etc. (if someone codes that)

@Rail-Runner Rail-Runner changed the title [WIP] [CR] Implement blackpowder fouling mechanics [CR] Implement blackpowder fouling mechanics Jun 1, 2019
@ghost
Copy link

ghost commented Jun 4, 2019

Why not base an autoloading gun's ability to cycle on how closely a cartridge's recoil matches a new "cycling_energy" JSON string?

@Rail-Runner
Copy link
Contributor Author

Why not base an autoloading gun's ability to cycle on how closely a cartridge's recoil matches a new "cycling_energy" JSON string?

Well, it can be done, but is it really necessary now to complicate things like that? I can't think of any other severely underpowered cartridge loads that player would have a reason to craft or which could be found. If necessary, "not being able to cycle in most guns" feature could be split off of BLACKPOWDER flag into a separate one.

@ghost
Copy link

ghost commented Jun 5, 2019

Well, it can be done, but is it really necessary now to complicate things like that? I can't think of any other severely underpowered cartridge loads that player would have a reason to craft or which could be found.

@Rail-Runner https://discourse.cataclysmdda.org/t/ammunition-type-overlap-and-uses-for-such-a-thing/9475

@Rail-Runner
Copy link
Contributor Author

Got it done, now whether the gun cycles or not is based on "min_cycle_recoil" JSON parameter. For now, I've set it to 90% of default ammo recoil for guns that aren't supposed to cycle with blackpowder, and for 65% of it for guns that can cycle while firing blackpowder loads.

I didn't implement maximum recoil (the point at which the gun can be damaged by overpressure loads), as this isn't really related to blackpowder cartridges at all.

@kevingranade kevingranade merged commit 7d65bbe into CleverRaven:master Jun 15, 2019
@Rail-Runner Rail-Runner deleted the blackpowder_fouling branch June 15, 2019 08:05
@EldritchSigma
Copy link

EldritchSigma commented Nov 4, 2019

Hey so I do believe the fouling mechanic currently is somewhat broken. As of #35290 I found out that energy weapons do indeed foul according to that description and cannot be cleaned. I have had freshly spawned in new firearms foul. I cannot remove the regular fouling. I can remove the "blackpowder" fouling via (m)end along other faults. But the regular dirt is not removeable in any way to my knowledge.. Intended behavior or a bug? I cannot tell

@esotericist
Copy link
Contributor

esotericist commented Nov 5, 2019

@EldritchSigma
Just for the record, commenting on fairly old pull requests isn't the right way to draw attention to bugs.

Filing issues (like you already did) is the correct method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing Items / Item Actions / Item Qualities Items and how they work and interact [JSON] Changes (can be) made in JSON Ranged Ranged (firearms, bows, crossbows, throwing), balance, tactics
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants