From a7180f0d5fa06964848bbe676d10a0c32899dce1 Mon Sep 17 00:00:00 2001 From: dolorous Date: Sat, 26 Apr 2008 15:08:21 +0000 Subject: Expand mutate() to account for mutations as god gifts, and make Xom use them, so that he respects the full mutation resistance mutation, as well as the limitations on how much players can be covered in scales, etc. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4666 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/mutation.cc | 52 +++++++++++++++++++++++++------------------- crawl-ref/source/mutation.h | 3 ++- crawl-ref/source/xom.cc | 4 ++-- 3 files changed, 34 insertions(+), 25 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index 2630ea28db..b4a1debbea 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -1649,7 +1649,8 @@ static mutation_type get_random_mutation(bool prefer_good, } bool mutate(mutation_type which_mutation, bool failMsg, - bool force_mutation, bool demonspawn) + bool force_mutation, bool god_gift, + bool demonspawn) { if (demonspawn) force_mutation = true; @@ -1693,8 +1694,17 @@ bool mutate(mutation_type which_mutation, bool failMsg, // except for demonspawn (or other permamutations) in lichform -- haranp if (rotting && !demonspawn) { - if (wearing_amulet(AMU_RESIST_MUTATION) ? one_chance_in(10) - : !one_chance_in(3)) + // Temporary resistance can be overridden by a god gift. + if ((wearing_amulet(AMU_RESIST_MUTATION) ? !one_chance_in(10) + : one_chance_in(3)) + && !god_gift) + { + if (failMsg) + mpr("You feel odd for a moment.", MSGCH_MUTATION); + + return (false); + } + else { mpr( "Your body decomposes!", MSGCH_MUTATION ); @@ -1709,17 +1719,14 @@ bool mutate(mutation_type which_mutation, bool failMsg, xom_is_stimulated(64); return (true); } - - if (failMsg) - mpr("You feel odd for a moment.", MSGCH_MUTATION); - - return (false); } if (!force_mutation) { - if (wearing_amulet(AMU_RESIST_MUTATION) && !one_chance_in(10) - || you.religion == GOD_ZIN && you.piety > random2(MAX_PIETY) + // Temporary resistance can be overridden by a god gift. + if (((wearing_amulet(AMU_RESIST_MUTATION) && !one_chance_in(10)) + || (you.religion == GOD_ZIN && you.piety > random2(MAX_PIETY)) + && !god_gift) || player_mutation_level(MUT_MUTATION_RESISTANCE) == 3 || player_mutation_level(MUT_MUTATION_RESISTANCE) && !one_chance_in(3)) @@ -1778,7 +1785,6 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (you.mutation[mutat] > 13 && !force_mutation) return false; - // These can be forced by demonspawn if ((mutat == MUT_TOUGH_SKIN || mutat == MUT_SHAGGY_FUR || mutat >= MUT_GREEN_SCALES && mutat <= MUT_BONEY_PLATES || mutat >= MUT_RED_SCALES && mutat <= MUT_PATTERNED_SCALES) @@ -1805,9 +1811,10 @@ bool mutate(mutation_type which_mutation, bool failMsg, } } - // This one can be forced by demonspawn + // This one can be forced by demonspawn or a god gift if (mutat == MUT_REGENERATION - && you.mutation[MUT_SLOW_METABOLISM] > 0 && !force_mutation) + && you.mutation[MUT_SLOW_METABOLISM] > 0 && !god_gift + && !force_mutation) { return false; // if you have a slow metabolism, no regen } @@ -1815,9 +1822,10 @@ bool mutate(mutation_type which_mutation, bool failMsg, if (mutat == MUT_SLOW_METABOLISM && you.mutation[MUT_REGENERATION] > 0) return false; // if you have regen, no slow metabolism - // This one can be forced by demonspawn + // This one can be forced by demonspawn or a god gift if (mutat == MUT_ACUTE_VISION - && you.mutation[MUT_BLURRY_VISION] > 0 && !force_mutation) + && you.mutation[MUT_BLURRY_VISION] > 0 && !god_gift + && !force_mutation) { return false; } @@ -1937,8 +1945,8 @@ bool mutate(mutation_type which_mutation, bool failMsg, case MUT_REGENERATION: if (you.mutation[MUT_SLOW_METABOLISM] > 0) { - // Should only get here from demonspawn, where our innate - // ability will clear away the counter-mutation. + // Should only get here from demonspawn or a god gift, where + // our innate ability will clear away the counter-mutation. while (delete_mutation(MUT_SLOW_METABOLISM)) ; } @@ -1948,8 +1956,8 @@ bool mutate(mutation_type which_mutation, bool failMsg, case MUT_ACUTE_VISION: if (you.mutation[MUT_BLURRY_VISION] > 0) { - // Should only get here from demonspawn, where our innate - // ability will clear away the counter-mutation. + // Should only get here from demonspawn or a god gift, where + // our innate ability will clear away the counter-mutation. while (delete_mutation(MUT_BLURRY_VISION)) ; } @@ -2747,13 +2755,13 @@ bool perma_mutate(mutation_type which_mut, int how_much) how_much = std::min(static_cast(how_much), mutation_defs[which_mut].levels); - if (mutate(which_mut, false, true, true)) + if (mutate(which_mut, false, true, false, true)) levels++; - if (how_much >= 2 && mutate(which_mut, false, true, true)) + if (how_much >= 2 && mutate(which_mut, false, true, false, true)) levels++; - if (how_much >= 3 && mutate(which_mut, false, true, true)) + if (how_much >= 3 && mutate(which_mut, false, true, false, true)) levels++; you.demon_pow[which_mut] = levels; diff --git a/crawl-ref/source/mutation.h b/crawl-ref/source/mutation.h index e80fca0aa1..3b39b95996 100644 --- a/crawl-ref/source/mutation.h +++ b/crawl-ref/source/mutation.h @@ -37,7 +37,8 @@ void fixup_mutations(); * mutation - religion - spell - spells * *********************************************************************** */ bool mutate(mutation_type which_mutation, bool failMsg = true, - bool force_mutation = false, bool demonspawn = false); + bool force_mutation = false, bool god_gift = false, + bool demonspawn = false); // last updated 12may2000 {dlb} /* *********************************************************************** diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 0c64e935c6..c8fa29bf31 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -638,7 +638,7 @@ static bool xom_is_good(int sever) bool failMsg = true; for (int i = random2(4); i >= 0; --i) { - if (mutate(RANDOM_GOOD_MUTATION, failMsg, true)) + if (mutate(RANDOM_GOOD_MUTATION, failMsg, false, false, true)) done = true; else failMsg = false; @@ -770,7 +770,7 @@ static bool xom_is_bad(int sever) bool failMsg = true; for (int i = random2(4); i >= 0; --i) { - if (mutate(RANDOM_XOM_MUTATION, failMsg, true)) + if (mutate(RANDOM_XOM_MUTATION, failMsg, false, false, true)) done = true; else failMsg = false; -- cgit v1.2.3-54-g00ecf