From 97b54e33f09eb9b0417bafce18ea163af89009bb Mon Sep 17 00:00:00 2001 From: Joseph Botosh Date: Mon, 12 Nov 2012 19:12:22 +0300 Subject: Added /atkhuman command --- src/commandhandler.cpp | 21 +++++++++++++++++++++ src/commandhandler.h | 4 ++++ 2 files changed, 25 insertions(+) diff --git a/src/commandhandler.cpp b/src/commandhandler.cpp index 001c50e6b..83078f49b 100644 --- a/src/commandhandler.cpp +++ b/src/commandhandler.cpp @@ -152,6 +152,8 @@ void CommandHandler::handleCommand(const std::string &command, handleMove(args, tab); else if (type == "target") handleTarget(args, tab); + else if (type == "atkhuman") + handleAttackHuman(args, tab); else if (type == "outfit") handleOutfit(args, tab); else if (type == "emote") @@ -709,6 +711,25 @@ void CommandHandler::handleTarget(const std::string &args, player_node->setTarget(target); } +void CommandHandler::handleAttackHuman(const std::string &args, + ChatTab *const tab A_UNUSED) +{ + if (!actorSpriteManager || !player_node) + return; + + Being *const target = actorSpriteManager->findNearestLivingBeing( + player_node, 10, ActorSprite::PLAYER); + if (target) + { + if (player_node->checAttackPermissions(target)) + { + player_node->setTarget(target); + player_node->attack2(target, true); + } + } +} + + void CommandHandler::handleCloseAll(const std::string &args A_UNUSED, ChatTab *const tab A_UNUSED) { diff --git a/src/commandhandler.h b/src/commandhandler.h index 5a73b2335..228682783 100644 --- a/src/commandhandler.h +++ b/src/commandhandler.h @@ -219,6 +219,10 @@ class CommandHandler final * Handle target command. */ static void handleTarget(const std::string &args, ChatTab *const tab); + /** + * Handle atkhuman command. + */ + static void handleAttackHuman(const std::string &args, ChatTab *const tab); /** * Handle closeall command. -- cgit v1.2.3-70-g09d2