summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-22 04:05:26 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-22 04:05:26 +0000
commitc37a9398ab2850d920de9cef57d1ca44d0e7e257 (patch)
treec8bce7639273b36f107a64a522e85c08f75edd4b
parentbea44e6c4331e7ff932eab4c7d96f61c1d2d3fe6 (diff)
downloadcrawl-ref-c37a9398ab2850d920de9cef57d1ca44d0e7e257.tar.gz
crawl-ref-c37a9398ab2850d920de9cef57d1ca44d0e7e257.zip
Add minor cleanups of divine protection from harm:
* move the list of gods that do it into the function god_protects_from_harm(), instead of hardcoding the list in two places * update the description of it, both in the code and the surrounding comments, since it no longer depends on prayer, and since it can now happen with piety less than 30 git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2892 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/describe.cc35
-rw-r--r--crawl-ref/source/ouch.cc10
-rw-r--r--crawl-ref/source/religion.cc6
-rw-r--r--crawl-ref/source/religion.h1
4 files changed, 25 insertions, 27 deletions
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 365336611c..3d608592df 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -4281,32 +4281,31 @@ void describe_god( god_type which_god, bool give_title )
cprintf(EOL EOL "Granted powers: (Cost)" EOL);
textcolor(colour);
- // mv: these gods protects you during your prayer (not mentioning XOM)
- // chance for doing so is (random2(you.piety) >= 30)
+ // mv: some gods can protect you from harm
+ // The chance for doing so is:
+ // one_chance_in(10) || you.piety > random2(1000)
// Note that it's not depending on penance.
// Btw. I'm not sure how to explain such divine protection
// because god isn't really protecting player - he only sometimes
// saves his life (probably it shouldn't be displayed at all).
- // What about this ?
+ // What about this?
bool have_any = false;
- if ((which_god == GOD_ZIN
- || which_god == GOD_SHINING_ONE
- || which_god == GOD_ELYVILON
- || which_god == GOD_YREDELEMNUL)
- && you.piety >= 30)
+
+ if (god_protects_from_harm(which_god))
{
have_any = true;
- cprintf( "%s %s watches over you during prayer." EOL,
- god_name(which_god),
- (you.piety >= 150) ? "carefully": // > 4/5
- (you.piety >= 90) ? "often" : // > 2/3
- "sometimes"); // less than 2:3
+ cprintf( "%s %s watches over you." EOL, god_name(which_god),
+ (you.piety >= 150) ? "carefully":
+ (you.piety >= 90) ? "often" :
+ (you.piety >= 30) ? "sometimes" :
+ "occasionally");
+ }
- if (which_god == GOD_ZIN)
- {
- cprintf("Praying to %s will provide sustenance if starving."
- EOL, god_name(which_god));
- }
+ if (which_god == GOD_ZIN && you.piety >= 30)
+ {
+ have_any = true;
+ cprintf("Praying to %s will provide sustenance if starving."
+ EOL, god_name(which_god));
}
if (which_god == GOD_TROG)
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 19403209ec..6e6e35dffd 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -785,24 +785,16 @@ void ouch( int dam, int death_source, kill_method_type death_type,
if (dam > -9000) // that is, a "death" caused by hp loss {dlb}
{
- switch (you.religion)
+ if (god_protects_from_harm(you.religion))
{
- case GOD_ZIN:
- case GOD_SHINING_ONE:
- case GOD_ELYVILON:
- case GOD_YREDELEMNUL:
if (dam >= you.hp
&& (one_chance_in(10) || you.piety > random2(1000)))
{
simple_god_message( " protects you from harm!" );
return;
}
- break;
- default:
- break;
}
-
dec_hp( dam, true );
// Even if we have low HP messages off, we'll still give a
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 78b047734c..6051692374 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -3478,6 +3478,12 @@ bool god_hates_butchery(god_type god)
return (god == GOD_ELYVILON);
}
+bool god_protects_from_harm(god_type god)
+{
+ return (god == GOD_ZIN || god == GOD_SHINING_ONE ||
+ god == GOD_ELYVILON || god == GOD_YREDELEMNUL);
+}
+
void offer_corpse(int corpse)
{
// We always give the "good" (piety-gain) message when doing
diff --git a/crawl-ref/source/religion.h b/crawl-ref/source/religion.h
index e07975a4e1..e7117ca90b 100644
--- a/crawl-ref/source/religion.h
+++ b/crawl-ref/source/religion.h
@@ -43,6 +43,7 @@ int piety_rank(int piety = -1);
void offer_items();
bool god_likes_butchery(god_type god);
bool god_hates_butchery(god_type god);
+bool god_protects_from_harm(god_type god);
void divine_retribution(god_type god);
bool beogh_water_walk();