summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-01 00:49:04 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-01 00:49:04 +0000
commitee9032f0333fe9fd08502d2291fe6aa6ec513e09 (patch)
treeff6a46e5a1031acb634f4b738f202dff752bd0c8 /crawl-ref/source/religion.cc
parent54d9768ff184b52faba9d466177b2563faebfe1d (diff)
downloadcrawl-ref-ee9032f0333fe9fd08502d2291fe6aa6ec513e09.tar.gz
crawl-ref-ee9032f0333fe9fd08502d2291fe6aa6ec513e09.zip
Bug 2004786: a lightning bolt bouncing and hitting a monster a second/tird/etc
time shouldn't be an unchivalrous attack if the first hit wasn't unchivalrous. Before this fix the damage from the first hit from a lightning bolt might make a monster flee, and then the subsequent hits from bounces would be unchivalrous since it was fleeing. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6272 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc27
1 files changed, 26 insertions, 1 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 303e26716e..c531c96366 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2758,19 +2758,44 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known,
return (ret);
}
+// These two arrays deal with the situation where a beam hits a non-fleeing
+// monster, the monster starts to flee because of the damage, and then the
+// beam bounces and hits the monster again. If the monster wasn't fleeing
+// when the beam started then hits from bounces shouldn't count as
+// unchivalric attacks, but if the first hit from the beam *was* unchivalrous
+// then all the bounces should count as unchivalrous as well.
+static FixedVector<bool, NUM_MONSTERS> _first_attack_conduct;
+static FixedVector<bool, NUM_MONSTERS> _first_attack_was_unchivalric;
+
+void religion_turn_start()
+{
+ _first_attack_conduct.init(true);
+ _first_attack_was_unchivalric.init(false);
+ crawl_state.clear_god_acting();
+}
+
void set_attack_conducts(god_conduct_trigger conduct[3], const monsters *mon,
bool known)
{
+ const unsigned int midx = monster_index(mon);
+
if (mons_friendly(mon))
conduct[0].set(DID_ATTACK_FRIEND, 5, known, mon);
else if (mons_neutral(mon))
conduct[0].set(DID_ATTACK_NEUTRAL, 5, known, mon);
- if (is_unchivalric_attack(&you, mon, mon))
+ if (is_unchivalric_attack(&you, mon, mon)
+ && (_first_attack_conduct[midx]
+ || _first_attack_was_unchivalric[midx]))
+ {
conduct[1].set(DID_UNCHIVALRIC_ATTACK, 4, known, mon);
+ _first_attack_was_unchivalric[midx] = true;
+ }
if (mons_is_holy(mon))
conduct[2].set(DID_ATTACK_HOLY, mon->hit_dice, known, mon);
+
+ _first_attack_conduct[midx] = false;
}
void enable_attack_conducts(god_conduct_trigger conduct[3])