diff options
-rw-r--r-- | src/actions/actions.cpp | 24 | ||||
-rw-r--r-- | src/input/inputactionmap.h | 2 |
2 files changed, 19 insertions, 7 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 8f7ba5579..ce53eaed9 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -731,20 +731,32 @@ impHandler0(targetAttack) if (localPlayer && actorManager) { Being *target = nullptr; - + std::string args = event.args; const bool newTarget = !inputManager.isActionActive( InputAction::STOP_ATTACK); + + if (!args.empty()) + { + if (args[0] != ':') + { + target = actorManager->findNearestByName(args); + } + else + { + target = actorManager->findBeing(atoi(args.substr(1).c_str())); + if (target && target->getType() != ActorType::Monster) + target = nullptr; + } + } + if (!target) + target = localPlayer->getTarget(); // A set target has highest priority - if (!localPlayer->getTarget()) + if (!target) { // Only auto target Monsters target = actorManager->findNearestLivingBeing( localPlayer, 90, ActorType::Monster, true); } - else - { - target = localPlayer->getTarget(); - } localPlayer->attack2(target, newTarget); return true; diff --git a/src/input/inputactionmap.h b/src/input/inputactionmap.h index 030600a38..23d4e6c06 100644 --- a/src/input/inputactionmap.h +++ b/src/input/inputactionmap.h @@ -115,7 +115,7 @@ static const InputActionData inputActionData[InputAction::TOTAL] = { InputCondition::GAME | InputCondition::NOFOLLOW | InputCondition::VALIDSPEED | InputCondition::ALIVE, "targetattack", - false}, + true}, {"keyMoveToTarget", addKey(SDLK_v), emptyKey, |