diff options
-rw-r--r-- | ChangeLog | 9 | ||||
-rw-r--r-- | src/engine.cpp | 18 | ||||
-rw-r--r-- | src/game.cpp | 12 | ||||
-rw-r--r-- | src/game.h | 1 | ||||
-rw-r--r-- | src/gui/popupmenu.cpp | 11 | ||||
-rw-r--r-- | src/net/protocol.cpp | 4 |
6 files changed, 45 insertions, 10 deletions
@@ -1,3 +1,12 @@ +2005-09-17 Matthias Hartmann <hartmann.matthias@gmail.com> + + + * src/engine.cpp: [TARGET] text over player + * src/game.cpp: PVP + * src/game.h: PVP + * src/gui/popupmenu.cpp: Added "attack" option to the popupmenu + * src/net/protocol.cpp: findPlayer + 2005-09-17 Bjørn Lindeijer <bjorn@lindeijer.nl> * src/engine.cpp, src/game.cpp: Indent properly. diff --git a/src/engine.cpp b/src/engine.cpp index 7642ef6c..8194e00b 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -468,10 +468,20 @@ void Engine::draw() } if (autoTarget) { - graphics->drawText("[TARGET]", - autoTarget->text_x + 60, - autoTarget->text_y, - gcn::Graphics::CENTER); + if (autoTarget->getType() == Being::PLAYER) + { + graphics->drawText("[TARGET]", + autoTarget->text_x+15, + autoTarget->text_y-60, + gcn::Graphics::CENTER); + + } else { + + graphics->drawText("[TARGET]", + autoTarget->text_x + 60, + autoTarget->text_y, + gcn::Graphics::CENTER); + } } #ifdef DEBUG diff --git a/src/game.cpp b/src/game.cpp index f2f86064..8f9586d9 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -664,16 +664,18 @@ void do_input() { switch (target->getType()) { - // Player default: trade + // Player default: attack case Being::PLAYER: { if (target != player_node) { + autoTarget = target; + attack(target);/* MessageOut outMsg; outMsg.writeShort(CMSG_TRADE_REQUEST); outMsg.writeLong(target->getId()); writeSet(6); - tradePartnerName = target->getName(); + tradePartnerName = target->getName();*/ } } break; @@ -772,7 +774,7 @@ void do_input() Being *being; FloorItem *floorItem; - if ((being = findNode(mx, my))) { + if ((being = findNode(mx, my)) && being != player_node) { popupMenu->showPopup(event.button.x, event.button.y, being); } else if ((floorItem = find_floor_item_by_id( @@ -902,11 +904,11 @@ void do_input() if (keys[SDLK_LCTRL] || keys[SDLK_RCTRL] || joy[JOY_BTN0]) { Being *monster = attack(x, y, player_node->direction); - if (monster == NULL && autoTarget != NULL) + if (monster == NULL && autoTarget != NULL && monster != player_node) { attack(autoTarget); } - else if (keys[SDLK_LSHIFT]) + else if (keys[SDLK_LSHIFT] && monster != player_node) { autoTarget = monster; } @@ -37,6 +37,7 @@ extern std::string tradePartnerName; extern int fps, frame, current_npc; extern volatile int tick_time; extern int server_tick; +extern Being* autoTarget; extern bool displayPathToMouse; extern unsigned short startX, startY; diff --git a/src/gui/popupmenu.cpp b/src/gui/popupmenu.cpp index 77f74f4c..29b599aa 100644 --- a/src/gui/popupmenu.cpp +++ b/src/gui/popupmenu.cpp @@ -86,7 +86,7 @@ void PopupMenu::showPopup(int x, int y, Being *being) const std::string &name = being->getName(); browserBox->addRow("@@trade|Trade With " + name + "@@"); - //browserBox->addRow("@@attack|Attack " + name + "@@"); + browserBox->addRow("@@attack|Attack " + name + "@@"); //browserBox->addRow("@@follow|Follow " + name + "@@"); //browserBox->addRow("@@buddy|Add " + name + " to Buddy List@@"); } @@ -151,6 +151,15 @@ void PopupMenu::handleLink(const std::string& link) //tradePartner << "Trade: You and " << being->name<< ""; tradePartnerName = being->getName(); } + + // Attack action + else if ((link == "attack") && being && being->getType() == Being::PLAYER) + { + + autoTarget = being; + attack(being); + } + /* // Follow Player action else if (link == "follow") diff --git a/src/net/protocol.cpp b/src/net/protocol.cpp index 2e4089d4..318c446d 100644 --- a/src/net/protocol.cpp +++ b/src/net/protocol.cpp @@ -148,18 +148,22 @@ Being* attack(unsigned short x, unsigned short y, unsigned char direction) { case Being::SOUTH: target = findNode(x, y + 1, Being::MONSTER); + if (!target) target = findNode(x, y + 1, Being::PLAYER); break; case Being::WEST: target = findNode(x - 1, y, Being::MONSTER); + if (!target) target = findNode(x - 1, y, Being::PLAYER); break; case Being::NORTH: target = findNode(x, y - 1, Being::MONSTER); + if (!target) target = findNode(x, y - 1, Being::PLAYER); break; case Being::EAST: target = findNode(x + 1, y, Being::MONSTER); + if (!target) target = findNode(x + 1, y, Being::PLAYER); break; } |