summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/item_use.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-23 20:59:37 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-23 20:59:37 +0000
commitb97996cd4e4b7c117951a4adf7bb9b4b2ec61b98 (patch)
treef232c827dbf7b3d82bfa29562f8d3397b8edea31 /crawl-ref/source/item_use.cc
parent1bfc2ce563b0f4c9f5928d3a942a1d04f2958ca6 (diff)
downloadcrawl-ref-b97996cd4e4b7c117951a4adf7bb9b4b2ec61b98.tar.gz
crawl-ref-b97996cd4e4b7c117951a4adf7bb9b4b2ec61b98.zip
Added potions of resistance, which give fire, electricity and cold resist for
10 + random2(40) turns. Rareness roughly equivalent to levitation. This is FR 1756363. The potion does *not* give MR. Rewrote some vampire potion handling, including some changes: e.g. vampires can now be paralysed by potions of paralysis (I don't see why they shouldn't be.) For now there is no status message for fire/cold resist; will change soon. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1918 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/item_use.cc')
-rw-r--r--crawl-ref/source/item_use.cc108
1 files changed, 43 insertions, 65 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 8e308e77c9..1ce98686d1 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -2963,57 +2963,48 @@ void drink(void)
lessen_hunger(40, true);
} // end drink()
-bool drink_fountain(void)
+bool drink_fountain()
{
- bool gone_dry = false;
- int temp_rand; // for probability determinations {dlb}
- potion_type fountain_effect = POT_WATER; // for fountain effects {dlb}
+ const dungeon_feature_type feat = grd[you.x_pos][you.y_pos];
+
+ if ( feat != DNGN_BLUE_FOUNTAIN && feat != DNGN_SPARKLING_FOUNTAIN )
+ return false;
- switch (grd[you.x_pos][you.y_pos])
+ potion_type fountain_effect = POT_WATER;
+ if ( feat == DNGN_BLUE_FOUNTAIN )
{
- case DNGN_BLUE_FOUNTAIN:
if (!yesno("Drink from the fountain?"))
return false;
-
- mpr("You drink the pure, clear water.");
- break;
-
- case DNGN_SPARKLING_FOUNTAIN:
+ else
+ mpr("You drink the pure, clear water.");
+ }
+ else // sparkling fountain
+ {
if (!yesno("Drink from the sparkling fountain?"))
return false;
-
mpr("You drink the sparkling water.");
- break;
-
- default:
- break;
- }
- if (grd[you.x_pos][you.y_pos] == DNGN_SPARKLING_FOUNTAIN)
- {
- temp_rand = random2(4500);
-
- fountain_effect = ((temp_rand > 2399) ? POT_WATER : // 46.7%
- (temp_rand > 2183) ? POT_DECAY : // 4.8%
- (temp_rand > 2003) ? POT_MUTATION : // 4.0%
- (temp_rand > 1823) ? POT_HEALING : // 4.0%
- (temp_rand > 1643) ? POT_HEAL_WOUNDS :// 4.0%
- (temp_rand > 1463) ? POT_SPEED : // 4.0%
- (temp_rand > 1283) ? POT_MIGHT : // 4.0%
- (temp_rand > 1139) ? POT_DEGENERATION ://3.2%
- (temp_rand > 1019) ? POT_LEVITATION :// 2.7%
- (temp_rand > 899) ? POT_POISON : // 2.7%
- (temp_rand > 779) ? POT_SLOWING : // 2.7%
- (temp_rand > 659) ? POT_PARALYSIS : // 2.7%
- (temp_rand > 539) ? POT_CONFUSION : // 2.7%
- (temp_rand > 419) ? POT_INVISIBILITY :// 2.7%
- (temp_rand > 329) ? POT_MAGIC : // 2.0%
- (temp_rand > 239) ? POT_RESTORE_ABILITIES :// 2.0%
- (temp_rand > 149) ? POT_STRONG_POISON ://2.0%
- (temp_rand > 59) ? POT_BERSERK_RAGE : //2.0%
- (temp_rand > 39) ? POT_GAIN_STRENGTH : //0.4%
- (temp_rand > 19) ? POT_GAIN_DEXTERITY //0.4%
- : POT_GAIN_INTELLIGENCE);//0.4%
+ const potion_type effects[] =
+ { POT_WATER, POT_DECAY,
+ POT_MUTATION, POT_HEALING, POT_HEAL_WOUNDS, POT_SPEED, POT_MIGHT,
+ POT_DEGENERATION,
+ POT_LEVITATION, POT_POISON, POT_SLOWING,
+ POT_PARALYSIS, POT_CONFUSION, POT_INVISIBILITY,
+ POT_MAGIC, POT_RESTORE_ABILITIES, POT_RESISTANCE,
+ POT_STRONG_POISON, POT_BERSERK_RAGE,
+ POT_GAIN_STRENGTH, POT_GAIN_INTELLIGENCE, POT_GAIN_DEXTERITY };
+
+ const int weights[] = { 467, 48,
+ 40, 40, 40, 40, 40,
+ 32,
+ 27, 27, 27,
+ 27, 27, 27,
+ 20, 20, 20,
+ 20, 20,
+ 4, 4, 4 };
+
+ ASSERT( ARRAYSIZE(weights) == ARRAYSIZE(effects) );
+ fountain_effect = effects[weighted_random(weights,ARRAYSIZE(weights))];
}
if (fountain_effect != POT_WATER)
@@ -3021,39 +3012,26 @@ bool drink_fountain(void)
potion_effect(fountain_effect, 100);
- switch (grd[you.x_pos][you.y_pos])
+ bool gone_dry = false;
+ if ( feat == DNGN_BLUE_FOUNTAIN )
{
- case DNGN_BLUE_FOUNTAIN:
- if (one_chance_in(20))
+ if ( one_chance_in(20) )
gone_dry = true;
- break;
-
- case DNGN_SPARKLING_FOUNTAIN:
+ }
+ else // sparkling fountain
+ {
if (one_chance_in(10))
- {
gone_dry = true;
- break;
- }
- else
- {
- temp_rand = random2(50);
-
- // you won't know it (yet)
- if (temp_rand > 40) // 18% probability
- grd[you.x_pos][you.y_pos] = DNGN_BLUE_FOUNTAIN;
- }
- break;
-
- default:
- break;
+ else if ( random2(50) > 40 ) // no message!
+ grd[you.x_pos][you.y_pos] = DNGN_BLUE_FOUNTAIN;
}
if (gone_dry)
{
mpr("The fountain dries up!");
- if (grd[you.x_pos][you.y_pos] == DNGN_BLUE_FOUNTAIN)
+ if (feat == DNGN_BLUE_FOUNTAIN)
grd[you.x_pos][you.y_pos] = DNGN_DRY_FOUNTAIN_I;
- else if (grd[you.x_pos][you.y_pos] == DNGN_SPARKLING_FOUNTAIN)
+ else
grd[you.x_pos][you.y_pos] = DNGN_DRY_FOUNTAIN_II;
}