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 | |
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')
-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, |