summaryrefslogtreecommitdiff
path: root/src/game.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/game.cpp')
-rw-r--r--src/game.cpp17
1 files changed, 17 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