diff --git a/src/monster.cpp b/src/monster.cpp index 9986e42768..890570d8c0 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -508,18 +508,18 @@ bool Monster::searchTarget(TargetSearchType_t searchType /*= TARGETSEARCH_DEFAUL } switch (searchType) { - case TARGETSEARCH_NEAREAST: { + case TARGETSEARCH_NEAREST: { if (!resultList.empty()) { auto it = resultList.begin(); Creature* target = *it; if (++it != resultList.end()) { const Position& targetPosition = target->getPosition(); - int32_t minRange = std::max(Position::getDistanceX(myPos, targetPosition), Position::getDistanceY(myPos, targetPosition)); + int32_t minRange = Position::getDistanceX(myPos, targetPosition) + Position::getDistanceY(myPos, targetPosition); do { const Position& pos = (*it)->getPosition(); - int32_t distance = std::max(Position::getDistanceX(myPos, pos), Position::getDistanceY(myPos, pos)); + int32_t distance = Position::getDistanceX(myPos, pos) + Position::getDistanceY(myPos, pos); if (distance < minRange) { target = *it; minRange = distance; @@ -888,7 +888,7 @@ void Monster::onThinkTarget(uint32_t interval) if (mType->targetDistance <= 1) { searchTarget(TARGETSEARCH_RANDOM); } else { - searchTarget(TARGETSEARCH_NEAREAST); + searchTarget(TARGETSEARCH_NEAREST); } } } diff --git a/src/monster.h b/src/monster.h index 3524b6c47e..ea77ab8de2 100644 --- a/src/monster.h +++ b/src/monster.h @@ -34,7 +34,7 @@ enum TargetSearchType_t { TARGETSEARCH_DEFAULT, TARGETSEARCH_RANDOM, TARGETSEARCH_ATTACKRANGE, - TARGETSEARCH_NEAREAST + TARGETSEARCH_NEAREST }; class Monster final : public Creature