summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNicholas Feinberg <pleasingfung@gmail.com>2014-08-02 12:51:41 -0700
committerNicholas Feinberg <pleasingfung@gmail.com>2014-08-02 12:51:41 -0700
commit1ddd267dccda3f6a30eb262df116bfab9c7c7111 (patch)
treec6aae392becadf2ac04aaca774e4dd0fbb17f6f7
parent190ec6e66d1ba387d0ddd5351a07730f414aded8 (diff)
downloadcrawl-ref-1ddd267dccda3f6a30eb262df116bfab9c7c7111.tar.gz
crawl-ref-1ddd267dccda3f6a30eb262df116bfab9c7c7111.zip
Don't let shadow mimics attack out-of-range enemies (8780)
Could occur when hitting an enemy with a distortion weapon.
-rw-r--r--crawl-ref/source/godabil.cc19
1 files changed, 19 insertions, 0 deletions
diff --git a/crawl-ref/source/godabil.cc b/crawl-ref/source/godabil.cc
index 31a96f0b05..5b08f9954c 100644
--- a/crawl-ref/source/godabil.cc
+++ b/crawl-ref/source/godabil.cc
@@ -3699,10 +3699,29 @@ void shadow_monster_reset(monster *mon)
mon->reset();
}
+/**
+ * Check if the player is in melee range of the target.
+ *
+ * Certain effects, e.g. distortion blink, can cause monsters to leave melee
+ * range between the initial hit & the shadow mimic.
+ *
+ * XXX: refactor this with attack/fight code!
+ *
+ * @param target The creature to be struck.
+ * @return Whether the player is melee range of the target, using
+ * their current weapon.
+ */
+bool _in_melee_range(actor* target)
+{
+ const int dist = (you.pos() - target->pos()).abs();
+ return dist < 2 || (dist <= 2 && you.reach_range() != REACH_NONE);
+}
+
void dithmenos_shadow_melee(actor* target)
{
if (!target
|| !target->alive()
+ || !_in_melee_range(target)
|| !_dithmenos_shadow_acts())
{
return;