diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-01-19 00:56:45 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-01-19 00:56:45 +0300 |
commit | b0b085453510ae5922e6f819a22f7cf46354036e (patch) | |
tree | d867dc5a84949311864d45b1f78be7c4f9dfa748 /src/actions/actions.cpp | |
parent | 21fbfa417e0ab5fee402e9c97b5220dc713c0a53 (diff) | |
download | mv-b0b085453510ae5922e6f819a22f7cf46354036e.tar.gz mv-b0b085453510ae5922e6f819a22f7cf46354036e.tar.bz2 mv-b0b085453510ae5922e6f819a22f7cf46354036e.tar.xz mv-b0b085453510ae5922e6f819a22f7cf46354036e.zip |
Extend chat command /tagetattack to support mob name parameter.
Diffstat (limited to 'src/actions/actions.cpp')
-rw-r--r-- | src/actions/actions.cpp | 24 |
1 files changed, 18 insertions, 6 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; |