summaryrefslogtreecommitdiff
path: root/src/gui/viewport.cpp
diff options
context:
space:
mode:
authorDavid Athay <ko2fan@gmail.com>2008-04-11 14:12:30 +0000
committerDavid Athay <ko2fan@gmail.com>2008-04-11 14:12:30 +0000
commitb50649ee5e28511df72cc3a08023747727c5b6f0 (patch)
tree1f1408b4550e70388ed1103747f973dbe77670f5 /src/gui/viewport.cpp
parent760967f3c0dae0c352568a2865c57679559806fa (diff)
downloadmana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.tar.gz
mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.tar.bz2
mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.tar.xz
mana-client-b50649ee5e28511df72cc3a08023747727c5b6f0.zip
Players now need to
click on the monster sprites rather than the tile. Players will now move to the target before attacking it.
Diffstat (limited to 'src/gui/viewport.cpp')
-rw-r--r--src/gui/viewport.cpp21
1 files changed, 19 insertions, 2 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index ecd70d69..d53204b6 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -398,7 +398,10 @@ Viewport::mousePressed(gcn::MouseEvent &event)
FloorItem *item;
// Interact with some being
- if ((being = beingManager->findBeing(tilex, tiley)))
+// if ((being = beingManager->findBeing(tilex, tiley))
+ int x = event.getX() + mPixelViewX;
+ int y = event.getY() + mPixelViewY;
+ if ((being = beingManager->findBeingByPixel(x, y)))
{
switch (being->getType())
{
@@ -410,8 +413,22 @@ Viewport::mousePressed(gcn::MouseEvent &event)
case Being::PLAYER:
if (being->mAction == Being::DEAD)
break;
+ if (being == player_node)
+ break;
- player_node->attack(being, true);
+ if (player_node->withinAttackRange(being))
+ {
+ player_node->attack(being, true);
+ }
+ else
+ {
+ Uint8 *keys = SDL_GetKeyState(NULL);
+ if (!(keys[SDLK_LSHIFT] || keys[SDLK_RSHIFT]))
+ {
+ player_node->stopAttack();
+ player_node->setGotoTarget(being);
+ }
+ }
break;
default: