From ee9032f0333fe9fd08502d2291fe6aa6ec513e09 Mon Sep 17 00:00:00 2001 From: zelgadis Date: Tue, 1 Jul 2008 00:49:04 +0000 Subject: 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 --- crawl-ref/source/religion.cc | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'crawl-ref/source/religion.cc') 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 _first_attack_conduct; +static FixedVector _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]) -- cgit v1.2.3-54-g00ecf