summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/actormanager.cpp18
1 files changed, 12 insertions, 6 deletions
diff --git a/src/actormanager.cpp b/src/actormanager.cpp
index 5c0ea8f80..7e1d8c9a2 100644
--- a/src/actormanager.cpp
+++ b/src/actormanager.cpp
@@ -1352,13 +1352,19 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing,
priority -= 10000; // but still respect their priorities.
}
}
-
- // if (default) is in ignore list, then only attack
- // those in priority or general attack list.
- if (ignoreDefault
- && attackMobs.find(being->getName()) == attackMobs.end()
- && prioIter == priorityMobsMap.end())
+ else if (auto attackIter = attackMobs.find(being->getName());
+ attackIter != attackMobs.end())
+ {
+ // prioritise attack mobs that are within attack range
+ if (abs(dx) <= attackRange2 && abs(dy) <= attackRange2)
+ {
+ priority -= 9999; // but still prefer priority ones.
+ }
+ }
+ else if (ignoreDefault)
{
+ // if (default) is in ignore list, then only attack
+ // those in priority or general attack list.
continue;
}
}