summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-01 23:01:54 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-01 23:01:54 +0000
commit9bd7a3af19172474a95751224c4bb2f5e7e31ac3 (patch)
tree4910a658cfcb6b1a473919376c619c7a08e2baf2 /crawl-ref
parentf9d00d00e2bd56d0f454ebea332e0617dcc4caa0 (diff)
downloadcrawl-ref-9bd7a3af19172474a95751224c4bb2f5e7e31ac3.tar.gz
crawl-ref-9bd7a3af19172474a95751224c4bb2f5e7e31ac3.zip
For flavor, make monsters that eat corpses effectively butcher them
first (e.g. leave blood from them on the floor if they're fresh). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8094 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/mon-util.cc26
2 files changed, 18 insertions, 10 deletions
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index cdbfe5e9e3..78dd421b5f 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1407,7 +1407,7 @@ public:
bool pickup_armour(item_def &item, int near, bool force);
bool pickup_misc(item_def &item, int near);
bool pickup_missile(item_def &item, int near, bool force);
- bool eat_corpse(item_def &carrion, int near);
+ bool eat_corpse(item_def &item, int near);
void equip(item_def &item, int slot, int near = -1);
bool unequip(item_def &item, int slot, int near = -1,
bool force = false);
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 2ac2063a78..8a8283f64d 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -4722,27 +4722,35 @@ bool monsters::pickup_gold(item_def &item, int near)
return pickup(item, MSLOT_GOLD, near);
}
-bool monsters::eat_corpse(item_def &carrion, int near)
+bool monsters::eat_corpse(item_def &item, int near)
{
if (!mons_eats_corpses(this))
return (false);
- hit_points += 1 + random2(mons_weight(carrion.plus)) / 100;
+ hit_points += 1 + random2(mons_weight(item.plus)) / 100;
// Limited growth factor here -- should 77 really be the cap? {dlb}:
- if (hit_points > 100)
- hit_points = 100;
-
- if (hit_points > max_hit_points)
- max_hit_points = hit_points;
+ hit_points = std::min(100, hit_points);
+ max_hit_points = std::max(hit_points, max_hit_points);
if (need_message(near))
{
mprf("%s eats %s.", name(DESC_CAP_THE).c_str(),
- carrion.name(DESC_NOCAP_THE).c_str());
+ item.name(DESC_NOCAP_THE).c_str());
}
- destroy_item( carrion.index() );
+ // Assume that eating a corpse requires butchering it.
+ //
+ // Use logic from misc.cc:turn_corpse_into_chunks().
+
+ 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(pos(), item.plus, max_chunks, true);
+
+ destroy_item(item.index());
+
return (true);
}