diff options
author | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-25 19:45:18 +0100 |
---|---|---|
committer | Philipp Sehmisch <crush@themanaworld.org> | 2009-01-25 19:45:18 +0100 |
commit | 3ca85b152531b9dd9cffa18d9b64d7c7ae615adf (patch) | |
tree | 91bbf1fdb71c52e1074160652abacfc1911a5bac /src/beingmanager.cpp | |
parent | 2a7c63f6070606e6623a9730aa1ca9d52c942055 (diff) | |
download | mana-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.tar.gz mana-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.tar.bz2 mana-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.tar.xz mana-3ca85b152531b9dd9cffa18d9b64d7c7ae615adf.zip |
Fixed offset of right-click hitboxes and made NPCs without sprites clickable.
Diffstat (limited to 'src/beingmanager.cpp')
-rw-r--r-- | src/beingmanager.cpp | 19 |
1 files changed, 10 insertions, 9 deletions
diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index 6d9267d2..7f3d8845 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -123,12 +123,13 @@ Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y) for (; itr != itr_end; ++itr) { Being *being = (*itr); - if ((being->mAction != Being::DEAD) && - (being != player_node) && - (being->getPixelX() <= x) && - (being->getPixelX() + being->getWidth() >= x) && - (being->getPixelY() <= y) && - (being->getPixelY() + being->getHeight() >= y)) + int xtol = being->getWidth() / 2; + int uptol = being->getHeight(); + if ((being != player_node) && + (being->getPixelX() - xtol <= x) && + (being->getPixelX() + xtol >= x) && + (being->getPixelY() - uptol <= y) && + (being->getPixelY() >= y)) { return being; } @@ -190,7 +191,7 @@ Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, //in map coords, while down below its in pixels // //I believe there is a deeper problem under this, but - //for a temp solution we'll convert to coords to pixels + //for a temp solution we'll convert to coords to pixels x = x * 32; y = y * 32; maxdist = maxdist * 32; @@ -210,8 +211,8 @@ Being* BeingManager::findNearestLivingBeing(Uint16 x, Uint16 y, int maxdist, closestBeing = being; } } - - return (maxdist >= dist) ? closestBeing : NULL; + + return (maxdist >= dist) ? closestBeing : NULL; } Being* BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist, |