summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-16 18:58:05 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-16 18:58:05 +0000
commitb9231c6613788ace1d7adfde1a0e028b21fae993 (patch)
tree974c93e302c3137100526d0a4a9e9586687c2efc
parentb8ba267261e0586c01fad1c5f280d1fd16cd44ca (diff)
downloadcrawl-ref-b9231c6613788ace1d7adfde1a0e028b21fae993.tar.gz
crawl-ref-b9231c6613788ace1d7adfde1a0e028b21fae993.zip
'DD' is now an alias for 'Dy'.
Clean up some corpse handling, add food_is_rotten() function instead of manually checking special < 100 everywhere. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3283 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/clua.cc2
-rw-r--r--crawl-ref/source/describe.cc2
-rw-r--r--crawl-ref/source/effects.cc3
-rw-r--r--crawl-ref/source/food.cc140
-rw-r--r--crawl-ref/source/item_use.cc2
-rw-r--r--crawl-ref/source/itemname.cc26
-rw-r--r--crawl-ref/source/itemprop.cc8
-rw-r--r--crawl-ref/source/itemprop.h1
-rw-r--r--crawl-ref/source/religion.cc8
-rw-r--r--crawl-ref/source/spells2.cc2
-rw-r--r--crawl-ref/source/spells4.cc2
-rw-r--r--crawl-ref/source/tile1.cc2
-rw-r--r--crawl-ref/source/tutorial.cc8
13 files changed, 114 insertions, 92 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc
index e8bd6449dd..be10393602 100644
--- a/crawl-ref/source/clua.cc
+++ b/crawl-ref/source/clua.cc
@@ -1609,7 +1609,7 @@ static int food_rotting(lua_State *ls)
bool rotting = false;
if (item && item->base_type == OBJ_FOOD && item->sub_type == FOOD_CHUNK)
{
- rotting = item->special < 100;
+ rotting = food_is_rotten(*item);
}
lua_pushboolean(ls, rotting);
return (1);
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index e6c6fb60e7..dd0b4928b4 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -1553,7 +1553,7 @@ std::string get_item_description( const item_def &item, bool verbose,
if (you.mutation[MUT_SAPROVOROUS] < 3)
description << "It looks rather unpleasant. ";
- if (item.special < 100)
+ if (food_is_rotten(item))
{
if (you.mutation[MUT_SAPROVOROUS] == 3)
description << "It looks nice and ripe. ";
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 9e761c6841..eb09c0aeeb 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -2081,7 +2081,8 @@ static void rot_inventory_food(long time_delta)
you.inv[i].special -= (time_delta / 20);
- if (you.inv[i].special < 100 && (you.inv[i].special + (time_delta / 20)>=100))
+ if (you.inv[i].special < 100 &&
+ (you.inv[i].special + (time_delta / 20) >=100 ))
{
rotten_items.push_back(index_to_letter( i ));
}
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index 8507ea7d1a..2874c207c1 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -28,6 +28,7 @@
#include "externs.h"
+#include "cio.h"
#include "clua.h"
#include "debug.h"
#include "delay.h"
@@ -257,7 +258,7 @@ bool butchery()
}
bool canceled_butcher = false;
-
+
// Now pick what you want to butcher. This is only a problem
// if there are several corpses on the square.
if ( num_corpses == 0 )
@@ -275,25 +276,46 @@ bool butchery()
continue;
// offer the possibility of butchering
- std::string prompt = "Butcher " + mitm[o].name(DESC_NOCAP_A) + '?';
- const int answer = yesnoquit( prompt.c_str(), true, 'n', false );
- if ( answer == 1 )
+ mprf("Butcher %s? [y/n/q/D]", mitm[o].name(DESC_NOCAP_A).c_str());
+ // possible results:
+ // 0 - cancel all butchery (quit)
+ // 1 - say no to this butchery, continue prompting
+ // 2 - OK this butchery
+ // Yes, this is a hack because it's too annoying to adapt
+ // yesnoquit() to this purpose.
+ int result = 100;
+ while (result == 100)
{
- corpse_id = o;
- break;
+ const int keyin = getchm(KC_CONFIRM);
+ if (keyin == CK_ESCAPE || keyin == 'q' || keyin == 'Q')
+ result = 0;
+ if (keyin == ' ' || keyin == '\r' || keyin == '\n' ||
+ keyin == 'n' || keyin == 'N')
+ result = 1;
+ if (keyin == 'y' || keyin == 'Y' || keyin == 'd' ||
+ keyin == 'D')
+ result = 2;
}
- else if ( answer == -1 )
+
+ if ( result == 0 )
{
canceled_butcher = true;
corpse_id = -1;
break;
}
+ else if ( result == 2 )
+ {
+ corpse_id = o;
+ break;
+ }
}
}
-
+
// Do the actual butchery, if we found a good corpse.
if ( corpse_id != -1 )
{
+ const bool can_sac = you.duration[DUR_PRAYER]
+ && god_likes_butchery(you.religion);
bool removed_gloves = false;
bool wpn_switch = false;
@@ -311,23 +333,24 @@ bool butchery()
takeoff_armour(old_gloves);
barehand_butcher = true;
}
- const int wpn = you.equip[EQ_WEAPON];
if ( wpn_switch )
{
new_cursed =
- (wpn != -1) &&
- (you.inv[wpn].base_type == OBJ_WEAPONS) &&
- item_cursed( you.inv[wpn]);
+ (you.weapon() != NULL) &&
+ (you.weapon()->base_type == OBJ_WEAPONS) &&
+ item_cursed( *you.weapon() );
}
- // note that if wpn == -1 the user selected '-' when
+ // note that if barehanded then the user selected '-' when
// switching weapons
- if (!barehand_butcher &&
- (!wpn_switch || wpn == -1 || !can_cut_meat(you.inv[wpn])))
+ if (!barehand_butcher && (!wpn_switch ||
+ you.weapon() == NULL ||
+ !can_cut_meat(*you.weapon())))
{
// still can't butcher. Early out
- if ( wpn == -1 ) {
+ if ( you.weapon() == NULL )
+ {
if (you.equip[EQ_GLOVES] == -1)
mpr("What, with your bare hands?");
else
@@ -345,24 +368,15 @@ bool butchery()
// switched to a good butchering knife
can_butcher = true;
}
-
+
if ( can_butcher )
{
- bool rotten = (mitm[corpse_id].special < 100);
- if (you.duration[DUR_PRAYER] && !rotten &&
- god_likes_butchery(you.religion))
- {
+ const bool rotten = food_is_rotten(mitm[corpse_id]);
+ if (can_sac && !rotten)
offer_corpse(corpse_id);
- // ritual sacrifice can also bloodify the ground
- const int mons_class = mitm[corpse_id].plus;
- const int max_chunks = mons_weight( mons_class ) / 150;
- bleed_onto_floor(you.x_pos, you.y_pos, mons_class, max_chunks, true);
- destroy_item(corpse_id);
- }
else
{
- if (you.duration[DUR_PRAYER] && rotten
- && god_likes_butchery(you.religion) )
+ if (can_sac && rotten)
{
simple_god_message(coinflip() ?
" refuses to accept that mouldy "
@@ -654,15 +668,16 @@ static bool prompt_eat_chunk(const item_def &item, bool rotten)
return (true);
}
+// should really be merged into function below -- FIXME
void eat_from_inventory(int which_inventory_slot)
{
- if (you.inv[which_inventory_slot].base_type == OBJ_CORPSES
- && you.inv[which_inventory_slot].sub_type == CORPSE_BODY)
+ item_def& food(you.inv[which_inventory_slot]);
+ if (food.base_type == OBJ_CORPSES && food.sub_type == CORPSE_BODY)
{
- const int mons_type = you.inv[ which_inventory_slot ].plus;
+ const int mons_type = food.plus;
const int chunk_type = mons_corpse_effect( mons_type );
- const bool rotten = (you.inv[which_inventory_slot].special < 100);
- const int mass = item_mass( you.inv[which_inventory_slot] );
+ const bool rotten = food_is_rotten(food);
+ const int mass = item_mass( food );
if (!vampire_consume_corpse(mons_type, mass, chunk_type, rotten))
return;
@@ -673,46 +688,41 @@ void eat_from_inventory(int which_inventory_slot)
}
else
{
- you.inv[which_inventory_slot].sub_type = CORPSE_SKELETON;
- you.inv[which_inventory_slot].special = 90;
- you.inv[which_inventory_slot].colour = LIGHTGREY;
+ food.sub_type = CORPSE_SKELETON;
+ food.special = 90;
+ food.colour = LIGHTGREY;
}
// dec_inv_item_quantity( which_inventory_slot, 1 );
return;
}
- else if (you.inv[which_inventory_slot].sub_type == FOOD_CHUNK)
+ else if (food.sub_type == FOOD_CHUNK)
{
- // this is a bit easier to read... most compilers should
- // handle this the same -- bwr
- const int mons_type = you.inv[ which_inventory_slot ].plus;
+ const int mons_type = food.plus;
const bool cannibal = is_player_same_species(mons_type);
const int intel = mons_intel(mons_type) - I_ANIMAL;
const int chunk_type = mons_corpse_effect( mons_type );
- const bool rotten = (you.inv[which_inventory_slot].special < 100);
+ const bool rotten = food_is_rotten(food);
- if (!prompt_eat_chunk(you.inv[which_inventory_slot], rotten))
+ if (!prompt_eat_chunk(food, rotten))
return;
- eat_chunk( determine_chunk_effect( chunk_type, rotten ), cannibal, intel );
+ eat_chunk(determine_chunk_effect(chunk_type, rotten), cannibal, intel);
}
else
- {
- eating( you.inv[which_inventory_slot].base_type,
- you.inv[which_inventory_slot].sub_type );
- }
+ eating( food.base_type, food.sub_type );
dec_inv_item_quantity( which_inventory_slot, 1 );
} // end eat_from_inventory()
void eat_floor_item(int item_link)
{
- if (mitm[item_link].base_type == OBJ_CORPSES
- && mitm[item_link].sub_type == CORPSE_BODY)
+ item_def& food(mitm[item_link]);
+ if (food.base_type == OBJ_CORPSES && food.sub_type == CORPSE_BODY)
{
- const int mons_type = mitm[item_link].plus;
+ const int mons_type = food.plus;
const int chunk_type = mons_corpse_effect( mons_type );
- const bool rotten = (mitm[item_link].special < 100);
- const int mass = item_mass( mitm[item_link] );
+ const bool rotten = food_is_rotten(food);
+ const int mass = item_mass( food );
if (!vampire_consume_corpse(mons_type, mass, chunk_type, rotten))
return;
@@ -723,29 +733,27 @@ void eat_floor_item(int item_link)
}
else
{
- mitm[item_link].sub_type = CORPSE_SKELETON;
- mitm[item_link].special = 90;
- mitm[item_link].colour = LIGHTGREY;
+ food.sub_type = CORPSE_SKELETON;
+ food.special = 90;
+ food.colour = LIGHTGREY;
}
// dec_mitm_item_quantity( item_link, 1 );
you.turn_is_over = 1;
return;
}
- else if (mitm[item_link].sub_type == FOOD_CHUNK)
+ else if (food.sub_type == FOOD_CHUNK)
{
- const int chunk_type = mons_corpse_effect( mitm[item_link].plus );
- const int intel = mons_intel( mitm[item_link].plus ) - I_ANIMAL;
- const bool cannibal = is_player_same_species( mitm[item_link].plus );
- const bool rotten = (mitm[item_link].special < 100);
- if (!prompt_eat_chunk(mitm[item_link], rotten))
+ const int chunk_type = mons_corpse_effect( food.plus );
+ const int intel = mons_intel( food.plus ) - I_ANIMAL;
+ const bool cannibal = is_player_same_species( food.plus );
+ const bool rotten = food_is_rotten(food);
+ if (!prompt_eat_chunk(food, rotten))
return;
- eat_chunk( determine_chunk_effect( chunk_type, rotten ), cannibal, intel );
+ eat_chunk(determine_chunk_effect(chunk_type, rotten), cannibal, intel);
}
else
- {
- eating( mitm[item_link].base_type, mitm[item_link].sub_type );
- }
+ eating( food.base_type, food.sub_type );
you.turn_is_over = true;
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index b9742dec0a..3242e19a1f 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -4513,7 +4513,7 @@ void tile_use_item(int idx, InvAction act)
case OBJ_CORPSES:
if (you.species != SP_VAMPIRE
|| you.inv[idx].sub_type == CORPSE_SKELETON
- || you.inv[idx].special < 100)
+ || food_is_rotten(you.inv[idx]))
{
break;
}
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index afb978dfa1..df0badb632 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -1327,7 +1327,7 @@ std::string item_def::name_aux( description_level_type desc,
case FOOD_CHUNK:
if (!basename && !dbname)
{
- if (this->special < 100)
+ if (food_is_rotten(*this))
buff << "rotting ";
buff << "chunk of "
@@ -1547,20 +1547,18 @@ std::string item_def::name_aux( description_level_type desc,
break;
case OBJ_CORPSES:
- if (item_typ == CORPSE_BODY && this->special < 100 && !dbname)
- {
+ if (food_is_rotten(*this) && !dbname)
buff << "rotting ";
- }
- {
- if (!dbname)
- buff << mons_type_name(it_plus, DESC_PLAIN) << ' ';
- if (item_typ == CORPSE_BODY)
- buff << "corpse";
- else if (item_typ == CORPSE_SKELETON)
- buff << "skeleton";
- else
- buff << "corpse bug";
- }
+
+ if (!dbname)
+ buff << mons_type_name(it_plus, DESC_PLAIN) << ' ';
+
+ if (item_typ == CORPSE_BODY)
+ buff << "corpse";
+ else if (item_typ == CORPSE_SKELETON)
+ buff << "skeleton";
+ else
+ buff << "corpse bug";
break;
default:
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index 2d35a8e5f5..2dc8e9bcce 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -1975,6 +1975,14 @@ bool can_cut_meat( const item_def &item )
return (does_damage_type( item, DAM_SLICE ));
}
+bool food_is_rotten( const item_def &item )
+{
+ return (item.special < 100) && ((item.base_type == OBJ_CORPSES &&
+ item.sub_type == CORPSE_BODY) ||
+ (item.base_type == OBJ_FOOD &&
+ item.sub_type == FOOD_CHUNK));
+}
+
// returns true if item counts as a tool for tool size comparisons and msgs
bool is_tool( const item_def &item )
{
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index 1c680e69c5..499880011c 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -697,6 +697,7 @@ bool food_is_veg( const item_def &item );
int food_value( const item_def &item );
int food_turns( const item_def &item );
bool can_cut_meat( const item_def &item );
+bool food_is_rotten( const item_def &item );
// generic item property functions:
bool is_tool( const item_def &item );
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 59053179da..ae8271380f 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -3675,7 +3675,13 @@ void offer_corpse(int corpse)
sacrifice_message(you.religion, mitm[corpse], true).c_str());
did_god_conduct(DID_DEDICATED_BUTCHERY, 10);
-} // end offer_corpse()
+
+ // ritual sacrifice can also bloodify the ground
+ const int mons_class = mitm[corpse].plus;
+ const int max_chunks = mons_weight( mons_class ) / 150;
+ bleed_onto_floor(you.x_pos, you.y_pos, mons_class, max_chunks, true);
+ destroy_item(corpse);
+}
// Returns true if the player can use the good gods' passive piety gain.
static bool need_free_piety()
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 78d648f4ad..613f7e6d27 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -490,7 +490,7 @@ void cast_twisted(int power, beh_type corps_beh, int corps_hit)
total_mass += mons_weight( mitm[objl].plus );
num_corpses++;
- if (mitm[objl].special < 100)
+ if (food_is_rotten(mitm[objl]))
rotted++;
destroy_item( objl );
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index f98bfa4981..e31a81a837 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -1836,7 +1836,7 @@ void cast_fulsome_distillation( int powc )
return;
}
- const bool rotten = (mitm[corpse].special < 100);
+ const bool rotten = food_is_rotten(mitm[corpse]);
const bool big_monster = (mons_type_hit_dice( mitm[corpse].plus ) >= 5);
const bool power_up = (rotten && big_monster);
diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc
index 52337dbee7..a40883ef0e 100644
--- a/crawl-ref/source/tile1.cc
+++ b/crawl-ref/source/tile1.cc
@@ -1258,7 +1258,7 @@ int tileidx_food(const item_def &item)
case FOOD_CHUNK:
ch=TILE_FOOD_CHUNK;
- if (item.special < 100) ch = TILE_FOOD_CHUNK_ROTTEN;
+ if (food_is_rotten(item)) ch = TILE_FOOD_CHUNK_ROTTEN;
break;
}
diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc
index aee22728ff..df6456ff76 100644
--- a/crawl-ref/source/tutorial.cc
+++ b/crawl-ref/source/tutorial.cc
@@ -1762,10 +1762,10 @@ void tutorial_describe_item(const item_def &item)
{
ostr << "Note that most species refuse to eat raw meat unless "
"really hungry. ";
- if (item.special < 100)
+ if (food_is_rotten(item))
{
- ostr << "Even fewer can safely digest rotten meat, and you're "
- "probably not part of this group.";
+ ostr << "Even fewer can safely digest rotten meat, and "
+ "you're probably not part of that group.";
}
}
Options.tutorial_events[TUT_SEEN_FOOD] = 0;
@@ -1890,7 +1890,7 @@ void tutorial_describe_item(const item_def &item)
}
ostr << ". ";
- if (item.special < 100)
+ if (food_is_rotten(item))
ostr << "Rotten corpses won't be of any use to you, though, so "
"you might just as well <w>d<magenta>rop this.";
Options.tutorial_events[TUT_SEEN_CARRION] = 0;