summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-30 05:04:29 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-30 05:04:29 +0000
commite9c49344ae30fe4e976bb4695c4c0d22d0af802d (patch)
tree0faf92a084d51be5d633ac39c5b17d77ba002548 /crawl-ref/source
parentb638f0eb21f238ce8f143f09d0d99effb3cff497 (diff)
downloadcrawl-ref-e9c49344ae30fe4e976bb4695c4c0d22d0af802d.tar.gz
crawl-ref-e9c49344ae30fe4e976bb4695c4c0d22d0af802d.zip
Consolidate and clean up Yred's injury mirroring routines.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7073 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/describe.cc2
-rw-r--r--crawl-ref/source/ouch.cc29
-rw-r--r--crawl-ref/source/religion.cc29
-rw-r--r--crawl-ref/source/religion.h2
4 files changed, 32 insertions, 30 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 034c12b027..d11bee2fa9 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -3143,7 +3143,7 @@ void describe_god( god_type which_god, bool give_title )
}
else if (which_god == GOD_YREDELEMNUL)
{
- if (!player_under_penance() && you.piety >= piety_breakpoint(0))
+ if (yred_injury_mirror())
{
have_any = true;
cprintf("%s mirrors your injuries on your foes "
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 7bb59beb1f..0495e0faa9 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -790,6 +790,32 @@ static void _xom_checks_damage(kill_method_type death_type,
xom_is_stimulated(amusementvalue);
}
+static void _yred_mirrors_injury(int dam, int death_source)
+{
+ if (dam <= 0 || invalid_monster_index(death_source))
+ return;
+
+ if (yred_injury_mirror() && you.duration[DUR_PRAYER])
+ {
+ simple_god_message(" mirrors your injury!");
+
+ monsters *mon = &menv[death_source];
+
+#ifndef USE_TILE
+ flash_monster_colour(mon, RED, 200);
+#endif
+
+ hurt_monster(mon, dam);
+
+ if (mon->hit_points < 1)
+ monster_die(mon, KILL_YOU, NON_MONSTER);
+ else
+ print_wounds(mon);
+
+ lose_piety(integer_sqrt(dam));
+ }
+}
+
// death_source should be set to NON_MONSTER for non-monsters. {dlb}
void ouch(int dam, int death_source, kill_method_type death_type,
const char *aux, bool see_source)
@@ -848,8 +874,7 @@ void ouch(int dam, int death_source, kill_method_type death_type,
take_note(
Note(NOTE_HP_CHANGE, you.hp, you.hp_max, damage_desc.c_str()) );
- if (!invalid_monster_index(death_source))
- yred_mirror_injury(&menv[death_source], dam);
+ _yred_mirrors_injury(dam, death_source);
return;
} // else hp <= 0
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 8900835a99..2de56b7124 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -739,33 +739,10 @@ void dec_penance(int val)
dec_penance(you.religion, val);
}
-bool yred_mirror_injury(monsters *mon, int dam)
+bool yred_injury_mirror()
{
- if (dam <= 0)
- return (false);
-
- if (you.religion == GOD_YREDELEMNUL && you.duration[DUR_PRAYER]
- && !player_under_penance() && you.piety >= piety_breakpoint(0))
- {
- simple_god_message(" mirrors your injury!");
-
-#ifndef USE_TILE
- flash_monster_colour(mon, RED, 200);
-#endif
-
- hurt_monster(mon, dam);
-
- if (mon->hit_points < 1)
- monster_die(mon, KILL_YOU, NON_MONSTER);
- else
- print_wounds(mon);
-
- lose_piety(integer_sqrt(dam));
-
- return (true);
- }
-
- return (false);
+ return (you.religion == GOD_YREDELEMNUL && !player_under_penance()
+ && you.piety >= piety_breakpoint(0));
}
bool beogh_water_walk()
diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h
index 86ebdc91bd..34dfaf8b47 100644
--- a/crawl-ref/source/religion.h
+++ b/crawl-ref/source/religion.h
@@ -94,7 +94,7 @@ void god_smites_you(god_type god, const char *message = NULL,
kill_method_type death_type = NUM_KILLBY);
void divine_retribution(god_type god);
-bool yred_mirror_injury(monsters *mon, int dam);
+bool yred_injury_mirror();
bool beogh_water_walk();
void beogh_idol_revenge();
void good_god_holy_attitude_change(monsters *holy);