summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/misc.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-10 17:38:27 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-10 17:38:27 +0000
commit1beb0abbfd7972efabd7817a0359b2c57cd91524 (patch)
tree91e514b80aaba65b2317817df1725ada648f1d21 /crawl-ref/source/misc.cc
parente5d9773c543dea310c3152f249a8c67e3d8195e3 (diff)
downloadcrawl-ref-1beb0abbfd7972efabd7817a0359b2c57cd91524.tar.gz
crawl-ref-1beb0abbfd7972efabd7817a0359b2c57cd91524.zip
Some more Stealth changes.
(1) Use diminishing returns for passive training depending on skill level. Below skill level 2, chances are unchanged; at level 2 chances are 2/3 of that, and at level 3 at 1/3. From level 4 onwards, Stealth cannot be trained by waiting anymore. (2) Active stealth training only has a 1% chance (instead of 5%) if you're sneaking around monsters while invisible (and the monster cannot see you). Add yet another function for blood potions - I sure hope this works when I eventually get around to actually use them. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4178 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/misc.cc')
-rw-r--r--crawl-ref/source/misc.cc36
1 files changed, 30 insertions, 6 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f5b51aec32..bd124f5d9d 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -202,8 +202,8 @@ void maybe_coagulate_blood_floor(item_def &blood)
ASSERT(is_valid_item(blood));
ASSERT(blood.base_type == OBJ_POTIONS);
- ASSERT (blood.sub_type == POT_BLOOD
- || blood.sub_type == POT_BLOOD_COAGULATED);
+ ASSERT(blood.sub_type == POT_BLOOD
+ || blood.sub_type == POT_BLOOD_COAGULATED);
CrawlHashTable &props = blood.props;
ASSERT(props.exists("timer"));
@@ -221,13 +221,13 @@ void maybe_coagulate_blood_floor(item_def &blood)
int coag_count = 0;
std::vector<long> age_timer;
long current;
- int size = timer.size();
+ const int size = timer.size();
for (int i = 0; i < size; i++)
{
current = timer.pop_back();
if (rot_limit >= current)
rot_count++;
- else if (coag_limit >= current)
+ else if (blood.sub_type == POT_BLOOD && coag_limit >= current)
{
coag_count++;
age_timer.push_back(current);
@@ -243,7 +243,7 @@ void maybe_coagulate_blood_floor(item_def &blood)
if (!rot_count && !coag_count)
return; // nothing to be done
- if (!coag_count)
+ if (!coag_count) // some potions rotted away
{
dec_mitm_item_quantity(blood.link, rot_count);
// timer is already up to date
@@ -260,6 +260,7 @@ void maybe_coagulate_blood_floor(item_def &blood)
if (mitm[o].base_type == OBJ_POTIONS
&& mitm[o].sub_type == POT_BLOOD_COAGULATED)
{
+ // merge with existing stack
CrawlHashTable &props2 = mitm[o].props;
ASSERT(props2.exists("timer"));
CrawlVector &timer2 = props2["timer"];
@@ -274,13 +275,35 @@ void maybe_coagulate_blood_floor(item_def &blood)
timer2.push_back(val);
}
_long_sort(timer2);
+ inc_mitm_item_quantity(o, coag_count);
+ ASSERT(timer2.size() == mitm[o].quantity);
dec_mitm_item_quantity(blood.link, rot_count + coag_count);
return;
}
o = mitm[o].link;
}
+ // If we got here nothing was found!
+
+ // entire stack is gone, rotted or coagulated.
+ // -> change potions to coagulated type
+ if (rot_count + coag_count == blood.quantity)
+ {
+ ASSERT(timer.empty());
+ // update subtype
+ blood.sub_type = POT_BLOOD_COAGULATED;
+ item_colour(blood);
+ // re-fill vector
+ long val;
+ while (!age_timer.empty())
+ {
+ val = age_timer[age_timer.size() - 1];
+ age_timer.pop_back();
+ timer.push_back(val);
+ }
+ dec_mitm_item_quantity(blood.link, rot_count);
+ ASSERT(timer.size() == blood.quantity);
+ }
- // if we got here nothing was found
// create a new stack of potions
o = get_item_slot( 100 + random2(200) );
if (o == NON_ITEM)
@@ -314,6 +337,7 @@ void maybe_coagulate_blood_floor(item_def &blood)
move_item_to_grid( &o, blood.x, blood.y );
dec_mitm_item_quantity(blood.link, rot_count + coag_count);
+ ASSERT(timer.size() == blood.quantity);
}
// used for (q)uaff, (f)ire, and Evaporate