summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-08 19:13:30 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-08 19:13:30 +0000
commit06c5d3d75459c2f78297095550311e8aac37af80 (patch)
tree79b70d65b32e70caabbf2a25e90fee98acdefdda /crawl-ref/source
parent9a20cf0a34b9caec2ff9a5c3708a88fb84c80496 (diff)
downloadcrawl-ref-06c5d3d75459c2f78297095550311e8aac37af80.tar.gz
crawl-ref-06c5d3d75459c2f78297095550311e8aac37af80.zip
Clean up nutrition-related functions a bit, and handle non-vampires'
nutrition from blood potions more consistently. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8983 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/food.cc48
-rw-r--r--crawl-ref/source/food.h1
-rw-r--r--crawl-ref/source/it_use2.cc24
-rw-r--r--crawl-ref/source/player.cc11
-rw-r--r--crawl-ref/source/player.h1
5 files changed, 51 insertions, 34 deletions
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index b25b538ddf..71416e87f8 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -1678,7 +1678,7 @@ void chunk_nutrition_message(int nutrition)
mpr("That was not very filling.");
}
-static int _apply_herbivore_chunk_effects(int nutrition)
+int apply_herbivore_nutrition_effects(int nutrition)
{
int how_herbivorous = player_mutation_level(MUT_HERBIVOROUS);
@@ -1688,6 +1688,12 @@ static int _apply_herbivore_chunk_effects(int nutrition)
return (nutrition);
}
+static int _apply_gourmand_nutrition_effects(int nutrition, int gourmand)
+{
+ return (nutrition * (gourmand + GOURMAND_NUTRITION_BASE)
+ / (GOURMAND_MAX + GOURMAND_NUTRITION_BASE));
+}
+
static int _chunk_nutrition(bool likes_chunks)
{
int nutrition = CHUNK_BASE_NUTRITION;
@@ -1695,15 +1701,14 @@ static int _chunk_nutrition(bool likes_chunks)
if (likes_chunks || you.hunger_state < HS_SATIATED)
{
return (likes_chunks ? nutrition
- : _apply_herbivore_chunk_effects(nutrition));
+ : apply_herbivore_nutrition_effects(nutrition));
}
const int gourmand =
- wearing_amulet(AMU_THE_GOURMAND)? you.duration[DUR_GOURMAND] : 0;
+ wearing_amulet(AMU_THE_GOURMAND) ? you.duration[DUR_GOURMAND] : 0;
- int effective_nutrition =
- nutrition * (gourmand + GOURMAND_NUTRITION_BASE)
- / (GOURMAND_MAX + GOURMAND_NUTRITION_BASE);
+ const int effective_nutrition =
+ _apply_gourmand_nutrition_effects(nutrition, gourmand);
#ifdef DEBUG_DIAGNOSTICS
const int epercent = effective_nutrition * 100 / nutrition;
@@ -1712,7 +1717,7 @@ static int _chunk_nutrition(bool likes_chunks)
gourmand, nutrition, effective_nutrition, epercent);
#endif
- return (_apply_herbivore_chunk_effects(effective_nutrition));
+ return (apply_herbivore_nutrition_effects(effective_nutrition));
}
static void _say_chunk_flavour(bool likes_chunks)
@@ -1725,8 +1730,7 @@ static void _say_chunk_flavour(bool likes_chunks)
static void _eat_chunk(corpse_effect_type chunk_effect, bool cannibal,
int mon_intel)
{
- bool likes_chunks = (you.omnivorous()
- || player_mutation_level(MUT_CARNIVOROUS));
+ bool likes_chunks = player_likes_chunks();
int nutrition = _chunk_nutrition(likes_chunks);
int hp_amt = 0;
bool suppress_msg = false; // do we display the chunk nutrition message?
@@ -2400,12 +2404,14 @@ bool is_inedible(const item_def &item)
{
return (true);
}
+
if (item.base_type == OBJ_CORPSES
&& (item.sub_type == CORPSE_SKELETON
|| you.species == SP_VAMPIRE && !mons_has_blood(item.plus)))
{
return (true);
}
+
return (false);
}
// As we want to avoid autocolouring the entire food selection, this should
@@ -2471,8 +2477,8 @@ bool is_forbidden_food(const item_def &food)
return (false);
}
-bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg, bool reqid,
- bool check_hunger)
+bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
+ bool reqid, bool check_hunger)
{
bool survey_says = false;
@@ -2508,16 +2514,15 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg, bool reqid,
return (false);
}
- bool ur_carnivorous = (player_mutation_level(MUT_CARNIVOROUS) == 3);
+ bool ur_carnivorous = player_mutation_level(MUT_CARNIVOROUS) == 3;
- bool ur_herbivorous = (player_mutation_level(MUT_HERBIVOROUS) == 3);
+ bool ur_herbivorous = player_mutation_level(MUT_HERBIVOROUS) == 3;
// ur_chunkslover not defined in terms of ur_carnivorous because
// a player could be one and not the other IMHO - 13mar2000 {dlb}
- bool ur_chunkslover = (
- (check_hunger ? you.hunger_state < HS_SATIATED : true)
- || you.omnivorous()
- || player_mutation_level(MUT_CARNIVOROUS));
+ bool ur_chunkslover = ((check_hunger ? you.hunger_state < HS_SATIATED
+ : true)
+ || player_likes_chunks());
switch (what_isit)
{
@@ -2530,7 +2535,7 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg, bool reqid,
return (false);
}
- int vorous = _player_likes_food_type(kindof_thing);
+ const int vorous = _player_likes_food_type(kindof_thing);
if (vorous > 0) // Herbivorous food.
{
if (ur_carnivorous)
@@ -2566,13 +2571,14 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg, bool reqid,
{
// For artefact amulets, this will tell you its name
// and subtype. Other properties may still be hidden.
- set_ident_flags( you.inv[ amulet], ISFLAG_KNOW_TYPE);
- set_ident_type( OBJ_JEWELLERY, AMU_THE_GOURMAND,
- ID_KNOWN_TYPE );
+ set_ident_flags(you.inv[amulet], ISFLAG_KNOW_TYPE);
+ set_ident_type(OBJ_JEWELLERY, AMU_THE_GOURMAND,
+ ID_KNOWN_TYPE);
mpr(you.inv[amulet].name(DESC_INVENTORY, false).c_str());
}
return (true);
}
+
if (!suppress_msg)
mpr("You aren't quite hungry enough to eat that!");
return (false);
diff --git a/crawl-ref/source/food.h b/crawl-ref/source/food.h
index f2da9ef993..26f0ea3bd6 100644
--- a/crawl-ref/source/food.h
+++ b/crawl-ref/source/food.h
@@ -102,6 +102,7 @@ void eat_inventory_item(int which_inventory_slot);
bool prompt_eat_inventory_item(int slot = -1);
void chunk_nutrition_message(int nutrition);
+int apply_herbivore_nutrition_effects(int nutrition);
void vampire_nutrition_per_turn(const item_def &corpse, int feeding = 0);
diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc
index f3625fae6b..b6db27b48a 100644
--- a/crawl-ref/source/it_use2.cc
+++ b/crawl-ref/source/it_use2.cc
@@ -80,39 +80,43 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known)
}
break;
- case POT_BLOOD:
- case POT_BLOOD_COAGULATED:
+ case POT_BLOOD:
+ case POT_BLOOD_COAGULATED:
if (you.species == SP_VAMPIRE)
{
// No healing anymore! (jpeg)
-
int value = 800;
if (pot_eff == POT_BLOOD)
{
mpr("Yummy - fresh blood!");
value += 200;
}
- else // coagulated
+ else // Coagulated.
mpr("This tastes delicious!");
lessen_hunger(value, true);
}
else
{
- if (you.omnivorous() || player_mutation_level(MUT_CARNIVOROUS))
+ const bool ur_herbivorous =
+ player_mutation_level(MUT_HERBIVOROUS) == 3;
+
+ int nutrition = apply_herbivore_nutrition_effects(200);
+
+ if (!ur_herbivorous && player_likes_chunks())
{
// Likes it.
mpr("This tastes like blood.");
- lessen_hunger(200, true);
+ lessen_hunger(nutrition, true);
}
else
{
mpr("Blech - this tastes like blood!");
- if (!player_mutation_level(MUT_HERBIVOROUS) && one_chance_in(3))
- lessen_hunger(100, true);
+ if (!ur_herbivorous && one_chance_in(3))
+ lessen_hunger(nutrition, true);
else
{
- disease_player( 50 + random2(100) );
+ disease_player(50 + random2(100));
xom_is_stimulated(32);
}
}
@@ -126,7 +130,7 @@ bool potion_effect(potion_type pot_eff, int pow, bool drank_it, bool was_known)
case POT_MIGHT:
{
- const bool were_mighty = (you.duration[DUR_MIGHT] > 0);
+ const bool were_mighty = you.duration[DUR_MIGHT] > 0;
mprf(MSGCH_DURATION, "You feel %s all of a sudden.",
were_mighty ? "mightier" : "very mighty");
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 7da768afee..57f1809db3 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -412,9 +412,9 @@ bool player_likes_water(bool permanently)
return (player_can_swim() || (!permanently && beogh_water_walk()));
}
-bool player_is_swimming(void)
+bool player_is_swimming()
{
- return you.swimming();
+ return (you.swimming());
}
bool player_under_penance(void)
@@ -1289,6 +1289,11 @@ bool player_can_smell()
return (you.species != SP_MUMMY);
}
+bool player_likes_chunks()
+{
+ return (you.omnivorous() || player_mutation_level(MUT_CARNIVOROUS) > 0);
+}
+
// If temp is set to false, temporary sources or resistance won't be counted.
int player_res_fire(bool calc_unid, bool temp, bool items)
{
@@ -4415,7 +4420,7 @@ bool extrinsic_amulet_effect(jewellery_type amulet)
bool wearing_amulet(jewellery_type amulet, bool calc_unid)
{
- if ( extrinsic_amulet_effect(amulet) )
+ if (extrinsic_amulet_effect(amulet))
return (true);
if (you.equip[EQ_AMULET] == -1)
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index c8eca92819..2ec0821269 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -174,6 +174,7 @@ bool player_item_conserve(bool calc_unid = true);
int player_mental_clarity(bool calc_unid = true, bool items = true);
bool player_can_smell();
+bool player_likes_chunks();
bool player_can_swim();
bool player_likes_water(bool permanently = false);