diff options
-rw-r--r-- | src/game.cpp | 17 | ||||
-rw-r--r-- | src/keyboardconfig.cpp | 1 | ||||
-rw-r--r-- | src/keyboardconfig.h | 1 |
3 files changed, 19 insertions, 0 deletions
diff --git a/src/game.cpp b/src/game.cpp index b56cbdde..c07d6520 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -923,6 +923,23 @@ void Game::handleInput() if (player_node->getTarget()) player_node->attack(player_node->getTarget(), true); } + + if (keyboard.isKeyActive(keyboard.KEY_TARGET_ATTACK)) + { + Being *target = NULL; + + bool newTarget = !keyboard.isKeyActive(keyboard.KEY_TARGET); + // A set target has highest priority + if (!player_node->getTarget()) + { + Uint16 targetX = x, targetY = y; + // Only auto target Monsters + target = beingManager->findNearestLivingBeing(targetX, targetY, + 20, Being::MONSTER); + } + player_node->attack(target, newTarget); + } + #endif // Target the nearest player/monster/npc diff --git a/src/keyboardconfig.cpp b/src/keyboardconfig.cpp index ff05d75b..b5db3de5 100644 --- a/src/keyboardconfig.cpp +++ b/src/keyboardconfig.cpp @@ -43,6 +43,7 @@ static KeyData const keyData[KeyboardConfig::KEY_TOTAL] = { {"keyMoveLeft", SDLK_LEFT, _("Move Left")}, {"keyMoveRight", SDLK_RIGHT, _("Move Right")}, {"keyAttack", SDLK_LCTRL, _("Attack")}, + {"keyTargetAttack", SDLK_x, _("Target & Attack")}, {"keySmilie", SDLK_LALT, _("Smilie")}, {"keyTalk", SDLK_t, _("Talk")}, {"keyTarget", SDLK_LSHIFT, _("Stop Attack")}, diff --git a/src/keyboardconfig.h b/src/keyboardconfig.h index d461c827..68a5efa6 100644 --- a/src/keyboardconfig.h +++ b/src/keyboardconfig.h @@ -154,6 +154,7 @@ class KeyboardConfig KEY_MOVE_LEFT, KEY_MOVE_RIGHT, KEY_ATTACK, + KEY_TARGET_ATTACK, KEY_EMOTE, KEY_TALK, KEY_TARGET, |