Skip to content

Commit

Permalink
Merge pull request #76823 from CavanStone/Can't-activate-item
Browse files Browse the repository at this point in the history
Fix #76414: Can't activate item - character instead tries to eat it.
  • Loading branch information
Maleclypse authored Oct 10, 2024
2 parents bf73865 + 30a378d commit b62308e
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions src/character.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7109,17 +7109,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 @@ -7133,6 +7122,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

0 comments on commit b62308e

Please sign in to comment.