diff options
author | Ira Rice <irarice@gmail.com> | 2009-01-26 01:26:25 -0700 |
---|---|---|
committer | Ira Rice <irarice@gmail.com> | 2009-01-26 01:26:25 -0700 |
commit | 062f4065f5a2117fc5fd5f408e1f3163e2f63afc (patch) | |
tree | 83e9f5053dcf16049cc416f05b03e7bbf9c916fe /src | |
parent | cd0bbf213902665f795d10a38c4f847f681c290c (diff) | |
download | mana-client-062f4065f5a2117fc5fd5f408e1f3163e2f63afc.tar.gz mana-client-062f4065f5a2117fc5fd5f408e1f3163e2f63afc.tar.bz2 mana-client-062f4065f5a2117fc5fd5f408e1f3163e2f63afc.tar.xz mana-client-062f4065f5a2117fc5fd5f408e1f3163e2f63afc.zip |
Fixed offset of right-click hitboxes and made NPCs without sprites
clickable. Also set a minimum clickable area so that small mobs like
maggots aren't too difficult to click.
Been wanting this patched for a while, but didn't know where to look
until Crush's patch for mainline click zones on TMW.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/being.cpp | 14 | ||||
-rw-r--r-- | src/being.h | 3 | ||||
-rw-r--r-- | src/beingmanager.cpp | 10 |
3 files changed, 20 insertions, 7 deletions
diff --git a/src/being.cpp b/src/being.cpp index 3fc679da..ad5f4204 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -571,11 +571,14 @@ int Being::getWidth() const { if (mSprites[BASE_SPRITE]) { - return mSprites[BASE_SPRITE]->getWidth(); + const int width = mSprites[BASE_SPRITE]->getWidth() > Being::DEFAULT_WIDTH ? + mSprites[BASE_SPRITE]->getWidth() : + Being::DEFAULT_WIDTH; + return width; } else { - return 0; + return Being::DEFAULT_WIDTH; } } @@ -584,11 +587,14 @@ int Being::getHeight() const { if (mSprites[BASE_SPRITE]) { - return mSprites[BASE_SPRITE]->getHeight(); + const int height = mSprites[BASE_SPRITE]->getHeight() > Being::DEFAULT_HEIGHT ? + mSprites[BASE_SPRITE]->getHeight() : + Being::DEFAULT_HEIGHT; + return height; } else { - return 0; + return Being::DEFAULT_HEIGHT; } } diff --git a/src/being.h b/src/being.h index 80295db8..a43297ad 100644 --- a/src/being.h +++ b/src/being.h @@ -432,6 +432,9 @@ class Being : public Sprite */ int getOffset(char pos, char neg) const; + static const int DEFAULT_WIDTH = 32; + static const int DEFAULT_HEIGHT = 32; + // Speech Bubble components SpeechBubble *mSpeechBubble; diff --git a/src/beingmanager.cpp b/src/beingmanager.cpp index b2dc330b..6b71b3bf 100644 --- a/src/beingmanager.cpp +++ b/src/beingmanager.cpp @@ -129,12 +129,16 @@ Being* BeingManager::findBeingByPixel(Uint16 x, Uint16 y) for (; itr != itr_end; ++itr) { Being *being = (*itr); + + int xtol = being->getWidth(); + int uptol = being->getHeight(); + if ((being->mAction != Being::DEAD) && (being != player_node) && (being->getPixelX() <= x) && - (being->getPixelX() + being->getWidth() >= x) && - (being->getPixelY() <= y) && - (being->getPixelY() + being->getHeight() >= y)) + (being->getPixelX() + xtol >= x) && + (being->getPixelY() - (uptol / 2) <= y) && + (being->getPixelY() + (uptol / 2) >= y)) { return being; } |