From de8f4030ab16a4d839e67096aa45c89de5b0d9ab Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 28 Mar 2008 00:04:30 +0000 Subject: Clean up vampire biting attack, and call the new method whenever a vampire successfully stabs one of those walking blood replenishers. All in all, vampires will bite monsters that don't yield blood less often (1/3 chance), though their overall biting chance has been slightly increases, and much so when stabbing. Weapons of vampiricism are now a distinct case, so vampiric biting (that also is signified by SPWPN_VAMPIRICISM, occasionally) consistently doesn't check for life protection (though that might be added) and instead always respects the mons_has_blood checks. Also, food messages ("You are very hungry.") are now displayed in green if your food level has increased. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3904 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/food.cc | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) (limited to 'crawl-ref/source/food.cc') diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 79b577551a..d9f9585905 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -613,6 +613,7 @@ static bool food_change(bool suppress_message) { char newstate = HS_ENGORGED; bool state_changed = false; + bool less_hungry = false; you.hunger = std::max(you_min_hunger(), you.hunger); you.hunger = std::min(you_max_hunger(), you.hunger); @@ -636,6 +637,8 @@ static bool food_change(bool suppress_message) if (newstate != you.hunger_state) { state_changed = true; + if (newstate > you.hunger_state) + less_hungry = true; you.hunger_state = newstate; set_redraw_status( REDRAW_HUNGER ); @@ -645,41 +648,44 @@ static bool food_change(bool suppress_message) && you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT && you.duration[DUR_TRANSFORMATION] > 2) { - mpr("Your bloodfilled body can't sustain your transformation much longer.", - MSGCH_WARN); + mpr("Your bloodfilled body can't sustain your transformation much " + "longer.", MSGCH_WARN); you.duration[DUR_TRANSFORMATION] = 2; } - if (suppress_message == false) + if (!suppress_message) { + std::string msg = "You "; switch (you.hunger_state) { case HS_STARVING: if (you.species == SP_VAMPIRE) - mpr("You feel devoid of blood!"); + msg += "feel devoid of blood!"; else - mpr("You are starving!", MSGCH_FOOD); + msg += "are starving!"; learned_something_new(TUT_YOU_STARVING); you.check_awaken(500); break; case HS_NEAR_STARVING: if (you.species == SP_VAMPIRE) - mpr("You feel almost devoid of blood!"); + msg += "feel almost devoid of blood!"; else - mpr("You are near starving.", MSGCH_FOOD); + msg += "are near starving!"; learned_something_new(TUT_YOU_HUNGRY); break; case HS_VERY_HUNGRY: - mprf(MSGCH_FOOD, "You are feeling very %s.", how_hungry().c_str()); - learned_something_new(TUT_YOU_HUNGRY); - break; case HS_HUNGRY: - mprf(MSGCH_FOOD, "You are feeling %s.", how_hungry().c_str()); + msg += "are feeling "; + if (you.hunger_state == HS_VERY_HUNGRY) + msg += "very "; + msg += how_hungry(); + msg += "."; learned_something_new(TUT_YOU_HUNGRY); break; default: - break; + return (state_changed); } + mpr(msg.c_str(), MSGCH_FOOD, less_hungry); } } @@ -736,8 +742,9 @@ void eat_from_inventory(int which_inventory_slot) return; const int mons_type = food.plus; - const int chunk_type = mons_corpse_effect( mons_type ); const bool rotten = food_is_rotten(food); + const int chunk_type + = determine_chunk_effect(mons_corpse_effect( mons_type ), rotten); const int mass = mons_weight(food.plus)/150; if (!vampire_consume_corpse(mons_type, mass, chunk_type, rotten)) @@ -780,8 +787,9 @@ void eat_floor_item(int item_link) if (food.base_type == OBJ_CORPSES && food.sub_type == CORPSE_BODY) { const int mons_type = food.plus; - const int chunk_type = mons_corpse_effect( mons_type ); const bool rotten = food_is_rotten(food); + const int chunk_type + = determine_chunk_effect(mons_corpse_effect( mons_type ), rotten); const int mass = mons_weight(food.plus)/150; if (!vampire_consume_corpse(mons_type, mass, chunk_type, rotten)) -- cgit v1.2.3-54-g00ecf