engine/actions/source/ConsumableAction.cpp
// Consume a consumable, adding its nutrition to the hunger counter,
// and its grams of absorbable pure alcohol (based on the number of standard 
// drinks) to the creature's grams of unabsorbed alcohol.  Then, check to see
// if it's poisoned - if it is, potentially poison the creature.
Consume a consumable, adding its nutrition to the hunger counter,
and its grams of absorbable pure alcohol (based on the number of standard
drinks) to the creature's grams of unabsorbed alcohol.  Then, check to see
if it's poisoned - if it is, potentially poison the creature.
Consume a consumable adding its nutrition to the hunger counter and its grams of absorbable pure alcohol ( based on the number of standard drinks ) to the creature ' s grams of unabsorbed alcohol . Then check to see if it ' s poisoned - if it is potentially poison the creature .
ActionCostValue ConsumableAction::consume(CreaturePtr creature, ConsumablePtr consumable, const bool process_effect)
{
  ActionCostValue action_cost_value = ActionCostConstants::NO_ACTION;
  if (creature && consumable)
  {
    Game& game = Game::instance();
    MapPtr current_map = game.get_current_map();
    pair<Coordinate, TilePtr> creature_loc = current_map->get_location_and_tile(creature->get_id());
    HungerClock& hunger = creature->get_hunger_clock_ref();
    int hunger_before = hunger.get_hunger();
    int nutrition = consumable->get_nutrition();
    hunger.set_hunger(hunger.get_hunger() + nutrition);
    int hunger_after = hunger.get_hunger();
    CreatureUtils::add_hunger_level_message_if_necessary(creature, hunger_before, hunger_after);
    creature->increment_grams_unabsorbed_alcohol(AlcoholConverter::standard_drinks_to_absorbable_grams(consumable->get_standard_drinks()));
    EffectType et = consumable->get_effect_type();
    if (et != EffectType::EFFECT_TYPE_NULL && process_effect)
    {
      EffectPtr consumable_effect = EffectFactory::create_effect(et, {}, {}, "", creature->get_id());
      consumable_effect->effect(creature, &game.get_action_manager_ref(), consumable->get_status(), creature_loc.first, creature_loc.second);
    }
    gain_resistances_from_consumable(creature, consumable);
    if (consumable->get_poisoned())
    {
      StatusEffectPtr poison = StatusEffectFactory::create_status_effect(StatusIdentifiers::STATUS_ID_POISON, "" );
      string base_id = consumable->get_base_id();
      int danger_level = 1;
      const auto item_map = Game::instance().get_item_generation_values_ref();
      auto i_it = item_map.find(base_id);
      if (i_it != item_map.end())
      {
        danger_level = i_it->second.get_danger_level();
      }
      if (poison && poison->should_apply_change(creature, ConsumableConstants::FOOD_POISON_APPLICATION_BONUS))
      {
        poison->apply_change(creature, danger_level);
      }
    }
    if (consumable->get_unpaid())
    {
      MapUtils::anger_shopkeeper_if_necessary(current_map->get_location(creature->get_id()), current_map, creature);
    }
    if (nutrition > 0)
    {
      creature->get_conducts_ref().break_conduct(ConductType::CONDUCT_TYPE_FOODLESS);
    }
    if (consumable->get_food_type() == FoodType::FOOD_TYPE_MEAT)
    {
      creature->get_conducts_ref().break_conduct(ConductType::CONDUCT_TYPE_VEGETARIAN);
    }
    if (consumable->is_corpse())
    {
      creature->get_conducts_ref().break_conduct(ConductType::CONDUCT_TYPE_CORPSELESS);
    }
  }
  return action_cost_value;
}
ActionCostValue ConsumableAction :: consume ( CreaturePtr creature , ConsumablePtr consumable , const bool process_effect ) { ActionCostValue action_cost_value = ActionCostConstants :: NO_ACTION ; if ( creature && consumable ) { Game & game = Game :: instance ( ) ; MapPtr current_map = game . get_current_map ( ) ; pair < Coordinate , TilePtr > creature_loc = current_map -> get_location_and_tile ( creature -> get_id ( ) ) ; HungerClock & hunger = creature -> get_hunger_clock_ref ( ) ; int hunger_before = hunger . get_hunger ( ) ; int nutrition = consumable -> get_nutrition ( ) ; hunger . set_hunger ( hunger . get_hunger ( ) + nutrition ) ; int hunger_after = hunger . get_hunger ( ) ; CreatureUtils :: add_hunger_level_message_if_necessary ( creature , hunger_before , hunger_after ) ; creature -> increment_grams_unabsorbed_alcohol ( AlcoholConverter :: standard_drinks_to_absorbable_grams ( consumable -> get_standard_drinks ( ) ) ) ; EffectType et = consumable -> get_effect_type ( ) ; if ( et != EffectType :: EFFECT_TYPE_NULL && process_effect ) { EffectPtr consumable_effect = EffectFactory :: create_effect ( et , { } , { } , " " , creature -> get_id ( ) ) ; consumable_effect -> effect ( creature , & game . get_action_manager_ref ( ) , consumable -> get_status ( ) , creature_loc . first , creature_loc . second ) ; } gain_resistances_from_consumable ( creature , consumable ) ; if ( consumable -> get_poisoned ( ) ) { StatusEffectPtr poison = StatusEffectFactory :: create_status_effect ( StatusIdentifiers :: STATUS_ID_POISON , " " ) ; string base_id = consumable -> get_base_id ( ) ; int danger_level = 1 ; const auto item_map = Game :: instance ( ) . get_item_generation_values_ref ( ) ; auto i_it = item_map . find ( base_id ) ; if ( i_it != item_map . end ( ) ) { danger_level = i_it -> second . get_danger_level ( ) ; } if ( poison && poison -> should_apply_change ( creature , ConsumableConstants :: FOOD_POISON_APPLICATION_BONUS ) ) { poison -> apply_change ( creature , danger_level ) ; } } if ( consumable -> get_unpaid ( ) ) { MapUtils :: anger_shopkeeper_if_necessary ( current_map -> get_location ( creature -> get_id ( ) ) , current_map , creature ) ; } if ( nutrition > 0 ) { creature -> get_conducts_ref ( ) . break_conduct ( ConductType :: CONDUCT_TYPE_FOODLESS ) ; } if ( consumable -> get_food_type ( ) == FoodType :: FOOD_TYPE_MEAT ) { creature -> get_conducts_ref ( ) . break_conduct ( ConductType :: CONDUCT_TYPE_VEGETARIAN ) ; } if ( consumable -> is_corpse ( ) ) { creature -> get_conducts_ref ( ) . break_conduct ( ConductType :: CONDUCT_TYPE_CORPSELESS ) ; } } return action_cost_value ; }
Consume a consumable, adding its nutrition to the hunger counter,
and its grams of absorbable pure alcohol (based on the number of standard
drinks) to the creature's grams of unabsorbed alcohol.
Consume a consumable adding its nutrition to the hunger counter and its grams of absorbable pure alcohol ( based on the number of standard drinks ) to the creature ' s grams of unabsorbed alcohol .
// Get any intrinsics from the resistances on the item being greater than // the creature's combined race and class values. // Much greater chance to get poisoned by consuming poisoned food/drink // than by getting attacked by a poisoned attack. /* no source id */ // Shopkeepers don't appreciate sampling. // Vegetarians can't consume meat. // Is the food actually a corpse?  Corpseless is a conduct due to the // general advantage adventurers get by eating corpses.