From a54f29e3313c2eb60369055731b0f50bd2ff20a3 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Wed, 11 Apr 2012 01:47:14 +0300 Subject: Convert attack handling code to new format. --- src/game.cpp | 83 ++---------------------------------------------------------- 1 file changed, 2 insertions(+), 81 deletions(-) (limited to 'src/game.cpp') 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(); } /** -- cgit v1.2.3-60-g2f50