diff options
author | Andrei Karas <akaras@inbox.ru> | 2011-11-09 23:45:52 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2011-11-09 23:45:52 +0300 |
commit | d811b764c763bb4ed48dc1d2444c47a1c28e94a5 (patch) | |
tree | 9f05fda7d6edf71f823c23a11c0d87d2df8c0e89 /src/game.cpp | |
parent | 4faba7f0df6abf47477d5408637103cd61df68a6 (diff) | |
download | plus-d811b764c763bb4ed48dc1d2444c47a1c28e94a5.tar.gz plus-d811b764c763bb4ed48dc1d2444c47a1c28e94a5.tar.bz2 plus-d811b764c763bb4ed48dc1d2444c47a1c28e94a5.tar.xz plus-d811b764c763bb4ed48dc1d2444c47a1c28e94a5.zip |
Fix joystick attack (button 0).
Add stop attack action to joystick (button 4).
Diffstat (limited to 'src/game.cpp')
-rw-r--r-- | src/game.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/game.cpp b/src/game.cpp index a6d79658c..e2a401d80 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -1580,19 +1580,22 @@ void Game::handleInput() } } - if (((player_node->getAttackType() == 0 + bool joyAttack(false); + if (joystick && joystick->buttonPressed(0)) + joyAttack = true; + + if ((((player_node->getAttackType() == 0 && player_node->getFollow().empty()) || event.type == SDL_KEYDOWN) - && mValidSpeed) + || joyAttack) && mValidSpeed) { // Attacking monsters - if (keyboard.isKeyActive(keyboard.KEY_ATTACK) || - (joystick && joystick->buttonPressed(0))) + if (keyboard.isKeyActive(keyboard.KEY_ATTACK)) { if (player_node->getTarget()) player_node->attack(player_node->getTarget(), true); } - if (keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) + if ((keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK) || joyAttack) && !keyboard.isKeyActive(keyboard.KEY_MOVE_TO_TARGET)) { Being *target = nullptr; @@ -1676,10 +1679,15 @@ void Game::handleInput() if (!keyboard.isKeyActive(keyboard.KEY_ATTACK) && !keyboard.isKeyActive(keyboard.KEY_EMOTE)) { - if (keyboard.isKeyActive(keyboard.KEY_TARGET)) + if (keyboard.isKeyActive(keyboard.KEY_TARGET) + || (joystick && joystick->buttonPressed(4))) + { player_node->stopAttack(); + } else if (keyboard.isKeyActive(keyboard.KEY_UNTARGET)) + { player_node->untarget(); + } } if (joystick) |