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 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) (limited to 'src/actions') 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; -- cgit v1.2.3-70-g09d2