From 51d6f634eecae2a9e68078a7272353b8b61fd4e1 Mon Sep 17 00:00:00 2001 From: Chuck Miller Date: Fri, 1 May 2009 21:28:29 -0400 Subject: Changed the way beings are handled when clicked on with a TMWServ build (mainly talking to NPCs, and attacking Monsters / Players. Though combat is still broken.) --- src/gui/viewport.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'src/gui/viewport.cpp') 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(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); } -- cgit v1.2.3-70-g09d2