summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gui/viewport.cpp24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/gui/viewport.cpp b/src/gui/viewport.cpp
index 9ce537fc..041794c2 100644
--- a/src/gui/viewport.cpp
+++ b/src/gui/viewport.cpp
@@ -335,21 +335,22 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
if (event.getButton() == gcn::MouseEvent::LEFT)
{
FloorItem *item;
-#ifdef EATHENA_SUPPORT
Being *being;
// Interact with some being
-// if ((being = beingManager->findBeing(tilex, tiley)))
if ((being = beingManager->findBeingByPixel(pixelx, pixely)))
{
switch (being->getType())
{
+ // Talk to NPCs
case Being::NPC:
dynamic_cast<NPC*>(being)->talk();
break;
+ // Attack or walk to monsters or players
case Being::MONSTER:
case Being::PLAYER:
+ // Ignore it if its dead
if (being->mAction == Being::DEAD)
break;
@@ -357,23 +358,30 @@ void Viewport::mousePressed(gcn::MouseEvent &event)
keyboard.isKeyActive(keyboard.KEY_ATTACK))
{
player_node->setGotoTarget(being);
+//TODO: This can be changed when TMWServ moves to target based combat
+#ifdef TMWSERV_SUPPORT
+ player_node->attack();
+#else
player_node->attack(being,
!keyboard.isKeyActive(keyboard.KEY_TARGET));
+#endif
+
}
else
{
+#ifdef TMWSERV_SUPPORT
+ player_node->setDestination(event.getX() + (int) mPixelViewX,
+ event.getY() + (int) mPixelViewY);
+#else
player_node->setDestination(tilex, tiley);
+#endif
}
break;
-
default:
break;
}
- }
- // Pick up some item
- else
-#endif
- if ((item = floorItemManager->findByCoordinates(tilex, tiley)))
+ // Picks up a item if we clicked on one
+ } else if ((item = floorItemManager->findByCoordinates(tilex, tiley)))
{
player_node->pickUp(item);
}