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

Prevent auto-eating items with use actions #3184

Merged

Conversation

chaosvolt
Copy link
Member

Summary

SUMMARY: Bugfixes "Prevent auto-eat code from selection items with use actions to avoid Y/N queries softlocking an auto-eat attempt"

Purpose of change

As mentioned in #3183, I intended to also add a code PR to nip this issue in the bud full-stop via a code solution.

From what I can tell, the root issue is specifically items that have an iuse that brings up a yes/no query. Mundane inedible stuff like meat for an herbivore character is already handled by will_eat, but stuff like asking if you want to eat tainted meat is handled through the item having an iuse.

As far as I can tell, the only real ways to check that are has_use and has_iuse. The latter can check for specific use actions, but it's a member of item factory and not usable in the relevant function, which handles an item. The other drawback is we'd need to manually screen for every iuse that can be canceled in some way if we want to be 100% sure we get all potential abuses that might softlock the player (and for some the answer will vary item by item, e.g. spellcasting items).

can_use is a simpler case of just asking if the offending item has any use action, period. Right now every case in the comestibles folder (barring some transforming and disassembly items that aren't actually comestibles) uses a blech/poison action, Mycus-related stuff, an alcohol use action, mutagen, or drug-related use actions, all of which we don't really want to be auto-eaten at the moment, so the simple solution seems like the best option anyway.

Describe the solution

In activity_item_handling.cpp, added a condition to find_auto_consume that excludes all items remaining that have a use action defined.

Describe alternatives you've considered

  1. Figuring out or writing a function that lets me check for specific items at the item level so I can manually filter out only those use actions that might trigger the softlock.
  2. Rigging some kinda way to check whether a use action will lead to a query or other way to fuck it up and cause a softlock, allowing for stuff like Eater of The Dead players being able to auto-eat poisoned stuff.
  3. Rigging it so that selecting no on a query flags the item as blacklisted from auto-eat in some way.
  4. Converting the use actions that are causing all these problems to item flags instead so that handling of this can be dumped into will_eat instead.

Testing

  1. Compiled and load-tested.
  2. Tested placing clean water in an auto-drink zone, confirmed that it overriding use action with a blank entry means it correclty counts as not having a use action.
  3. Temporarily removed UNSAFE_CONSUME from tainted meat, confirmed that dehydrated meat (which has enough fun to not be skipped over already) still doesn't trigger the softlock like it used to.

Additional context

One casualty of this is honeycombs, which use a use action to hack in leaving behind wax when eaten. The only other "normal" food to suffer for this would be special brownies, but whether those should be avoided by auto-eat is more debatable since they are technically triggering drug effects, with the main counterargument being unlike alcohol weed items don't have addiction effects.

@github-actions github-actions bot added the src changes related to source code. label Sep 19, 2023
Copy link
Collaborator

@Firestorm01X2 Firestorm01X2 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hotfix

@Firestorm01X2 Firestorm01X2 merged commit 87d4d5f into cataclysmbnteam:upload Sep 20, 2023
16 checks passed
@chaosvolt chaosvolt deleted the fix-auto-eat-softlock branch September 20, 2023 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants