From 8b6107e382417e437cc541dfad85c20234ca3d7c Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Tue, 15 Apr 2008 13:43:36 +0000 Subject: Vampire "eating" interface: Only offer corpses (inventory or floor) that actually contain blood. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4243 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/food.cc | 31 +++++++++++++++++++++++++------ 1 file changed, 25 insertions(+), 6 deletions(-) (limited to 'crawl-ref/source/food.cc') diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 962da54dbe..3f7e4b5da1 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -577,9 +577,7 @@ bool eat_food(bool run_hook, int slot) // If user hook ran, we don't know whether something // was eaten or not... if (run_hook && userdef_eat_food()) - { return (false); - } if (igrd[you.x_pos][you.y_pos] != NON_ITEM && slot == -1) { @@ -859,6 +857,8 @@ int eat_from_floor() return 0; bool need_more = false; + int vamp_undrainable_corpse = 0; + bool found_valid = false; for (int o = igrd[you.x_pos][you.y_pos]; o != NON_ITEM; o = mitm[o].link) { item_def& item = mitm[o]; @@ -866,18 +866,28 @@ int eat_from_floor() if (you.species != SP_VAMPIRE && item.base_type != OBJ_FOOD) continue; - if (you.species == SP_VAMPIRE && - (item.base_type != OBJ_CORPSES || item.sub_type != CORPSE_BODY)) - continue; + if (you.species == SP_VAMPIRE) + { + if (item.base_type != OBJ_CORPSES || item.sub_type != CORPSE_BODY) + continue; + if (!mons_has_blood(item.plus)) + { + vamp_undrainable_corpse++; + continue; + } + } + + found_valid = true; std::ostringstream prompt; prompt << (you.species == SP_VAMPIRE ? "Drink blood from" : "Eat") << ' ' << ((item.quantity > 1) ? "one of " : "") << item.name(DESC_NOCAP_A) << '?'; + const int ans = yesnoquit( prompt.str().c_str(), true, 0, false, 'E' ); if ( ans == -1 ) // quit return -1; - else if ( ans == 1 ) + else if ( ans == 1 ) // yes { if (can_ingest(item.base_type, item.sub_type, false)) { @@ -886,6 +896,15 @@ int eat_from_floor() } need_more = true; } + // else no: try next one + } + + if (!found_valid && vamp_undrainable_corpse) + { + mprf("%s devoid of blood.", + (vamp_undrainable_corpse == 1) ? "This corpse is" + : "These corpses are"); + need_more = true; } if (need_more && Options.auto_list) -- cgit v1.2.3-54-g00ecf