From 2596c142137a45d88a65431956436b9a5d466859 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Sun, 2 Oct 2011 19:36:43 +0300 Subject: Add new move to target mode for archers. In this mode player not selecting closer targets. --- src/actorspritemanager.cpp | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'src/actorspritemanager.cpp') diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp index 827d46f29..3a8b47aed 100644 --- a/src/actorspritemanager.cpp +++ b/src/actorspritemanager.cpp @@ -118,7 +118,11 @@ class SortBeingFunctor return w1 < w2; } if (being1->getDistance() != being2->getDistance()) + { + if (specialDistance && being1->getDistance() <= 2) + return false; return being1->getDistance() < being2->getDistance(); + } int d1, d2; #ifdef MANASERV_SUPPORT @@ -164,7 +168,7 @@ class SortBeingFunctor int defaultAttackIndex; std::map *priorityBeings; int defaultPriorityIndex; - + bool specialDistance; } beingSorter; ActorSpriteManager::ActorSpriteManager() : @@ -764,6 +768,12 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, std::map priorityMobsMap; int defaultAttackIndex = 10000; int defaultPriorityIndex = 10000; + bool specialDistance = false; + if (player_node->getMoveToTargetType() == 7 + && player_node->getAttackRange() > 2) + { + specialDistance = true; + } maxDist = maxDist * maxDist; @@ -783,6 +793,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, priorityMobsMap = mPriorityAttackMobsMap; beingSorter.attackBeings = &attackMobsMap; beingSorter.priorityBeings = &priorityMobsMap; + beingSorter.specialDistance = specialDistance; if (ignoreAttackMobs.find("") != ignoreAttackMobs.end()) ignoreDefault = true; std::map::const_iterator @@ -928,6 +939,9 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing, if (!valid) continue; + if (specialDistance && being->getDistance() <= 2) + continue; + // logger->log("being name:" + being->getName()); // logger->log("index:" + toString(index)); // logger->log("d:" + toString(d)); -- cgit v1.2.3-70-g09d2