diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-20 19:56:19 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-04-20 19:56:19 +0000 |
commit | 741f3db05f169b784e130a11e87f4485d6a679e4 (patch) | |
tree | 8d6004441e49d4158cd5ecf1a004944abc5b92d6 | |
parent | 131216891cbe3539a153395c83f74ac52c216d0a (diff) | |
download | crawl-ref-741f3db05f169b784e130a11e87f4485d6a679e4.tar.gz crawl-ref-741f3db05f169b784e130a11e87f4485d6a679e4.zip |
Expand restore_stat() to allow for more fine-grained constrol of stat
restoration; the amount to be restored can now be specified. Use this
where necessary.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4417 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/source/abl-show.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 23 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/food.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/it_use2.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/spells2.cc | 52 | ||||
-rw-r--r-- | crawl-ref/source/spells2.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 6 |
8 files changed, 48 insertions, 53 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 3afa6f2a59..8fa3574ae0 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1008,7 +1008,7 @@ static bool _do_ability(const ability_def& abil) case ABIL_MUMMY_RESTORATION: { mpr( "You infuse your body with magical energy." ); - bool did_restore = restore_stat( STAT_ALL, false ); + bool did_restore = restore_stat( STAT_ALL, 0, false ); const int oldhpmax = you.hp_max; unrot_hp( 100 ); @@ -1659,7 +1659,7 @@ static bool _do_ability(const ability_def& abil) break; case ABIL_ELYVILON_RESTORATION: - restore_stat( STAT_ALL, false ); + restore_stat( STAT_ALL, 0, false ); unrot_hp( 100 ); exercise( SK_INVOCATIONS, 4 + random2(6) ); diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 7d8a0a62ca..f39421dc0b 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -50,6 +50,7 @@ #include "religion.h" #include "skills.h" #include "skills2.h" +#include "spells2.h" #include "spells3.h" #include "spells4.h" #include "spl-book.h" @@ -2377,25 +2378,13 @@ void handle_time( long time_delta ) if (!you.disease) { if (you.strength < you.max_strength && one_chance_in(100)) - { - mpr("You feel your strength returning.", MSGCH_RECOVERY); - you.strength++; - you.redraw_strength = 1; - } - - if (you.dex < you.max_dex && one_chance_in(100)) - { - mpr("You feel your dexterity returning.", MSGCH_RECOVERY); - you.dex++; - you.redraw_dexterity = 1; - } + restore_stat(STAT_STRENGTH, 0, false); if (you.intel < you.max_intel && one_chance_in(100)) - { - mpr("You feel your intelligence returning.", MSGCH_RECOVERY); - you.intel++; - you.redraw_intelligence = 1; - } + restore_stat(STAT_INTELLIGENCE, 0, false); + + if (you.dex < you.max_dex && one_chance_in(100)) + restore_stat(STAT_DEXTERITY, 0, false); } else { diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 134cfda43f..d08ae846c1 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2587,8 +2587,8 @@ enum slot_select_mode enum stat_type { STAT_STRENGTH, // 0 - STAT_DEXTERITY, STAT_INTELLIGENCE, + STAT_DEXTERITY, NUM_STATS, // added for increase_stats() {dlb} STAT_ALL, // must remain after NUM_STATS -- added to handle royal jelly, etc. {dlb} STAT_RANDOM = 255 // leave at 255, added for increase_stats() handling {dlb} diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index fa28e1f4de..eb8b08c58f 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -1286,7 +1286,7 @@ static void eating(unsigned char item_class, int item_type) break; case FOOD_ROYAL_JELLY: mpr("That royal jelly was delicious!"); - restore_stat(STAT_ALL, false); + restore_stat(STAT_ALL, 0, false); break; case FOOD_PIZZA: if (!SysEnv.crawl_pizza.empty() && !one_chance_in(3)) @@ -1793,12 +1793,7 @@ static void heal_from_food(int hp_amt, int mp_amt, bool unrot, } if (restore_str && you.strength < you.max_strength) - { - mpr("You feel your strength returning."); - you.strength++; - you.redraw_strength = true; - burden_change(); - } + restore_stat(STAT_STRENGTH, 1, false); calc_hp(); calc_mp(); diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index 6ca4a09a46..f1ab3b3d40 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -321,7 +321,7 @@ bool potion_effect( potion_type pot_eff, int pow, bool was_known ) } // give a message if no message otherwise - if (!restore_stat(STAT_ALL, false) && nothing_happens) + if (!restore_stat(STAT_ALL, 0, false) && nothing_happens) mpr( "You feel refreshed." ); break; } diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 14fa175bb2..783f4a92e6 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -689,20 +689,24 @@ bool brand_weapon(brand_type which_brand, int power) return true; } // end brand_weapon() -bool restore_stat(unsigned char which_stat, bool suppress_msg) +// Restore the stat in which_stat by the amount in stat_gain, displaying +// a message if suppress_msg is false. If stat_gain is 0, restore the +// stat completely. +bool restore_stat(unsigned char which_stat, unsigned char stat_gain, + bool suppress_msg) { - bool statRestored = false; + bool stat_restored = false; // a bit hackish, but cut me some slack, man! -- // besides, a little recursion never hurt anyone {dlb}: if (which_stat == STAT_ALL) { - for (unsigned char loopy = STAT_STRENGTH; loopy < NUM_STATS; loopy++) + for (unsigned char loopy = STAT_STRENGTH; loopy < NUM_STATS; ++loopy) { - if (restore_stat(loopy, suppress_msg) == true) - statRestored = true; + if (restore_stat(loopy, stat_gain, suppress_msg)) + stat_restored = true; } - return statRestored; // early return {dlb} + return stat_restored; // early return {dlb} } // the real function begins here {dlb}: @@ -725,14 +729,6 @@ bool restore_stat(unsigned char which_stat, bool suppress_msg) ptr_redraw = &you.redraw_strength; break; - case STAT_DEXTERITY: - msg += "dexterity"; - - ptr_stat = &you.dex; - ptr_stat_max = &you.max_dex; - ptr_redraw = &you.redraw_dexterity; - break; - case STAT_INTELLIGENCE: msg += "intelligence"; @@ -740,23 +736,37 @@ bool restore_stat(unsigned char which_stat, bool suppress_msg) ptr_stat_max = &you.max_intel; ptr_redraw = &you.redraw_intelligence; break; + + case STAT_DEXTERITY: + msg += "dexterity"; + + ptr_stat = &you.dex; + ptr_stat_max = &you.max_dex; + ptr_redraw = &you.redraw_dexterity; + break; } if (*ptr_stat < *ptr_stat_max) { msg += " returning."; if ( !suppress_msg ) - mpr(msg.c_str()); + mpr(msg.c_str(), MSGCH_RECOVERY); + + if (stat_gain == 0 || *ptr_stat + stat_gain > *ptr_stat_max) + stat_gain = *ptr_stat_max - *ptr_stat; - *ptr_stat = *ptr_stat_max; - *ptr_redraw = 1; - statRestored = true; + if (stat_gain != 0) + { + *ptr_stat += stat_gain; + *ptr_redraw = true; + stat_restored = true; - if (ptr_stat == &you.strength) - burden_change(); + if (ptr_stat == &you.strength) + burden_change(); + } } - return statRestored; + return stat_restored; } // end restore_stat() void turn_undead(int pow) diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index fead7c715c..b5d8e8cfaf 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -124,7 +124,8 @@ void drain_life(int pow); * called from: ability - food - it_use2 - spell * returns TRUE if a stat was restored. * *********************************************************************** */ -bool restore_stat(unsigned char which_stat, bool suppress_msg); +bool restore_stat(unsigned char which_stat, unsigned char stat_gain, + bool suppress_msg); // last updated 24may2000 {dlb} diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index b100a966cb..674f09a919 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1218,15 +1218,15 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail ) break; case SPELL_RESTORE_STRENGTH: - restore_stat(STAT_STRENGTH, false); + restore_stat(STAT_STRENGTH, 0, false); break; case SPELL_RESTORE_INTELLIGENCE: - restore_stat(STAT_INTELLIGENCE, false); + restore_stat(STAT_INTELLIGENCE, 0, false); break; case SPELL_RESTORE_DEXTERITY: - restore_stat(STAT_DEXTERITY, false); + restore_stat(STAT_DEXTERITY, 0, false); break; case SPELL_VENOM_BOLT: |