From 84d56b88a03054d35b84dc1ecbd7ad4614f8ac86 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 24 Jun 2014 22:49:20 +0300 Subject: Add new action for select closest monster without filters and sorting. By default unassigned. --- src/actormanager.cpp | 29 +++++++++++++++++++++-------- 1 file changed, 21 insertions(+), 8 deletions(-) (limited to 'src/actormanager.cpp') diff --git a/src/actormanager.cpp b/src/actormanager.cpp index 36fdf7c93..4e4cf0655 100644 --- a/src/actormanager.cpp +++ b/src/actormanager.cpp @@ -833,25 +833,36 @@ Being *ActorManager::findNearestLivingBeing(const int x, const int y, { const int maxDist = maxTileDist * mapTileSize; - return findNearestLivingBeing(nullptr, maxDist, type, x, y, excluded); + return findNearestLivingBeing(nullptr, maxDist, + type, + x, y, + excluded, + true); } Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, const int maxDist, - const ActorType::Type type) const + const ActorType::Type type, + const bool allowSort) const { if (!aroundBeing) return nullptr; - return findNearestLivingBeing(aroundBeing, maxDist, type, - aroundBeing->getTileX(), aroundBeing->getTileY(), aroundBeing); + return findNearestLivingBeing(aroundBeing, + maxDist, + type, + aroundBeing->getTileX(), + aroundBeing->getTileY(), + aroundBeing, + allowSort); } Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, int maxDist, const ActorType::Type &type, const int x, const int y, - const Being *const excluded) const + const Being *const excluded, + const bool allowSort) const { if (!aroundBeing || !player_node) return nullptr; @@ -874,11 +885,13 @@ Being *ActorManager::findNearestLivingBeing(const Being *const aroundBeing, maxDist = maxDist * maxDist; - const bool cycleSelect = (mCyclePlayers && type == ActorType::PLAYER) + const bool cycleSelect = allowSort + && ((mCyclePlayers && type == ActorType::PLAYER) || (mCycleMonsters && type == ActorType::MONSTER) - || (mCycleNPC && type == ActorType::NPC); + || (mCycleNPC && type == ActorType::NPC)); - const bool filtered = config.getBoolValue("enableAttackFilter") + const bool filtered = allowSort + && config.getBoolValue("enableAttackFilter") && type == ActorType::MONSTER; const bool modActive = inputManager.isActionActive( InputAction::STOP_ATTACK); -- cgit v1.2.3-60-g2f50