From b0b085453510ae5922e6f819a22f7cf46354036e Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Mon, 19 Jan 2015 00:56:45 +0300 Subject: Extend chat command /tagetattack to support mob name parameter. --- src/actions/actions.cpp | 24 ++++++++++++++++++------ 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, -- cgit v1.2.3-70-g09d2