summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-10-04 02:18:31 +0300
committerAndrei Karas <akaras@inbox.ru>2011-10-04 02:18:31 +0300
commit851bee28374c5c60114c9f78299e28eaa14891b3 (patch)
treee6239581d2ccfd494f0382694ab5d449f1160920
parentbd76fd8ea5c665f41b76cc51b227259d6302681c (diff)
downloadmanaverse-851bee28374c5c60114c9f78299e28eaa14891b3.tar.gz
manaverse-851bee28374c5c60114c9f78299e28eaa14891b3.tar.bz2
manaverse-851bee28374c5c60114c9f78299e28eaa14891b3.tar.xz
manaverse-851bee28374c5c60114c9f78299e28eaa14891b3.zip
Dont select in archer mode very closer mobs if no other mobs in attack distance.
-rw-r--r--src/actorspritemanager.cpp27
-rw-r--r--src/being.h2
2 files changed, 25 insertions, 4 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 155fe05ef..ba303e800 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -119,8 +119,18 @@ class SortBeingFunctor
}
if (being1->getDistance() != being2->getDistance())
{
- if (specialDistance && being1->getDistance() <= 2)
+ if (specialDistance && being1->getDistance() <= 2
+ && being2->getDistance() <= attackRange
+ && being2->getDistance() > 2)
+ {
return false;
+ }
+ else if (specialDistance && being2->getDistance() <= 2
+ && being1->getDistance() <= attackRange
+ && being1->getDistance() > 2)
+ {
+ return true;
+ }
return being1->getDistance() < being2->getDistance();
}
@@ -169,6 +179,7 @@ class SortBeingFunctor
std::map<std::string, int> *priorityBeings;
int defaultPriorityIndex;
bool specialDistance;
+ int attackRange;
} beingSorter;
ActorSpriteManager::ActorSpriteManager() :
@@ -768,6 +779,8 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
std::map<std::string, int> priorityMobsMap;
int defaultAttackIndex = 10000;
int defaultPriorityIndex = 10000;
+ const int attackRange = player_node->getAttackRange();
+
bool specialDistance = false;
if (player_node->getMoveToTargetType() == 7
&& player_node->getAttackRange() > 2)
@@ -794,6 +807,7 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
beingSorter.attackBeings = &attackMobsMap;
beingSorter.priorityBeings = &priorityMobsMap;
beingSorter.specialDistance = specialDistance;
+ beingSorter.attackRange = attackRange;
if (ignoreAttackMobs.find("") != ignoreAttackMobs.end())
ignoreDefault = true;
std::map<std::string, int>::const_iterator
@@ -872,8 +886,15 @@ Being *ActorSpriteManager::findNearestLivingBeing(Being *aroundBeing,
if (player_node->getTarget() == NULL)
{
- // if no selected being, return first nearest being
- return sortedBeings.at(0);
+ Being *target = sortedBeings.at(0);
+
+ if (specialDistance && target->getType() == Being::MONSTER
+ && target->getDistance() <= 2)
+ {
+ return 0;
+ }
+ // if no selected being in vector, return first nearest being
+ return target;
}
beingEqualFinder.findBeing = player_node->getTarget();
diff --git a/src/being.h b/src/being.h
index 2c37ffeb5..90bfcfb54 100644
--- a/src/being.h
+++ b/src/being.h
@@ -540,7 +540,7 @@ class Being : public ActorSprite, public ConfigListener
const Path &getPath() const
{ return mPath; }
- int getDistance()
+ int getDistance() const
{ return mDistance; }
void setDistance(int n)