diff options
author | David Athay <ko2fan@gmail.com> | 2009-05-26 15:25:55 +0100 |
---|---|---|
committer | David Athay <ko2fan@gmail.com> | 2009-05-26 15:33:49 +0100 |
commit | 802481a7e19c45da2128de18359b44f1a95c476c (patch) | |
tree | 7c9bc341c16547ed30fe7212b0d672607ce19bf5 | |
parent | cd5ca5b198f7345f363dba322f49a8e3703dd431 (diff) | |
download | mana-802481a7e19c45da2128de18359b44f1a95c476c.tar.gz mana-802481a7e19c45da2128de18359b44f1a95c476c.tar.bz2 mana-802481a7e19c45da2128de18359b44f1a95c476c.tar.xz mana-802481a7e19c45da2128de18359b44f1a95c476c.zip |
Fixed attacking for tmwserv. Added back attacking with keyboard for tmwserv.
-rw-r--r-- | src/game.cpp | 12 | ||||
-rw-r--r-- | src/localplayer.cpp | 20 |
2 files changed, 24 insertions, 8 deletions
diff --git a/src/game.cpp b/src/game.cpp index 98985e74..41bcc9cc 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -728,7 +728,7 @@ void Game::handleInput() default: break; } - if (keyboard.isEnabled() && + if (keyboard.isEnabled() && !chatWindow->isInputFocused() && !npcDialog->isInputFocused()) { const int tKey = keyboard.getKeyIndex(event.key.keysym.sym); @@ -988,7 +988,7 @@ void Game::handleInput() } #else player_node->setWalkingDir(direction); - +#endif // Attacking monsters if (keyboard.isKeyActive(keyboard.KEY_ATTACK) || (joystick && joystick->buttonPressed(0))) @@ -1005,7 +1005,11 @@ void Game::handleInput() // A set target has highest priority if (!player_node->getTarget()) { +#ifdef TMWSERV_SUPPORT + Uint16 targetX = x / 32, targetY = y / 32; +#else Uint16 targetX = x, targetY = y; +#endif // Only auto target Monsters target = beingManager->findNearestLivingBeing(targetX, targetY, 20, Being::MONSTER); @@ -1013,8 +1017,6 @@ void Game::handleInput() player_node->attack(target, newTarget); } -#endif - // Target the nearest player/monster/npc if ((keyboard.isKeyActive(keyboard.KEY_TARGET_PLAYER) || keyboard.isKeyActive(keyboard.KEY_TARGET_CLOSEST) || @@ -1058,7 +1060,7 @@ void Game::handleInput() } // Stop attacking if the right key is pressed - if (!keyboard.isKeyActive(keyboard.KEY_ATTACK) + if (!keyboard.isKeyActive(keyboard.KEY_ATTACK) && keyboard.isKeyActive(keyboard.KEY_TARGET)) { player_node->stopAttack(); diff --git a/src/localplayer.cpp b/src/localplayer.cpp index c9dc771d..9cdf0bf8 100644 --- a/src/localplayer.cpp +++ b/src/localplayer.cpp @@ -703,6 +703,22 @@ void LocalPlayer::attack(Being *target, bool keep) return; #endif +#ifdef TMWSERV_SUPPORT + if (abs(dist_y) >= abs(dist_x)) + { + if (dist_y < 0) + setDirection(DOWN); + else + setDirection(UP); + } + else + { + if (dist_x < 0) + setDirection(RIGHT); + else + setDirection(LEFT); + } +#else if (abs(dist_y) >= abs(dist_x)) { if (dist_y > 0) @@ -717,6 +733,7 @@ void LocalPlayer::attack(Being *target, bool keep) else setDirection(LEFT); } +#endif #ifdef TMWSERV_SUPPORT mLastAction = tick_time; @@ -738,9 +755,6 @@ void LocalPlayer::attack(Being *target, bool keep) sound.playSfx("sfx/fist-swish.ogg"); } -#ifdef TMWSERV_SUPPORT - if (mLastAction == STAND) -#endif Net::getPlayerHandler()->attack(target->getId()); #ifdef EATHENA_SUPPORT if (!keep) |