diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/clua.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/it_use2.cc | 182 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 108 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/makeitem.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/shopping.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/stuff.cc | 12 | ||||
-rw-r--r-- | crawl-ref/source/stuff.h | 1 |
10 files changed, 142 insertions, 173 deletions
diff --git a/crawl-ref/source/clua.cc b/crawl-ref/source/clua.cc index 7f735179b1..d0535fd03b 100644 --- a/crawl-ref/source/clua.cc +++ b/crawl-ref/source/clua.cc @@ -1212,6 +1212,7 @@ static int l_item_potion_type(lua_State *ls) case POT_MAGIC: case POT_RESTORE_ABILITIES: case POT_CURE_MUTATION: + case POT_RESISTANCE: val = 1; break; diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index fbb133bb34..b26bbc5040 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2218,6 +2218,9 @@ static const char* describe_potion( const item_def &item ) case POT_BLOOD: return "A potion containing the essence of life. Vital for all living " "creatures, as well as some undead ones.$"; + case POT_RESISTANCE: + return "A potion which grants you " + "temporary resistance to the elements.$"; case NUM_POTIONS: return "A buggy potion."; } diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index b22d747567..51fe08e20c 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2892,6 +2892,7 @@ enum potion_type POT_CURE_MUTATION, POT_MUTATION, POT_BLOOD, + POT_RESISTANCE, NUM_POTIONS }; diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index e74aa0fd2b..b21d4024ad 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -46,52 +46,48 @@ bool potion_effect( potion_type pot_eff, int pow ) bool effect = true; // current behaviour is all potions id on quaffing int new_value = 0; - unsigned char i; if (pow > 150) pow = 150; + const int factor = (you.species == SP_VAMPIRE ? 2 : 1); + switch (pot_eff) { case POT_HEALING: + + inc_hp( (5 + random2(7)) / factor, false); + mpr("You feel better."); + if (you.species == SP_VAMPIRE) { - inc_hp((5 + random2(7)) / 2, false); if (!one_chance_in(3)) you.rotting = 0; if (!one_chance_in(3)) you.duration[DUR_CONF] = 0; - mpr("You feel slightly better."); - break; - } - mpr("You feel better."); - inc_hp(5 + random2(7), false); - - // only fix rot when healed to full - if (you.hp == you.hp_max) + } + else { - unrot_hp(1); - set_hp(you.hp_max, false); + // only fix rot when healed to full + if (you.hp == you.hp_max) + { + unrot_hp(1); + set_hp(you.hp_max, false); + } + + you.duration[DUR_POISONING] = 0; + you.rotting = 0; + you.disease = 0; + you.duration[DUR_CONF] = 0; } - - you.duration[DUR_POISONING] = 0; - you.rotting = 0; - you.disease = 0; - you.duration[DUR_CONF] = 0; break; case POT_HEAL_WOUNDS: - if (you.species == SP_VAMPIRE) - { - inc_hp((10 + random2avg(28, 3)) / 2, false); - mpr("You feel better."); - break; - } + inc_hp((10 + random2avg(28, 3)) / factor, false); mpr("You feel much better."); - inc_hp(10 + random2avg(28, 3), false); // only fix rot when healed to full - if (you.hp == you.hp_max) + if ( you.species != SP_VAMPIRE && you.hp == you.hp_max ) { unrot_hp( 2 + random2avg(5, 2) ); set_hp(you.hp_max, false); @@ -99,39 +95,31 @@ bool potion_effect( potion_type pot_eff, int pow ) break; case POT_SPEED: - if (you.species == SP_VAMPIRE) - { - haste_player( (40 + random2(pow)) / 2 ); - break; - } - haste_player( 40 + random2(pow) ); + haste_player( (40 + random2(pow)) / factor ); break; case POT_MIGHT: - { - bool were_mighty = (you.duration[DUR_MIGHT] > 0); - - if (!were_mighty) - mpr( "You feel very mighty all of a sudden." ); - else - { - mpr( "You feel mightier all of a sudden." ); - contaminate_player(1); - } - - // conceivable max gain of +184 {dlb} - you.duration[DUR_MIGHT] += 35 + random2(pow); + { + const bool were_mighty = (you.duration[DUR_MIGHT] > 0); + + mprf(MSGCH_DURATION, "You feel %s all of a sudden.", + were_mighty ? "mightier" : "very mighty"); - if (!were_mighty) - modify_stat(STAT_STRENGTH, 5, true); + if ( were_mighty ) + contaminate_player(1); + else + modify_stat(STAT_STRENGTH, 5, true); - // files.cc permits values up to 215, but ... {dlb} - if (you.duration[DUR_MIGHT] > 80) - you.duration[DUR_MIGHT] = 80; + // conceivable max gain of +184 {dlb} + you.duration[DUR_MIGHT] += 35 + random2(pow); + + // files.cc permits values up to 215, but ... {dlb} + if (you.duration[DUR_MIGHT] > 80) + you.duration[DUR_MIGHT] = 80; - did_god_conduct( DID_STIMULANTS, 4 + random2(4) ); - } + did_god_conduct( DID_STIMULANTS, 4 + random2(4) ); break; + } case POT_GAIN_STRENGTH: mutate(MUT_STRONG); @@ -179,36 +167,18 @@ bool potion_effect( potion_type pot_eff, int pow ) break; case POT_SLOWING: - if (you.species == SP_VAMPIRE) - { - slow_player( (10 + random2(pow)) / 2 ); - xom_is_stimulated(32); - break; - } - slow_player( 10 + random2(pow) ); - xom_is_stimulated(64); + slow_player( (10 + random2(pow)) / factor ); + xom_is_stimulated(64 / factor); break; case POT_PARALYSIS: - if (you.species == SP_VAMPIRE) - { - slow_player( 10 + random2(pow) ); - xom_is_stimulated(32); - break; - } you.paralyse(2 + random2( 6 + you.duration[DUR_PARALYSIS] )); xom_is_stimulated(64); break; case POT_CONFUSION: - if (you.species == SP_VAMPIRE) - { - confuse_player( (3 + random2(8)) / 2 ); - xom_is_stimulated(54); - break; - } - confuse_player( 3 + random2(8) ); - xom_is_stimulated(128); + confuse_player( (3 + random2(8)) / factor ); + xom_is_stimulated(128 / factor); break; case POT_INVISIBILITY: @@ -234,20 +204,15 @@ bool potion_effect( potion_type pot_eff, int pow ) if (you.species == SP_VAMPIRE || you.mutation[MUT_CARNIVOROUS] == 3) { mpr("Blech - that potion was really gluggy!"); - break; } - mpr("That potion was really gluggy!"); - lessen_hunger(6000, true); + else + { + mpr("That potion was really gluggy!"); + lessen_hunger(6000, true); + } break; case POT_DEGENERATION: - if (you.species == SP_VAMPIRE) - { - mpr("There was something wrong with that liquid!"); - lose_stat(STAT_RANDOM, 1 + random2(2)); - xom_is_stimulated(32); - break; - } mpr("There was something very wrong with that liquid!"); lose_stat(STAT_RANDOM, 1 + random2avg(4, 2)); xom_is_stimulated(64); @@ -268,13 +233,12 @@ bool potion_effect( potion_type pot_eff, int pow ) if (you.species == SP_VAMPIRE) { mpr("Blech - this tastes like water."); - break; } - mpr("This tastes like water."); - // we should really separate thirst from hunger {dlb} - // Thirst would just be annoying for the player, the - // 20 points here doesn't represesent real food anyways -- bwr - lessen_hunger(20, true); + else + { + mpr("This tastes like water."); + lessen_hunger(20, true); + } break; case POT_EXPERIENCE: @@ -297,19 +261,15 @@ bool potion_effect( potion_type pot_eff, int pow ) if (you.magic_points + new_value > you.max_magic_points) { new_value = (you.max_magic_points - you.magic_points) - + (you.magic_points + new_value - you.max_magic_points) / 4 + 1; + + (you.magic_points + new_value - you.max_magic_points)/4 + 1; } inc_mp( new_value, true ); break; case POT_RESTORE_ABILITIES: - // messaging taken care of within function {dlb} - // not quite true... if no stat's are restore = no message, and - // that's just confusing when trying out random potions (this one - // still auto-identifies so we know what the effect is, but it - // shouldn't require bringing up the descovery screen to do that -- bwr - if (restore_stat(STAT_ALL, false) == false) + // give a message if restore_stat doesn't + if (!restore_stat(STAT_ALL, false)) mpr( "You feel refreshed." ); break; @@ -318,28 +278,25 @@ bool potion_effect( potion_type pot_eff, int pow ) { mpr("You feel slightly irritated."); make_hungry(100, false); - break; } - go_berserk(true); - xom_is_stimulated(64); + else + { + go_berserk(true); + xom_is_stimulated(64); + } break; case POT_CURE_MUTATION: mpr("It has a very clean taste."); - for (i = 0; i < 7; i++) - { + for (int i = 0; i < 7; i++) if (random2(10) > i) delete_mutation(RANDOM_MUTATION); - } break; case POT_MUTATION: mpr("You feel extremely strange."); - for (i = 0; i < 3; i++) - { + for (int i = 0; i < 3; i++) mutate(RANDOM_MUTATION, false); - } - did_god_conduct(DID_STIMULANTS, 4 + random2(4)); break; @@ -366,10 +323,10 @@ bool potion_effect( potion_type pot_eff, int pow ) else { bool likes_blood = (you.species == SP_KOBOLD - || you.species == SP_OGRE + || you.species == SP_OGRE || you.species == SP_TROLL || you.mutation[MUT_CARNIVOROUS]); - + if (likes_blood) { mpr("This tastes like blood."); @@ -388,6 +345,15 @@ bool potion_effect( potion_type pot_eff, int pow ) } break; + case POT_RESISTANCE: + mpr("You feel protected."); + you.duration[DUR_RESIST_FIRE] += random2(pow) + 10; + you.duration[DUR_RESIST_COLD] += random2(pow) + 10; + you.duration[DUR_INSULATION] += random2(pow) + 10; + // one contamination point for each resist + contaminate_player(3); + break; + case NUM_POTIONS: mpr("You feel bugginess flow through your body."); break; 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; } diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index fc9decb7ce..48ea28531f 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -481,6 +481,7 @@ static const char* potion_type_name(int potiontype) case POT_CURE_MUTATION: return "cure mutation"; case POT_MUTATION: return "mutation"; case POT_BLOOD: return "blood"; + case POT_RESISTANCE: return "resistance"; default: return "bugginess"; } } diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index 9f7d79b6bc..b267bab7a3 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -2416,6 +2416,9 @@ int items( int allow_uniques, // not just true-false, if (one_chance_in(6)) mitm[p].sub_type = POT_LEVITATION; // 3.401% + if (one_chance_in(8)) + mitm[p].sub_type = POT_RESISTANCE; + if (one_chance_in(30)) mitm[p].sub_type = POT_PORRIDGE; // 0.704% diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 627874cd5d..fce0a7cab6 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -1113,6 +1113,9 @@ unsigned int item_value( item_def item, bool ident ) case POT_MAGIC: valued += 120; break; + case POT_RESISTANCE: + valued += 70; + break; case POT_INVISIBILITY: valued += 55; break; diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index a26a318c7a..92063e93d3 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -248,6 +248,18 @@ int random_choose_weighted(int weight, int first, ...) return (chosen); } +int weighted_random( const int weights[], unsigned int numweights ) +{ + int totalweight = 0; + unsigned int result = 0; + for ( unsigned int i = 0; i < numweights; ++i ) + { + totalweight += weights[i]; + if ( random2(totalweight) < weights[i] ) + result = i; + } + return result; +} int random2( int max ) { diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h index 39fa0da021..8e1532a21a 100644 --- a/crawl-ref/source/stuff.h +++ b/crawl-ref/source/stuff.h @@ -37,6 +37,7 @@ int random_range(int low, int high); int random_range(int low, int high, int nrolls); int random_choose(int first, ...); int random_choose_weighted(int weight, int first, ...); +int weighted_random(const int weights[], unsigned int numweights); unsigned long random_int(); int random2avg( int max, int rolls ); int bestroll(int max, int rolls); |