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

Camps can handle crafting liquid #69437

Merged
merged 2 commits into from
Nov 21, 2023

Conversation

RenechCDDA
Copy link
Member

@RenechCDDA RenechCDDA commented Nov 16, 2023

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

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.

@github-actions github-actions bot added [C++] Changes (can be) made in C++. Previously named `Code` Player Faction Base / Camp All about the player faction base/camp/site <Enhancement / Feature> New features, or enhancements on existing json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions labels Nov 16, 2023
@PatrikLundell
Copy link
Contributor

It would definitely be useful to have a new zone type for crafted liquid contents and have the zone being capable of specifying what liquid it takes (so the clean water goes into water tanks, milk goes into (refrigerated) milk tanks, etc.) so you wouldn't have to search your various targets to see where things ended up this time. Default would be no modifier, so any storage would do.

@GuardianDll
Copy link
Member

Not for this PR, but for a future development: new zone "containers for liquids", and NPC by default use containers from this zone for craft?

@RenechCDDA RenechCDDA marked this pull request as ready for review November 16, 2023 08:45
@RenechCDDA
Copy link
Member Author

I can make no promises for future zones with dynamic data-driven interactions, the implementation here turned out to be extraordinarily simple.

@github-actions github-actions bot added the <Bugfix> This is a fix for a bug (or closes open issue) label Nov 16, 2023
@RenechCDDA
Copy link
Member Author

OK I still don't know what the save functions are necessary for this, but clang thinks they are, so they have been implemented. I checked the save manually just to make sure I wasn't going to nuke it, too. Just saves the tripoints as a list. Whoopie.
image

@Maleclypse Maleclypse merged commit 8ee75e5 into CleverRaven:master Nov 21, 2023
@RenechCDDA RenechCDDA deleted the camp_liquid_crafting branch November 21, 2023 02:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` <Enhancement / Feature> New features, or enhancements on existing json-styled JSON lint passed, label assigned by github actions Player Faction Base / Camp All about the player faction base/camp/site
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Faction camp liquid recipe results should be stored in containers
4 participants