summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-24 05:21:45 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-24 05:21:45 +0000
commit62b57f5fce2459dade3705de7107d430c17d2e45 (patch)
tree24743ccac6b43ae92a8dabe29ce0c8511b96f4d8 /crawl-ref
parent35a49060d5aa1154a1361c2d3504cd976835e942 (diff)
downloadcrawl-ref-62b57f5fce2459dade3705de7107d430c17d2e45.tar.gz
crawl-ref-62b57f5fce2459dade3705de7107d430c17d2e45.zip
Clean up and consolidate all the smiting routines into the new function
god_smites_you(). This fixes a problem where you could worship Beogh, draw the Wrath card to make him smite you, and have him possibly protect you from his own smiting. The smiting code in beogh_idol_revenge() wouldn't allow this, but the smiting code in beogh_retribution() would. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2906 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/religion.cc134
-rw-r--r--crawl-ref/source/religion.h3
2 files changed, 61 insertions, 76 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 3bc858658a..9c16fcbd9f 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -353,7 +353,6 @@ const char* god_lose_power_messages[NUM_GODS][MAX_GOD_ABILITIES] =
"walk on water" }
};
-
void altar_prayer(void);
void dec_penance(god_type god, int val);
void dec_penance(int val);
@@ -2124,24 +2123,7 @@ static bool tso_retribution()
god );
}
else
- {
- if (!player_under_penance() && you.piety > random2(400))
- {
- snprintf(info, INFO_SIZE, "Mortal, I have averted the wrath "
- "of %s... this time.", god_name(god));
- god_speaks(you.religion, info);
- }
- else
- {
- int divine_hurt = 10 + random2(10);
- for (int i = 0; i < 5; i++)
- divine_hurt += random2( you.experience_level );
-
- simple_god_message( " smites you!", god );
- ouch( divine_hurt, 0, KILLED_BY_TSO_SMITING );
- dec_penance( god, 1 );
- }
- }
+ god_smites_you(GOD_SHINING_ONE, KILLED_BY_TSO_SMITING);
return false;
}
@@ -2395,26 +2377,8 @@ static bool beogh_retribution()
{
case 0: // smiting (25%)
case 1:
- {
- if (!player_under_penance() && you.piety > random2(400))
- {
- snprintf(info, INFO_SIZE, "Mortal, I have averted the wrath "
- "of %s... this time.", god_name(god));
- god_speaks(you.religion, info);
- }
- else
- {
- int divine_hurt = 10 + random2(10);
-
- for (int i = 0; i < 5; i++)
- divine_hurt += random2( you.experience_level );
-
- simple_god_message( " smites you!", god );
- ouch( divine_hurt, 0, KILLED_BY_BEOGH_SMITING );
- dec_penance( god, 1 );
- }
+ god_smites_you(GOD_BEOGH, KILLED_BY_BEOGH_SMITING);
break;
- }
case 2: // send out one or two dancing weapons of orc slaying (12.5%)
{
@@ -2818,56 +2782,45 @@ void beogh_idol_revenge()
|| (you.species == SP_HILL_ORC && coinflip())
|| one_chance_in(3))
{
- if (you.religion != GOD_BEOGH && you.religion != GOD_XOM &&
- !player_under_penance() && you.piety > random2(400))
+ const char* revenge;
+
+ if (you.religion == GOD_BEOGH)
{
- snprintf(info, INFO_SIZE, "Mortal, I have averted the wrath "
- "of %s... this time.", god_name(GOD_BEOGH));
- god_speaks(you.religion, info);
+ const char* messages[3] = {
+ "Beogh fumes, \"This is no small sin, orc. Repent!\"",
+ "Beogh whispers, \"You will pay for this transgression.\"",
+ "Beogh rages, \"An eye for an eye...\""
+ };
+
+ revenge = RANDOM_ELEMENT(messages);
}
- else
+ else if (you.species == SP_HILL_ORC)
{
- if (you.religion == GOD_BEOGH)
- {
- const char* messages[3] = {
- " fumes, \"This is no small sin, orc. Repent!\"",
- " whispers, \"You will pay for this transgression.\"",
- " rages, \"An eye for an eye...\""
- };
- simple_god_message(RANDOM_ELEMENT(messages), GOD_BEOGH);
- }
- else if (you.species == SP_HILL_ORC)
- {
- const char* messages[2] = {
- "Beogh's voice booms out: \"Heretic, die!\"",
- "You hear Beogh's thundering voice: \"Suffer, infidel!\""
- };
- god_speaks(GOD_BEOGH, RANDOM_ELEMENT(messages));
- }
- else
- {
- const char* messages[2] = {
- " is not amused about the destruction of his idols.",
- " seems highly displeased."
- };
- simple_god_message(RANDOM_ELEMENT(messages), GOD_BEOGH);
- }
-
- int divine_hurt = 10 + random2(10);
+ const char* messages[2] = {
+ "Beogh's voice booms out: \"Heretic, die!\"",
+ "You hear Beogh's thundering voice: \"Suffer, infidel!\""
+ };
- for (int i = 0; i < 5; i++)
- divine_hurt += random2( you.experience_level );
+ revenge = RANDOM_ELEMENT(messages);
+ }
+ else
+ {
+ const char* messages[2] = {
+ "Beogh is not amused about the destruction of his idols.",
+ "Beogh seems highly displeased."
+ };
- simple_god_message( " smites you!", GOD_BEOGH );
- ouch( divine_hurt, 0, KILLED_BY_BEOGH_SMITING );
+ revenge = RANDOM_ELEMENT(messages);
}
+ god_smites_you(GOD_BEOGH, KILLED_BY_BEOGH_SMITING, revenge);
+
if (you.religion == GOD_BEOGH)
{
// comes closest and same result (penance + piety loss)
did_god_conduct(DID_ATTACK_FRIEND, 8);
}
- }
+ }
}
static void beogh_orc_emergency_conversion_speech(
@@ -3487,6 +3440,35 @@ bool god_protects_from_harm(god_type god)
god == GOD_ELYVILON || god == GOD_YREDELEMNUL);
}
+void god_smites_you(god_type god, kill_method_type death_type,
+ const char *message)
+{
+ // Your god won't protect you from his own smiting, and Xom is too
+ // capricious to protect you from any god's smiting.
+ if (you.religion != god && you.religion != GOD_XOM &&
+ !player_under_penance() && you.piety > random2(400))
+ {
+ snprintf(info, INFO_SIZE, "Mortal, I have averted the wrath "
+ "of %s... this time.", god_name(god));
+ god_speaks(you.religion, info);
+ }
+ else
+ {
+ // If there's a message, display it before smiting.
+ if (message)
+ god_speaks(god, message);
+
+ int divine_hurt = 10 + random2(10);
+
+ for (int i = 0; i < 5; i++)
+ divine_hurt += random2( you.experience_level );
+
+ simple_god_message( " smites you!", god );
+ ouch( divine_hurt, 0, death_type );
+ dec_penance( god, 1 );
+ }
+}
+
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 e7117ca90b..15b5d843cb 100644
--- a/crawl-ref/source/religion.h
+++ b/crawl-ref/source/religion.h
@@ -15,6 +15,7 @@
#define RELIGION_H
#include "enum.h"
+#include "ouch.h"
#define MAX_PIETY 200
@@ -44,6 +45,8 @@ 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 god_smites_you(god_type god, kill_method_type death_type,
+ const char *message = NULL);
void divine_retribution(god_type god);
bool beogh_water_walk();