diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-08-26 19:38:55 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-08-26 20:40:39 +0300 |
commit | a4077c474c370275442982965bb174b2e1e59422 (patch) | |
tree | 86607326f06bb241cb0245d294b3220eacaba5cc /src/actions/actions.cpp | |
parent | 647c1a8b8b02b737b11b1e08af86ecc84f649a81 (diff) | |
download | manaplus-a4077c474c370275442982965bb174b2e1e59422.tar.gz manaplus-a4077c474c370275442982965bb174b2e1e59422.tar.bz2 manaplus-a4077c474c370275442982965bb174b2e1e59422.tar.xz manaplus-a4077c474c370275442982965bb174b2e1e59422.zip |
Move chat command /attack into actions.
Diffstat (limited to 'src/actions/actions.cpp')
-rw-r--r-- | src/actions/actions.cpp | 27 |
1 files changed, 17 insertions, 10 deletions
diff --git a/src/actions/actions.cpp b/src/actions/actions.cpp index 6c5f365af..a46e37347 100644 --- a/src/actions/actions.cpp +++ b/src/actions/actions.cpp @@ -407,14 +407,19 @@ impHandler0(untarget) impHandler0(attack) { - if (localPlayer) - { - Being *const target = localPlayer->getTarget(); - if (target) - localPlayer->attack(target, true); - return true; - } - return false; + if (!localPlayer || !actorManager) + return false; + + Being *target = nullptr; + if (!event.args.empty()) + target = actorManager->findNearestByName(event.args); + if (!target) + target = localPlayer->getTarget(); + else + localPlayer->setTarget(target); + if (target) + localPlayer->attack(target, true); + return true; } impHandler0(targetAttack) @@ -687,9 +692,11 @@ impHandler(undress) if (!actorManager || !localPlayer) return false; - Being *target = localPlayer->getTarget(); - if (!target) + Being *target = nullptr; + if (!event.args.empty()) target = actorManager->findNearestByName(event.args); + if (!target) + target = localPlayer->getTarget(); if (target) Net::getBeingHandler()->undress(target); return true; |