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

Fix #76414: Can't activate item - character instead tries to eat it. #76823

Merged
merged 2 commits into from
Oct 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 10 additions & 11 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7105,17 +7105,6 @@ bool Character::invoke_item( item *used, const std::string &method, const tripoi
return false;
}

if( actually_used->is_comestible() &&
actually_used->type->use_methods.find( "delayed_transform" ) ==
actually_used->type->use_methods.end() ) {
// Assume that when activating food that can be transformed, you're trying to transform it. Otherwise...
// Try to eat it.
add_msg_if_player( m_info, string_format( "Attempting to eat %s", actually_used->display_name() ) );
assign_activity( consume_activity_actor( item_location( *this, actually_used ) ) );
// If the character isn't eating, then invoking the item failed somewhere
return !activity.is_null();
}

std::optional<int> charges_used = actually_used->type->invoke( this, *actually_used,
pt, method );
if( !charges_used.has_value() ) {
Expand All @@ -7129,6 +7118,16 @@ bool Character::invoke_item( item *used, const std::string &method, const tripoi
return false;
}

if( actually_used->is_comestible() ) {
const bool ret = consume_effects( *used );
const int consumed = used->activation_consume( charges_used.value(), pt, this );
if( consumed == 0 ) {
// Nothing was consumed from within the item. "Eat" the item itself away.
i_rem( actually_used );
}
return ret;
}

actually_used->activation_consume( charges_used.value(), pt, this );

if( actually_used->has_flag( flag_SINGLE_USE ) || actually_used->is_bionic() ||
Expand Down
Loading