feat: reversible bullet recipes can have different uncraft requirements #4656
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.
Purpose of change
This at long last follows up on fixing all the jank in #886 by properly implementing a way for reversible recipes to automatically decide whether it requires cutting 1, pulling 1, or pulling 2 to take the ammo apart. Without this you have to define explicit uncrafts for factory ammo, something we can now axe. Conversely, this fixes the issue of the few existing reversible ammo recipes all demanding pulling 1 no matter what their factory counterparts need to dismantle.
Currently WIP as it's gonna take a while to add to all the recipes, plus right now I'm having a problem actually finding how to get the code to correctly check for flags in the tool it finds. Was given the go-ahead to post it up here so others can look at it.
Describe the solution
C++ changes:
UNCRAFT_CONVERT_TO_CUTTING
andUNCRAFT_CONVERT_TO_PULLING_2
. These are intended to be used in tool entries, to affect what that recipe does when reversed, if marked as reversible.requirement_data::disassembly_requirements
so that the handling of converting hand press recipes into bullet pulling when reversed is at long last sanity-checked: if it findsUNCRAFT_CONVERT_TO_CUTTING
tacked onto the hand press, it adds cutting quality of 1 instead of bullet pulling. Meanwhile if it findsUNCRAFT_CONVERT_TO_PULLING_2
it instead upgrades the required pulling requirement to level 2. At least, it's supposed to but currently I need to get it checkingtool_comp
for the flags, I think?JSON changes:
UNCRAFT_CONVERT_TO_CUTTING
to the hand press in theshot_forming
crafting requirement. This makes it so that shotshells that use this crafting requirement can now be set to be reverisible while still converting them to use cutting instead of pulling quality, where previously this only worked right if you set aside an explicit uncraft for that.bullet_forming_rifle
. This is identical tobullet_forming
except its hand press is flagged withUNCRAFT_CONVERT_TO_PULLING_2
. Intended for rifle bullet recipes where we want them to require a bullet puller to take apart and not just mere pliers, this ensures they will get their pulling quality escalated from 1 to 2 during recipe reversal.TODO:
Describe alternatives you've considered
Unending fucking screaming at how janky the hardcoded uncraft generation is.
Testing
Testing to continue as implementation is completed. Right now I'm at an impasse: the actual check is a cursed-ass
for
loop buried in anotherfor
loop, which is why it's so hard to effectively vary up the conversions here. Far as I can tell, the check needs to be looking to see if thetool_comp
that it found the tool in has the flag, and right now it's checking theitype
of the tool it found for presumably item flags instead. Hence, it currently compiles without issue but completely fails to trigger either of the if statements, so 00 shot as of right now demands pliers to reverse its recipe instead of cutting quality.Additional context
Speaking of, the ability to axe explicit uncrafts for ammo and use purely reversible recipes will come in handy if developed further later on, to convert all those wacky conversions into a more JSONized form.
Checklist