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

Update first pass component selection to avoid poison #70826

Merged
merged 6 commits into from
Jan 14, 2024

Conversation

PatrikLundell
Copy link
Contributor

@PatrikLundell PatrikLundell commented Jan 10, 2024

Summary

None

Purpose of change

Fix #70796, i.e. select non poisonous/hallucinogenic food in preference of poisonous/hallucinogenic one where the same item exists in both variants, as well as indicate the need to use such undesirable items when there aren't enough of them by coloring the item line in magenta (same logic that's used for used water tight containers).

Note: This PR's purpose has been expanded from its first incarnation. The various edit notes have been removed and only the "final" content remains. This note is made to explain why things have changed, if anyone has looked at the PR previously.

Describe the solution

Extend the restriction for first pass item selection to exclude known poisonous and hallucinogenic items in addition to the previous exclusion of containers containing items.

As a side effect the odd case where a separate filter was used (because it was used together with a supplied filter) had its first pass filter use a common operation to remove code duplication.

The code ended up no longer being inlined as the addition relied on flags that weren't in the set of files copied into the header (and the compiler complained about mismatching definitions elsewhere when it was done).

Changed the logic for component coloring to use the same kind of two pass process the component selection used, as that logic also had the side effect of determining whether components should be consumed from the personal inventory, environment inventory, or both. The changed process also made use of the same filter as the consumption used, rather than local defined ones. This added the effect handling poisonous/hallucinogenic food items.

Describe alternatives you've considered

  • Try to figure out how to detect if the crafter is unaware of the poison. My current belief is that this information is not stored, but calculated on the fly for display only purposes when a poisonous/hallucinogenic item is found.
  • Change the consumption logic for used containers to a three pass process, where the first pass would look for any kind of empty containers, the second one add containers using non liquid contents, and the third one going for all containers. Considered out of scope, as well as not obvious it would be desired.

Testing

  • Debug spawned two normal and two poisonous mushrooms.
  • Dropped one of each on the tile to the south of the PC.
  • Crafted cooked mushrooms (the recipe uses two mushrooms).
  • Verified I ended up with normal (not poisonous) cooked mushrooms.
  • Spawned two normal mushrooms and dropped one on the tile beneath the PC's feet together with the poisonous one in the inventory.
  • Crafted cooked mushrooms and verified the result was non poisonous and that the poisonous mushrooms remained where they were dropped.
  • Spawned a normal mushroom.
  • Crafted cooked mushrooms, verifying the shroom entry was magenta and that the result was poisonous.
  • Spawned the components for two charcoal kilns and dropped one tank on the tile beneath the PC and the other on the tile to the east (had moved to a different crafting spot as I had most materials available there).
  • Spawned two more tanks and "refilled" them with fluid. Dropped one tank on the tile beneath the PC and the other on the tile to the east.
  • Crafted two charcoal kilns and verified the used tanks remained on the floor (this test is a regression test).
  • Verified the charcoal kiln recipe entry showed the tank component in magenta (as no empty tanks were available). Again, this is a regression test.

In addition to the "formal" ones above, a lot of tests were made during the development of this PR, including ones using hallucinogenic mushrooms.

Additional context

As noted, I'm unable to test for usage of undetected poisonous shrooms, but I doubt there actually is such a thing beside the message shown when the shrooms are discovered. There's some Survival based code for whether to detect if shrooms are poisonous/hallucinogenic, but I failed to see any code to keep track of that on the item itself.

During the development and testing of this PR, #70846 was encountered. It was verified that bug existed prior to the start of the work on this PR.

@github-actions github-actions bot added Crafting / Construction / Recipes Includes: Uncrafting / Disassembling [C++] Changes (can be) made in C++. Previously named `Code` Player Faction Base / Camp All about the player faction base/camp/site 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 Jan 10, 2024
@PatrikLundell PatrikLundell marked this pull request as draft January 11, 2024 12:23
@github-actions github-actions bot added Info / User Interface Game - player communication, menus, etc. and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Jan 12, 2024
@PatrikLundell PatrikLundell marked this pull request as ready for review January 12, 2024 12:20
@github-actions github-actions bot added the <Bugfix> This is a fix for a bug (or closes open issue) label Jan 12, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Jan 12, 2024
@Maleclypse Maleclypse merged commit 4b86f1d into CleverRaven:master Jan 14, 2024
25 of 26 checks passed
@PatrikLundell PatrikLundell deleted the avoid_poison branch January 14, 2024 07:53
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` Crafting / Construction / Recipes Includes: Uncrafting / Disassembling Info / User Interface Game - player communication, menus, etc. 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.

Pickled veggie recipe will include identified poisonous mushrooms without warning or required confirmation.
2 participants