diff options
author | Andrei Karas <akaras@inbox.ru> | 2012-04-11 01:47:14 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2012-04-11 01:51:41 +0300 |
commit | a54f29e3313c2eb60369055731b0f50bd2ff20a3 (patch) | |
tree | 4d0c59fb180063f9e0933a2c6ee61bc387609d87 /src/game.cpp | |
parent | 9be7d0ac1127477a5ff5ffb3fb3dd45487eec213 (diff) | |
download | manaplus-a54f29e3313c2eb60369055731b0f50bd2ff20a3.tar.gz manaplus-a54f29e3313c2eb60369055731b0f50bd2ff20a3.tar.bz2 manaplus-a54f29e3313c2eb60369055731b0f50bd2ff20a3.tar.xz manaplus-a54f29e3313c2eb60369055731b0f50bd2ff20a3.zip |
Convert attack handling code to new format.
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 83 |
1 files changed, 2 insertions, 81 deletions
diff --git a/src/game.cpp b/src/game.cpp index 68d637829..902411f69 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -709,7 +709,7 @@ void Game::resetAdjustLevel() mAdjustLevel = 0; } -void Game::handleMoveAndAttack() +void Game::handleMove() { // Moving player around if (player_node->isAlive() && !Being::isTalking() @@ -783,85 +783,6 @@ void Game::handleMoveAndAttack() viewport->moveCamera(dx, dy); } } - - bool joyAttack(false); - if (joystick && joystick->buttonPressed(0)) - joyAttack = true; - - if ((player_node->getFollow().empty() || joyAttack) && mValidSpeed) - { - // Attacking monsters - if (inputManager.isActionActive(Input::KEY_ATTACK)) - { - if (player_node->getTarget()) - player_node->attack(player_node->getTarget(), true); - } - - if ((inputManager.isActionActive(Input::KEY_TARGET_ATTACK) - || joyAttack) - /*&& !inputManager.isActionActive(Input::KEY_MOVE_TO_TARGET)*/ - ) - { - Being *target = nullptr; - - bool newTarget = !inputManager.isActionActive( - Input::KEY_STOP_ATTACK); - // A set target has highest priority - if (!player_node->getTarget()) - { - // Only auto target Monsters - target = actorSpriteManager->findNearestLivingBeing( - player_node, 90, ActorSprite::MONSTER); - } - else - { - target = player_node->getTarget(); - } - - player_node->attack2(target, newTarget); - } - } - - if (!inputManager.isActionActive(Input::KEY_EMOTE)) - { - // Target the nearest player/monster/npc - if ((inputManager.isActionActive(Input::KEY_TARGET_PLAYER) || - inputManager.isActionActive(Input::KEY_TARGET_CLOSEST) || - inputManager.isActionActive(Input::KEY_TARGET_NPC) || - (joystick && joystick->buttonPressed(3))) && - !inputManager.isActionActive(Input::KEY_STOP_ATTACK) && - !inputManager.isActionActive(Input::KEY_UNTARGET)) - { - ActorSprite::Type currentTarget = ActorSprite::UNKNOWN; - if (inputManager.isActionActive(Input::KEY_TARGET_CLOSEST) || - (joystick && joystick->buttonPressed(3))) - { - currentTarget = ActorSprite::MONSTER; - } - else if (inputManager.isActionActive(Input::KEY_TARGET_PLAYER)) - { - currentTarget = ActorSprite::PLAYER; - } - else if (inputManager.isActionActive(Input::KEY_TARGET_NPC)) - { - currentTarget = ActorSprite::NPC; - } - - Being *target = actorSpriteManager->findNearestLivingBeing( - player_node, 20, currentTarget); - - if (target && (target != player_node->getTarget() || - currentTarget != mLastTarget)) - { - player_node->setTarget(target); - mLastTarget = currentTarget; - } - } - else - { - mLastTarget = ActorSprite::UNKNOWN; // Reset last target - } - } } } @@ -967,7 +888,7 @@ void Game::handleInput() return; } - handleMoveAndAttack(); + handleMove(); } /** |