-
Notifications
You must be signed in to change notification settings - Fork 277
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
feat(content,port): corpses decay into items, use existing harvest entries to actually implement feature, fix off-map decay behavior #4751
Conversation
Autofix has formatted code style violation in this PR. I edit commits locally (e.g: git, github desktop) and want to keep autofix
I do not want the automated commit
If you don't do this, your following commits will be based on the old commit, and cause MERGE CONFLICT. |
JSON
JSON
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this adds new methods in item
and map
class directly, which we should generally avoid without good reason (check #3200 for details). not sure for items, but for map it seems like the method added could have been a separate free function. could we extract the method into regular function here?
Maybe? Not sure where best to put it. Also, discovered a critical issue with this: bodies don't actually drop their harvest results if they rotted away while out of the reality bubble. Also covers bodies that spawn in map extras and the like when visited long after zero day. |
Tested DDA to see if I could replicate it, I can't even actually get bodies to properly recognize that it's been a year so they should've already rotted like I can in BN, and also managed to get it to error about not recognizing the harvest entry for the decay value I gave a zed for testing, so DDA's version of it is for now a complete write-off. Notifying @RenechCDDA since this is a DDA error with their version of the feature: |
So, root problem here in particular is corpse removal off-map appears to be handled by Problem is, dumping a call to |
Father I crave violence
There's one part I hate about this and that's the way I have to move stuff out of the `remove_with()` function to make it work. Sort of works but non-count_by_charges harvest materials don't stack when spawning for some reason?
f3e4798
to
7f3ce80
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me. Adding items into a temporary vector and then handling them at the end to avoid memory problems is fine and it's something we do in other places.
And at request of @VissValdyr during discussion in the BN server, I went ahead and added the "decay can potentially drop corpse components" idea in this PR instead of in a follow-up, since is a fairly basic addition. Uses the same odds and general behavior as the bare-minimum chance of obtaining corpse components when dissecting. Lowering it to something like 5% instead of 10% is a potential option if we feel it more balanced to make "at least try even though you know the success rate is at rock bottom currently" still worth attempting. |
Purpose of change
This aims to port over a feature recently added to DDA that'd been on my wishlist for a while, allowing corpses to decay into bones when left alone. Along the way, I went from having to actually do the JSON implementation myself to finding aw ay to make it automatically affect all butcherable monsters without needing to touch JSON.
Some cleanup and consistent edits to harvest JSONs were cooked up along the way, and subsequently moved to #4755 now that they're officially unrelated to this PR's changes.
Describe the solution
C++ changes:
item::process_internal
, and definition ofitem::get_corpse_mon
to item.cpp and item.h. Also set it to not do this with corpses that're about to zombify into something, so it doesn't break that.map::handle_decayed_corpse
from the source PR, converted to behave with the item identity behavior, and with some additional improvements. Most importantly, it now uses the monster'sharvest
entry directly, setting the items to use the corpse's birthday so that any perishable materials in the harvest yields will rot away correctly, leaving behind only bones, sinew, etc. This way we don't actually have to implement a million fuckingdecay
entries in the JSON. It also has a fix for the potential issues of spawning bionics or bionics groups on doing this, the latter if not forbidden would cause issues due to interpreting an itemgroup as an item and erroring.map::actualize
, right before the call toremove_rotten_items
. Reason is, just shoving the function call tohandle_decayed_corpse
intomap::remove_rotten_items
was causing it to implode with an access violation I couldn't figure out the cause of, but inserting a (somewhat hacky I feel, but functional) check for handling this earlier seems to make it happy at the expense of most likely making Scarf cry.JSON changes:
Describe alternatives you've considered
If desired, the chance to return CBMs from decaying corpses can either be postponed for a followup PR, nerfed even lower than the minimum success rate of dissection (if we feel we want to incentivize going for rock-bottom dissections of corpses about to rot, personally I feel using the same odds will probably encourage the player to waste their time less often in favor of going for better tools/skills), or just not done at all if people strongly object to having it.
Testing
2024-05-30
just advancing time has a high chance to make the body vanish instead.Next summer drug deal location:
Ant leftovers after debug-murdering them and warping back in after advancing time by a year:
A fresh example showing how bones are now at the top of the item stack instead of sinew:
End result of refugee center test:
Unlimited Moose Works:
And finally, screenshot from the cyborg corpse components testing, showing a CBM and non-CBM corpse component successfully dropping as intended:
Additional context
PR source:
Corpses can decay into bones, etc.
, by @RenechCDDA: CleverRaven/Cataclysm-DDA#74328In the future I'd also like to have it attempt to dump CBMs and other items generated on a corpse when it rots away, likely at the minimum of 10% chance so the player is still encouraged to harvest them themselves, but that can be a separate PR.
Checklist