summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-09 21:48:55 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-03-09 21:48:55 +0000
commit5e2d8f305c41e9f2eec9b5a66804d1a03370a0b5 (patch)
treeee600a1ceea04920fc86a59e13495b94db2a9e7b /crawl-ref/source/religion.cc
parentdbe4130e239966c0e524704123c0fb094a07e7ec (diff)
downloadcrawl-ref-5e2d8f305c41e9f2eec9b5a66804d1a03370a0b5.tar.gz
crawl-ref-5e2d8f305c41e9f2eec9b5a66804d1a03370a0b5.zip
Implement FR 1808966:
Your summoned Daevas leave you if TSO puts you under penance, and they'll actually attack you if you abandon TSO. While the former only applies to Daevas on your current level, the latter happens for all visited dungeon levels. The functions used are generic enough to work for other cases as well, e.g. Trog's "Brothers in Arms" now also turn hostile if you leave Trog. Also: * Make Beogh "protect you from harm" like Zin/TSO do, but only if you're not under penance. * Correct Amulet of inaccuracy description (Bug 1895810). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3558 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc106
1 files changed, 100 insertions, 6 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index cd767dcfb3..b0dc7fa36d 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -363,6 +363,8 @@ void inc_penance(int val);
static bool holy_beings_attitude_change();
static bool beogh_followers_abandon_you(void);
static void dock_piety(int piety_loss, int penance);
+static bool make_god_gifts_disappear(bool level_only = true);
+static bool make_god_gifts_hostile(bool level_only = true);
bool is_evil_god(god_type god)
{
@@ -448,12 +450,16 @@ void inc_penance(god_type god, int val)
// orcish bonuses don't apply under penance
if (god == GOD_BEOGH)
you.redraw_armour_class = true;
- else if (god == GOD_SHINING_ONE && you.duration[DUR_DIVINE_SHIELD])
- { // nor does TSO's divine shield
- mpr("Your divine shield disappears!");
- you.duration[DUR_DIVINE_SHIELD] = 0;
- you.attribute[ATTR_DIVINE_SHIELD] = 0;
- you.redraw_armour_class = true;
+ else if (god == GOD_SHINING_ONE)
+ {
+ if (you.duration[DUR_DIVINE_SHIELD])
+ { // nor does TSO's divine shield
+ mpr("Your divine shield disappears!");
+ you.duration[DUR_DIVINE_SHIELD] = 0;
+ you.attribute[ATTR_DIVINE_SHIELD] = 0;
+ you.redraw_armour_class = true;
+ }
+ make_god_gifts_disappear(true); // only on level
}
}
@@ -2815,6 +2821,87 @@ static bool holy_beings_attitude_change()
return apply_to_all_dungeons(holy_beings_on_level_attitude_change);
}
+// Make summoned (temporary) god gifts disappear on penance
+// or when abandoning the god in question.
+// If seen, only count monsters where the player can see the change and
+// output a message.
+static bool make_god_gifts_on_level_disappear(bool seen = false)
+{
+ int count = 0;
+ for ( int i = 0; i < MAX_MONSTERS; ++i )
+ {
+ monsters *monster = &menv[i];
+ if (monster->type != -1
+ && monster->attitude == ATT_FRIENDLY
+ && monster->has_ench(ENCH_ABJ)
+ && testbits(monster->flags,MF_GOD_GIFT))
+ {
+
+ // monster disappears
+ if (!seen || simple_monster_message(monster, " abandons you!"))
+ count++;
+
+ monster_die(monster, KILL_DISMISSED, 0);
+ }
+ }
+ return (count);
+}
+
+static bool god_gifts_disappear_wrapper()
+{
+ return (make_god_gifts_on_level_disappear());
+}
+
+// Make god gifts disappear on all levels, or on only the current one.
+bool make_god_gifts_disappear(bool level_only)
+{
+ bool success = make_god_gifts_on_level_disappear(true);
+
+ if (level_only)
+ return (success);
+
+ return (apply_to_all_dungeons(god_gifts_disappear_wrapper) || success);
+}
+
+// When abandoning the god in question turn god gifts hostile.
+// If seen, only count monsters where the player can see the change and
+// output a message.
+static bool make_god_gifts_on_level_hostile(bool seen = false)
+{
+ int count = 0;
+ for ( int i = 0; i < MAX_MONSTERS; ++i )
+ {
+ monsters *monster = &menv[i];
+ if (monster->type != -1
+ && monster->attitude == ATT_FRIENDLY
+ && (monster->flags & MF_GOD_GIFT))
+ {
+ // monster changes attitude
+ monster->attitude = ATT_HOSTILE;
+
+ if (!seen || simple_monster_message(monster, " turns against you!"))
+ count++;
+ }
+ }
+ return (count);
+}
+
+static bool god_gifts_hostile_wrapper()
+{
+ return (make_god_gifts_on_level_hostile());
+}
+
+// Make god gifts disappear on all levels, or on only the current one.
+bool make_god_gifts_hostile(bool level_only)
+{
+ bool success = make_god_gifts_on_level_hostile(true);
+
+ if (level_only)
+ return (success);
+
+ return (apply_to_all_dungeons(god_gifts_hostile_wrapper) || success);
+}
+
static bool orcish_followers_on_level_abandon_you()
{
bool success = false;
@@ -3214,6 +3301,7 @@ void excommunication(void)
case GOD_TROG:
simple_god_message( " does not appreciate desertion!", old_god );
+ make_god_gifts_hostile(false);
// Penance has to come before retribution to prevent "mollify"
inc_penance( old_god, 50 );
@@ -3263,6 +3351,7 @@ void excommunication(void)
you.attribute[ATTR_DIVINE_SHIELD] = 0;
you.redraw_armour_class = true;
}
+ make_god_gifts_hostile(false);
inc_penance( old_god, 50 );
break;
@@ -3829,6 +3918,7 @@ harm_protection_type god_protects_from_harm(god_type god, bool actual)
bool praying = (you.duration[DUR_PRAYER] &&
random2(you.piety) >= min_piety);
bool anytime = (one_chance_in(10) || you.piety > random2(1000));
+ bool penance = you.penance[god];
// If actual is true, return HPT_NONE if the given god can protect
// the player from harm, but doesn't actually do so.
@@ -3839,6 +3929,10 @@ harm_protection_type god_protects_from_harm(god_type god, bool actual)
return (you.piety >= min_piety) ? HPT_PRAYING :
HPT_NONE;
break;
+ case GOD_BEOGH:
+ if (!penance && (!actual || anytime))
+ return HPT_ANYTIME;
+ break;
case GOD_ZIN:
case GOD_SHINING_ONE:
if (!actual || anytime)