Prevent auto-eating items with use actions #3184
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
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
andhas_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
will_eat
instead.Testing
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.