summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/items.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-28 16:35:46 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-12-28 16:35:46 +0000
commit2bc554ff35a7e20c28f1804bc7aea2c172e6263e (patch)
tree1bebb741e44ff30699d8919a9c10ba7865d066f7 /crawl-ref/source/items.cc
parent7ea028dc76bf558c02c4d7775cd2af9fac52d796 (diff)
downloadcrawl-ref-2bc554ff35a7e20c28f1804bc7aea2c172e6263e.tar.gz
crawl-ref-2bc554ff35a7e20c28f1804bc7aea2c172e6263e.zip
[1859486] Fixed skeletons weighing five times more than intended, burden state not changing when corpse rots to skeleton.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3132 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/items.cc')
-rw-r--r--crawl-ref/source/items.cc252
1 files changed, 131 insertions, 121 deletions
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 4414fb2ccf..339ccb1c39 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -500,18 +500,11 @@ void unlink_item( int dest )
#endif
} // end unlink_item()
-void destroy_item( int dest, bool never_created )
+void destroy_item( item_def &item, bool never_created )
{
- // Don't destroy non-items, but this function may be called upon
- // to remove items reduced to zero quantity, so we allow "invalid"
- // objects in.
- if (dest == NON_ITEM || !is_valid_item( mitm[dest] ))
+ if (!is_valid_item( item ))
return;
- unlink_item( dest );
-
- item_def& item(mitm[dest]);
-
if (never_created)
{
if (is_fixed_artefact(item))
@@ -531,6 +524,18 @@ void destroy_item( int dest, bool never_created )
item.clear();
}
+void destroy_item( int dest, bool never_created )
+{
+ // Don't destroy non-items, but this function may be called upon
+ // to remove items reduced to zero quantity, so we allow "invalid"
+ // objects in.
+ if (dest == NON_ITEM || !is_valid_item( mitm[dest] ))
+ return;
+
+ unlink_item( dest );
+ destroy_item( mitm[dest], never_created );
+}
+
static void handle_gone_item(const item_def &item)
{
if (you.level_type == LEVEL_ABYSS
@@ -2442,6 +2447,122 @@ static void hell_effects()
}
}
+static void rot_inventory_food(long time_delta)
+{
+ // Update all of the corpses and food chunks in the player's
+ // inventory {should be moved elsewhere - dlb}
+
+ bool burden_changed_by_rot = false;
+ bool new_rotting_item = false;
+ for (int i = 0; i < ENDOFPACK; i++)
+ {
+ if (you.inv[i].quantity < 1)
+ continue;
+
+ if (you.inv[i].base_type != OBJ_CORPSES && you.inv[i].base_type != OBJ_FOOD)
+ continue;
+
+ if (you.inv[i].base_type == OBJ_CORPSES
+ && you.inv[i].sub_type > CORPSE_SKELETON)
+ {
+ continue;
+ }
+
+ if (you.inv[i].base_type == OBJ_FOOD && you.inv[i].sub_type != FOOD_CHUNK)
+ continue;
+
+ if ((time_delta / 20) >= you.inv[i].special)
+ {
+ if (you.inv[i].base_type == OBJ_FOOD)
+ {
+ if (you.equip[EQ_WEAPON] == i)
+ unwield_item();
+
+ destroy_item(you.inv[i]);
+ burden_changed_by_rot = true;
+ continue;
+ }
+
+ if (you.inv[i].sub_type == CORPSE_SKELETON)
+ continue; // carried skeletons are not destroyed
+
+ if (!mons_skeleton( you.inv[i].plus ))
+ {
+ if (you.equip[EQ_WEAPON] == i)
+ unwield_item();
+
+ destroy_item(you.inv[i]);
+ burden_changed_by_rot = true;
+ continue;
+ }
+
+ you.inv[i].sub_type = CORPSE_SKELETON;
+ you.inv[i].special = 0;
+ you.inv[i].colour = LIGHTGREY;
+ you.wield_change = true;
+ burden_changed_by_rot = true;
+ continue;
+ }
+
+ you.inv[i].special -= (time_delta / 20);
+
+ if (you.inv[i].special < 100 && (you.inv[i].special + (time_delta / 20)>=100))
+ {
+ new_rotting_item = true;
+ }
+ }
+
+ //mv: messages when chunks/corpses become rotten
+ if (new_rotting_item)
+ {
+ // XXX: should probably still notice?
+ // Races that can't smell don't care, and trolls are stupid and
+ // don't care.
+ if (player_can_smell() && you.species != SP_TROLL)
+ {
+ int temp_rand = 0; // Grr.
+ switch (you.mutation[MUT_SAPROVOROUS])
+ {
+ // level 1 and level 2 saprovores aren't so touchy
+ case 1:
+ case 2:
+ temp_rand = random2(8);
+ mpr( ((temp_rand < 5) ? "You smell something rotten." :
+ (temp_rand == 5) ? "You smell rotting flesh." :
+ (temp_rand == 6) ? "You smell decay."
+ : "There is something rotten in your inventory."),
+ MSGCH_ROTTEN_MEAT );
+ break;
+
+ // level 3 saprovores like it
+ case 3:
+ temp_rand = random2(8);
+ mpr( ((temp_rand < 5) ? "You smell something rotten." :
+ (temp_rand == 5) ? "The smell of rotting flesh makes you hungry." :
+ (temp_rand == 6) ? "You smell decay. Yum-yum."
+ : "Wow! There is something tasty in your inventory."),
+ MSGCH_ROTTEN_MEAT );
+ break;
+
+ default:
+ temp_rand = random2(8);
+ mpr( ((temp_rand < 5) ? "You smell something rotten." :
+ (temp_rand == 5) ? "The smell of rotting flesh makes you sick." :
+ (temp_rand == 6) ? "You smell decay. Yuck!"
+ : "Ugh! There is something really disgusting in your inventory."),
+ MSGCH_ROTTEN_MEAT );
+ break;
+ }
+ }
+ learned_something_new(TUT_ROTTEN_FOOD);
+ }
+ if (burden_changed_by_rot)
+ {
+ mpr("Your equipment suddenly weighs less.", MSGCH_ROTTEN_MEAT);
+ burden_change();
+ }
+}
+
//---------------------------------------------------------------
//
// handle_time
@@ -2452,11 +2573,6 @@ static void hell_effects()
//---------------------------------------------------------------
void handle_time( long time_delta )
{
- int temp_rand; // probability determination {dlb}
-
- unsigned char i; // loop variable {dlb}
- bool new_rotting_item = false; //mv: becomes true when some new item becomes rotting
-
// BEGIN - Nasty things happen to people who spend too long in Hell:
if (player_in_hell() && coinflip())
hell_effects();
@@ -2682,113 +2798,7 @@ void handle_time( long time_delta )
// Update all of the corpses and food chunks on the floor
update_corpses(time_delta);
- // Update all of the corpses and food chunks in the player's
- // inventory {should be moved elsewhere - dlb}
-
-
- for (i = 0; i < ENDOFPACK; i++)
- {
- if (you.inv[i].quantity < 1)
- continue;
-
- if (you.inv[i].base_type != OBJ_CORPSES && you.inv[i].base_type != OBJ_FOOD)
- continue;
-
- if (you.inv[i].base_type == OBJ_CORPSES
- && you.inv[i].sub_type > CORPSE_SKELETON)
- {
- continue;
- }
-
- if (you.inv[i].base_type == OBJ_FOOD && you.inv[i].sub_type != FOOD_CHUNK)
- continue;
-
- if ((time_delta / 20) >= you.inv[i].special)
- {
- if (you.inv[i].base_type == OBJ_FOOD)
- {
- if (you.equip[EQ_WEAPON] == i)
- unwield_item();
-
- mpr("Your equipment suddenly weighs less.", MSGCH_ROTTEN_MEAT);
- // FIXME should replace with a destroy_item call
- you.inv[i].quantity = 0;
- burden_change();
- continue;
- }
-
- if (you.inv[i].sub_type == CORPSE_SKELETON)
- continue; // carried skeletons are not destroyed
-
- if (!mons_skeleton( you.inv[i].plus ))
- {
- if (you.equip[EQ_WEAPON] == i)
- unwield_item();
-
- // FIXME should replace with a destroy_item call
- you.inv[i].quantity = 0;
- burden_change();
- continue;
- }
-
- you.inv[i].sub_type = 1;
- you.inv[i].special = 0;
- you.inv[i].colour = LIGHTGREY;
- you.wield_change = true;
- continue;
- }
-
- you.inv[i].special -= (time_delta / 20);
-
- if (you.inv[i].special < 100 && (you.inv[i].special + (time_delta / 20)>=100))
- {
- new_rotting_item = true;
- }
- }
-
- //mv: messages when chunks/corpses become rotten
- if (new_rotting_item)
- {
- // XXX: should probably still notice?
- // Races that can't smell don't care, and trolls are stupid and
- // don't care.
- if (player_can_smell() && you.species != SP_TROLL)
- {
- switch (you.mutation[MUT_SAPROVOROUS])
- {
- // level 1 and level 2 saprovores aren't so touchy
- case 1:
- case 2:
- temp_rand = random2(8);
- mpr( ((temp_rand < 5) ? "You smell something rotten." :
- (temp_rand == 5) ? "You smell rotting flesh." :
- (temp_rand == 6) ? "You smell decay."
- : "There is something rotten in your inventory."),
- MSGCH_ROTTEN_MEAT );
- break;
-
- // level 3 saprovores like it
- case 3:
- temp_rand = random2(8);
- mpr( ((temp_rand < 5) ? "You smell something rotten." :
- (temp_rand == 5) ? "The smell of rotting flesh makes you hungry." :
- (temp_rand == 6) ? "You smell decay. Yum-yum."
- : "Wow! There is something tasty in your inventory."),
- MSGCH_ROTTEN_MEAT );
- break;
-
- default:
- temp_rand = random2(8);
- mpr( ((temp_rand < 5) ? "You smell something rotten." :
- (temp_rand == 5) ? "The smell of rotting flesh makes you sick." :
- (temp_rand == 6) ? "You smell decay. Yuck!"
- : "Ugh! There is something really disgusting in your inventory."),
- MSGCH_ROTTEN_MEAT );
- break;
- }
- }
- learned_something_new(TUT_ROTTEN_FOOD);
- }
+ rot_inventory_food(time_delta);
// exercise armour *xor* stealth skill: {dlb}
if (!player_light_armour(true))