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FNOPMWYYJHJBTTY33PB43HTJPKEC46L62YERTWIX73HYZSELXQC
// Harpies may eat food/corpses on the ground.
if (monster->type == MONS_HARPY && !mons_is_fleeing(monster)
&& (mons_wont_attack(monster)
|| (grid_distance(monster->pos(), you.pos()) > 1))
&& (mons_is_wandering(monster) && one_chance_in(3)
|| one_chance_in(5))
&& expose_items_to_element(BEAM_STEAL_FOOD, monster->pos(), 10))
{
simple_monster_message(monster, " eats something on the ground.");
monster->speed_increment -= non_move_energy;
continue;
}
// XXX: This function assumes that only undead (which can heal from
// eating) eat corpses.
static bool _monster_eat_corpse(monsters *monster, bool monster_nearby)
static bool _monster_eat_single_corpse(monsters *monster, item_def& item,
bool do_heal, bool nearby)
if (monster_nearby)
if (nearby)
{
mprf("%s eats %s.", monster->name(DESC_CAP_THE).c_str(),
item.name(DESC_NOCAP_THE).c_str());
}
// Assume that eating a corpse requires butchering it. Use logic
// from misc.cc:turn_corpse_into_chunks() and the butchery-related
// delays in delay.cc:stop_delay().
const int max_chunks = mons_weight(item.plus) / 150;
// Only fresh corpses bleed enough to colour the ground.
if (!food_is_rotten(item))
bleed_onto_floor(monster->pos(), item.plus, max_chunks, true);
if (mons_skeleton(item.plus) && one_chance_in(3))
turn_corpse_into_skeleton(item);
else
destroy_item(item.index());
return (true);
}
static bool _monster_eat_corpse(monsters *monster, bool do_heal, bool nearby)
{
if (!mons_eats_corpses(monster))
return (false);
int eaten = 0;
for (stack_iterator si(monster->pos()); si; ++si)
{
if (_monster_eat_single_corpse(monster, *si, do_heal, nearby))
if (mons_skeleton(si->plus) && one_chance_in(3))
turn_corpse_into_skeleton(*si);
else
destroy_item(si->index());
int eaten = 0;
for (stack_iterator si(monster->pos()); si; ++si)
{
const bool is_food = (si->base_type == OBJ_FOOD);
const bool is_corpse = (si->base_type == OBJ_CORPSES
&& si->sub_type == CORPSE_BODY);
eaten++;
break;
if (!is_food && !is_corpse)
continue;
if ((mons_wont_attack(monster)
|| grid_distance(monster->pos(), you.pos()) > 1)
&& one_chance_in(3))
{
if (is_food)
{
if (nearby)
{
mprf("%s eats %s.", monster->name(DESC_CAP_THE).c_str(),
quant_name(*si, 1, DESC_NOCAP_THE).c_str());
}
dec_mitm_item_quantity(si.link(), 1);
eaten++;
break;
}
else
{
// Assume that only undead can heal from eating corpses.
if (_monster_eat_single_corpse(monster, *si,
monster->holiness() == MH_UNDEAD,
nearby))
{
eaten++;
break;
}
}
}
if (_monster_eat_corpse(monster, monster_nearby))
// Assume that only undead can heal from eating corpses.
if (_monster_eat_corpse(monster, monster->holiness() == MH_UNDEAD,
nearby))
{
return (false);
}
}
else if (mons_eats_food(monster))
{
if (_monster_eat_food(monster, nearby))
Monsters with MONEAT_ITEMS are capable of eating most items, while
monsters with MONEAT_CORPSES are capable of eating corpses.
Monsters with MONEAT_ITEMS are capable of eating most items,
monsters with MONEAT_CORPSES are capable of eating corpses, and
monsters with MONEAT_FOOD are capable of eating food (note that
corpses also count as food).