From 2772e5117bba390bc735af3dd9e0853f93a8306d Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 6 Mar 2009 14:35:34 +0000 Subject: Fix permanent-MP abilities being usable when only temporary MP (e.g. from a ring of magical power) is available. [2664906] This does not apply to HP costs because there's no way to abuse that. In theory it might still be possible to get negative real MP with the high/low magic mutations. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9347 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/skills2.cc | 63 ++++++--------------------------------------- 1 file changed, 8 insertions(+), 55 deletions(-) (limited to 'crawl-ref/source/skills2.cc') diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index aacb6c817a..dc2fa7680e 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -2108,65 +2108,18 @@ void init_skill_order( void ) } } -int calc_hp(bool real_hp) +void calc_hp() { - int hitp = get_real_hp(!real_hp, false); - - you.hp_max = hitp; - - deflate_hp( you.hp_max, false ); - - return (hitp); -} // end calc_hp() + you.hp_max = get_real_hp(true, false); + deflate_hp(you.hp_max, false); +} -int calc_mp(bool real_mp) +void calc_mp() { - int enp; - - // base_magic_points2 accounts for species and magic potions - enp = (you.base_magic_points2 - 5000); - - int spell_extra = (you.experience_level * you.skills[SK_SPELLCASTING]) / 4; - int invoc_extra = (you.experience_level * you.skills[SK_INVOCATIONS]) / 6; - - if (spell_extra > invoc_extra) - enp += spell_extra; - else - enp += invoc_extra; - - you.max_magic_points = stepdown_value( enp, 9, 18, 45, 100 ); - - // this is our "rotted" base (applied after scaling): - you.max_magic_points += (you.base_magic_points - 5000); - - // Yes, we really do want this duplication... this is so the stepdown - // doesn't truncate before we apply the rotted base. We're doing this - // the nice way. -- bwr - if (you.max_magic_points > 50) - you.max_magic_points = 50; - - // now applied after scaling so that power items are more useful -- bwr - if (!real_mp) - you.max_magic_points += player_magical_power(); - - // analogous to ROBUST/FRAIL - you.max_magic_points *= (10 + player_mutation_level(MUT_HIGH_MAGIC) - - player_mutation_level(MUT_LOW_MAGIC)); - you.max_magic_points /= 10; - - if (you.max_magic_points > 50) - you.max_magic_points = 50 + ((you.max_magic_points - 50) / 2); - - if (you.max_magic_points < 0) - you.max_magic_points = 0; - - if (you.magic_points > you.max_magic_points) - you.magic_points = you.max_magic_points; - + you.max_magic_points = get_real_mp(true); + you.magic_points = std::min(you.magic_points, you.max_magic_points); you.redraw_magic_points = true; - - return (you.max_magic_points); -} // end calc_mp() +} unsigned int skill_exp_needed(int lev) { -- cgit v1.2.3-54-g00ecf