Camps can handle crafting liquid #69437
Merged
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.
Summary
Features "Liquids crafted at camps will try to be placed inside zoned terrain/furniture that can hold them(LIQUIDCONT)"
Purpose of change
Crafting liquids at camps dumped them on the ground (lol)
Describe the solution
During the camp's zone initialization it registers a vector of absolute tripoints where it can place liquids (furniture or terrain with the LIQUIDCONT flag). These are saved much like the existing
dumping_spot
.When placing crafting results, it checks if the result is liquid and if so, tries to find an entry in the vector where there are no items already existing (most of the time liquids can't mix). Basically, "find an empty barrel and dump it in there".
If it doesn't find one, fine - it just reverts to putting the liquids where everything else goes. It also gives the player a popup explaining why it's dumping their precious crafting results on the ground.
Describe alternatives you've considered
Some sort of selectable menu like with personal crafting where you could select a valid container/(terrain/furniture?) to hold your new liquids
Testing
3x3 empty storage zone full of bathtubs, places new solid items at the center point (get_dumping_spot always uses the center of the zone), but places liquid items at the first evaluated point that can hold them (top-left):
https://github.com/CleverRaven/Cataclysm-DDA/assets/84619419/8f6280cf-ea9c-45ed-aa39-5cdb0856e824
3x3 storage zone with SOME possible containers, some items already in the area, and not all tiles covered in possible containers! Places new solid items at the center point, but places liquid items at the first evaluated point that can hold them (bottom-right, last spot to be evaluated):
https://github.com/CleverRaven/Cataclysm-DDA/assets/84619419/84e68b03-9ea9-4e9c-85f0-a50fbe59182b
Warning popup if resulting items would be placed on the ground (placement will still happen, but it lets the player know why):
![image](https://private-user-images.githubusercontent.com/84619419/283372570-930aebe5-cde9-49d5-aede-d24080271a15.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Mzk1NzUyNTQsIm5iZiI6MTczOTU3NDk1NCwicGF0aCI6Ii84NDYxOTQxOS8yODMzNzI1NzAtOTMwYWViZTUtY2RlOS00OWQ1LWFlZGUtZDI0MDgwMjcxYTE1LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTQlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjE0VDIzMTU1NFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWUxNTA2YTYxOGNlOTAzMGZiZWNmMWI4NjcxZTljOGExYjNmNDg5ODQ4YjY0YmY4OTAzYzhmOGFkMDc2ODg2YmYmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.cPvwtaRrPZkuRIiKRl36_uBq-io5B9HjyWVTUSDA5E0)
It successfully handles batch results, placing them all together at once.
Additional context
Known deficiencies:
-Although furniture can be a LIQUIDCONT I don't think zones are reinitialized unless the player modifies them in some way, so you could go push a toilet into your storage, initialize them, push the toilet out, and the game will happily dump crafted liquids onto the empty tile where it thinks a toilet is. Re-checking the zones is a bit more than I want to bite off here.Haha, they're reset right before the crafting results get placed! Perfect, nothing to worry about here.-I have not touched the save game functions as of this writing so it probably doesn't persist after a save and load cycle.They're reset before placement so I actually don't know why this would need to be serialized to the save except for legacy. This has no legacy equivalent, so it shouldn't matter.
-It cannot handle container items. Only furniture and terrain with LIQUIDCONT. This was intentional to KISS.