[Hide Content]From 6dc2e7c80f8621cad024b3381cd4b83d7adc115c Mon Sep 17 00:00:00 2001
From: cjo <cjo@ulyco.com>
Date: Mon, 22 Apr 2013 12:15:27 -0700
Subject: [PATCH] Mana Shield mutation, revised.
---
crawl-ref/source/enum.h | 3 +++
crawl-ref/source/main.cc | 21 +++++++++++++++++++--
crawl-ref/source/mon-abil.cc | 4 +++-
crawl-ref/source/mutation-data.h | 30 ++++++++++++++++++++++++++++++
crawl-ref/source/mutation.cc | 5 +++++
crawl-ref/source/ouch.cc | 16 ++++++++++++++++
6 files changed, 76 insertions(+), 3 deletions(-)
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index 02e476c..453df1f 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -2773,6 +2773,9 @@ enum mutation_type
MUT_TENDRILS,
MUT_JELLY_GROWTH,
MUT_JELLY_MISSILE,
+ MUT_MANA_SHIELD, // added new values here, is that correct? -cjo
+ MUT_MANA_REGENERATION,
+ MUT_MANA_LINK,
NUM_MUTATIONS,
RANDOM_MUTATION,
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index 3252ea1..492f9b2 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -2923,6 +2923,11 @@ static void _check_sanctuary()
decrease_sanctuary_radius();
}
+// cjo: Handles player hp and mp regeneration. If the counter you.hit_points_regeneration
+// is over 100, a loop restores 1 hp and decreased the counter by 100 (so you can regen
+// more than 1hp per turn). If the counter is below 100, it is increased by a variable
+// calculated from delay, BASELINE_DELAY, and your regeneration rate. MP regeneration happens
+// similarly, but the countup depends on delay, BASELINE_DELAY, and you.max_magic_points
static void _regenerate_hp_and_mp(int delay)
{
if (crawl_state.disables[DIS_PLAYER_REGEN])
@@ -2940,7 +2945,15 @@ static void _regenerate_hp_and_mp(int delay)
while (tmp >= 100)
{
- inc_hp(1);
+ if (you.mutation[MUT_MANA_LINK] // at low mp, "mana link" restores mp in place of hp
+ && you.magic_points < you.max_magic_points * 2 / 3)
+ {
+ inc_mp(1);
+ }
+ else // standard hp regeneration
+ {
+ inc_hp(1);
+ }
tmp -= 100;
}
@@ -2959,7 +2972,11 @@ static void _regenerate_hp_and_mp(int delay)
if (you.magic_points < you.max_magic_points)
{
const int base_val = 7 + you.max_magic_points / 2;
- tmp += div_rand_round(base_val * delay, BASELINE_DELAY);
+ int mp_regen_countup = div_rand_round(base_val * delay, BASELINE_DELAY);
+ if (you.mutation[MUT_MANA_REGENERATION])
+ mp_regen_countup *= 2;
+
+ tmp += mp_regen_countup;
}
while (tmp >= 100)
diff --git a/crawl-ref/source/mon-abil.cc b/crawl-ref/source/mon-abil.cc
index 958e032..12b8415 100644
--- a/crawl-ref/source/mon-abil.cc
+++ b/crawl-ref/source/mon-abil.cc
@@ -3573,8 +3573,10 @@ void mon_nearby_ability(monster* mons)
interrupt_activity(AI_MONSTER_ATTACKS, mons);
int mp = min(5 + random2avg(13, 3), you.magic_points);
- dec_mp(mp);
+ if (you.mutation[MUT_MANA_LINK]) // this mutation cuts mp loss in half
+ mp = div_rand_round(mp, 2);
+ dec_mp(mp);
mons->heal(mp, true); // heh heh {dlb}
}
break;
diff --git a/crawl-ref/source/mutation-data.h b/crawl-ref/source/mutation-data.h
index 5c596dc..cbabf27 100644
--- a/crawl-ref/source/mutation-data.h
+++ b/crawl-ref/source/mutation-data.h
@@ -1098,6 +1098,36 @@
"augmentation"
},
+{ MUT_MANA_SHIELD, 0, 1, false, false, false,
+ "mana shield",
+
+ {"When hurt, damage is shared between your health and your mana reserves.", "", ""},
+ {"You feel your magical essence form a protective shroud around your flesh.", "", ""},
+ {"", "", ""},
+
+ "mana shield"
+},
+
+{ MUT_MANA_REGENERATION, 0, 1, false, false, false,
+ "mana regeneration",
+
+ {"You regenerate mana rapidly.", "", ""},
+ {"You feel your mana shroud grow more resiliant.", "", ""},
+ {"", "", ""},
+
+ "mana regeneration"
+},
+
+{ MUT_MANA_LINK, 0, 1, false, false, false,
+ "mana link",
+
+ {"When low on mana, you restore mana in place of health. and you resist mana draining attacks.", "", ""},
+ {"You feel your life force and your magical essence meld.", "", ""},
+ {"", "", ""},
+
+ "mana link"
+},
+
// Jiyva only mutations
{ MUT_GELATINOUS_BODY, 0, 3, false, true, true,
NULL,
diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc
index d3a14b0..46500e5 100644
--- a/crawl-ref/source/mutation.cc
+++ b/crawl-ref/source/mutation.cc
@@ -803,6 +803,9 @@ static int _calc_mutation_amusement_value(mutation_type which_mutation)
case MUT_MUTATION_RESISTANCE:
case MUT_ROBUST:
case MUT_HIGH_MAGIC:
+ case MUT_MANA_SHIELD:
+ case MUT_MANA_REGENERATION:
+ case MUT_MANA_LINK:
amusement /= 2; // not funny
break;
@@ -1928,6 +1931,8 @@ static const facet_def _demon_facets[] =
{ -33, 0, 0 } },
{ 2, { MUT_SAPROVOROUS, MUT_FOUL_STENCH, MUT_FOUL_STENCH },
{ -33, 0, 0 } },
+ { 2, { MUT_MANA_SHIELD, MUT_MANA_REGENERATION, MUT_MANA_LINK },
+ { -33, 0, 0 } },
// Tier 3 facets
{ 3, { MUT_CONSERVE_SCROLLS, MUT_HEAT_RESISTANCE, MUT_HURL_HELLFIRE },
{ 50, 50, 50 } },
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index f15fd34..9935290 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -1139,6 +1139,22 @@ void ouch(int dam, int death_source, kill_method_type death_type,
return;
}
+ // Currently the effect from MUT_MANA_SHIELD is the same as "spirit shield"
+ if (you.mutation[MUT_MANA_SHIELD] && death_type != KILLED_BY_POISON)
+ {
+ // round off fairly (important for taking 1 damage at a time)
+ int mp = div_rand_round(dam * you.magic_points,
+ you.hp + you.magic_points);
+ // but don't kill the player with round-off errors
+ mp = max(mp, dam + 1 - you.hp);
+ mp = min(mp, you.magic_points);
+
+ dam -= mp;
+ dec_mp(mp);
+ if (dam <= 0)
+ return;
+ }
+
if (dam >= you.hp && you.hp_max > 0 && god_protects_from_harm())
{
simple_god_message(" protects you from harm!");
--
1.8.1.2