summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc33
1 files changed, 30 insertions, 3 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 5cb96c2c4c..d7cdd7361b 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -3451,10 +3451,37 @@ bool god_hates_butchery(god_type god)
return (god == GOD_ELYVILON);
}
-bool god_protects_from_harm(god_type god)
+harm_protection_type god_protects_from_harm(god_type god, bool actual)
{
- return (god == GOD_ZIN || god == GOD_SHINING_ONE ||
- god == GOD_ELYVILON || god == GOD_YREDELEMNUL);
+ const int min_piety = piety_breakpoint(0);
+ bool praying = (you.duration[DUR_PRAYER] &&
+ random2(you.piety) >= min_piety);
+ bool anytime = (one_chance_in(10) || you.piety > random2(1000));
+
+ // If actual is true, return HPT_NONE if the given god can protect
+ // the player from harm, but doesn't actually do so.
+ switch (god)
+ {
+ case GOD_YREDELEMNUL:
+ if (!actual || praying)
+ return (you.piety >= min_piety) ? HPT_PRAYING :
+ HPT_NONE;
+ break;
+ case GOD_ZIN:
+ case GOD_SHINING_ONE:
+ if (!actual || anytime)
+ return HPT_ANYTIME;
+ break;
+ case GOD_ELYVILON:
+ if (!actual || praying || anytime)
+ return (you.piety >= min_piety) ? HPT_PRAYING_PLUS_ANYTIME :
+ HPT_ANYTIME;
+ break;
+ default:
+ break;
+ }
+
+ return HPT_NONE;
}
void god_smites_you(god_type god, kill_method_type death_type,