summaryrefslogtreecommitdiff
path: root/src/actorspritemanager.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2011-10-02 18:57:10 +0300
committerAndrei Karas <akaras@inbox.ru>2011-10-02 18:57:10 +0300
commitf1e92aca00a4859047e83fab76220767b9a2f814 (patch)
tree8aaa9d6853c6a8e0e8fc568c6f981cbd889b0cc3 /src/actorspritemanager.cpp
parent70b520b1e876f9698bb95baa2d274ea289a0c6bd (diff)
parent99771a1fb50286fdb0b511f425312503e657eddc (diff)
downloadplus-stripped1.1.10.2.tar.gz
plus-stripped1.1.10.2.tar.bz2
plus-stripped1.1.10.2.tar.xz
plus-stripped1.1.10.2.zip
Merge branch 'master' into strippedstripped1.1.10.2
Conflicts: packaging/debian/watch
Diffstat (limited to 'src/actorspritemanager.cpp')
-rw-r--r--src/actorspritemanager.cpp101
1 files changed, 74 insertions, 27 deletions
diff --git a/src/actorspritemanager.cpp b/src/actorspritemanager.cpp
index 03418a857..827d46f29 100644
--- a/src/actorspritemanager.cpp
+++ b/src/actorspritemanager.cpp
@@ -177,11 +177,13 @@ ActorSpriteManager::ActorSpriteManager() :
mTargetOnlyReachable = config.getBoolValue("targetOnlyReachable");
mCyclePlayers = config.getBoolValue("cyclePlayers");
mCycleMonsters = config.getBoolValue("cycleMonsters");
+ mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
config.addListener("targetDeadPlayers", this);
config.addListener("targetOnlyReachable", this);
config.addListener("cyclePlayers", this);
config.addListener("cycleMonsters", this);
+ config.addListener("extMouseTargeting", this);
loadAttackList();
}
@@ -192,6 +194,7 @@ ActorSpriteManager::~ActorSpriteManager()
config.removeListener("targetOnlyReachable", this);
config.removeListener("cyclePlayers", this);
config.removeListener("cycleMonsters", this);
+ config.removeListener("extMouseTargeting", this);
storeAttackList();
clear();
}
@@ -300,26 +303,81 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
return NULL;
bool targetDead = mTargetDeadPlayers;
- Being *tempBeing = 0;
- bool noBeing(false);
- for_actors
+ if (mExtMouseTargeting)
{
- if (!*it)
- continue;
+ Being *tempBeing = 0;
+ bool noBeing(false);
- if ((*it)->getType() == ActorSprite::FLOOR_ITEM
- || (*it)->getType() == ActorSprite::PORTAL)
+ for_actors
{
- continue;
- }
+ if (!*it)
+ continue;
- Being *being = static_cast<Being*>(*it);
+ if ((*it)->getType() == ActorSprite::PORTAL)
+ continue;
- if ((being->isAlive()
- || (targetDead && being->getType() == Being::PLAYER))
- && (allPlayers || being != player_node))
+ if ((*it)->getType() == ActorSprite::FLOOR_ITEM)
+ {
+ if (!noBeing)
+ {
+ FloorItem *floor = static_cast<FloorItem*>(*it);
+ if (!noBeing && (floor->getPixelX() - 32 <= x) &&
+ (floor->getPixelX() + 32 > x) &&
+ (floor->getPixelY() - 64 <= y) &&
+ (floor->getPixelY() + 16 > y))
+ {
+ noBeing = true;
+ }
+ }
+ continue;
+ }
+
+ Being *being = static_cast<Being*>(*it);
+
+ if ((being->isAlive()
+ || (targetDead && being->getType() == Being::PLAYER))
+ && (allPlayers || being != player_node))
+ {
+
+ if ((being->getPixelX() - 16 <= x) &&
+ (being->getPixelX() + 16 > x) &&
+ (being->getPixelY() - 32 <= y) &&
+ (being->getPixelY() > y))
+ {
+ return being;
+ }
+ else if (!noBeing && (being->getPixelX() - 32 <= x) &&
+ (being->getPixelX() + 32 > x) &&
+ (being->getPixelY() - 64 <= y) &&
+ (being->getPixelY() + 16 > y))
+ {
+ if (tempBeing)
+ noBeing = true;
+ else
+ tempBeing = being;
+ }
+ }
+ }
+
+ if (noBeing)
+ return 0;
+ return tempBeing;
+ }
+ else
+ {
+ for_actors
{
+ if (!*it)
+ continue;
+
+ if ((*it)->getType() == ActorSprite::PORTAL ||
+ (*it)->getType() == ActorSprite::FLOOR_ITEM)
+ {
+ continue;
+ }
+
+ Being *being = static_cast<Being*>(*it);
if ((being->getPixelX() - 16 <= x) &&
(being->getPixelX() + 16 > x) &&
@@ -328,22 +386,9 @@ Being *ActorSpriteManager::findBeingByPixel(int x, int y,
{
return being;
}
- else if (!noBeing && (being->getPixelX() - 32 <= x) &&
- (being->getPixelX() + 32 > x) &&
- (being->getPixelY() - 64 <= y) &&
- (being->getPixelY() + 16 > y))
- {
- if (tempBeing)
- noBeing = true;
- else
- tempBeing = being;
- }
}
- }
-
- if (noBeing)
return 0;
- return tempBeing;
+ }
}
void ActorSpriteManager::findBeingsByPixel(std::vector<Being*> &beings,
@@ -1285,6 +1330,8 @@ void ActorSpriteManager::optionChanged(const std::string &name)
mCyclePlayers = config.getBoolValue("cyclePlayers");
else if (name == "cycleMonsters")
mCycleMonsters = config.getBoolValue("cycleMonsters");
+ else if (name == "extMouseTargeting")
+ mExtMouseTargeting = config.getBoolValue("extMouseTargeting");
}
void ActorSpriteManager::removeAttackMob(const std::string &name)