From 4a33c8f11e40457c60d93c28074f98f98ec69b11 Mon Sep 17 00:00:00 2001 From: Gultask <100873791+Gultask@users.noreply.github.com> Date: Thu, 1 Jan 2026 05:42:12 -0300 Subject: [PATCH] feat(Scripts/Commands): Add command ".npc do" for calling DoAction() (#24281) --- .../pending_db_world/rev_1767205751101911600.sql | 8 ++++++++ src/server/game/Miscellaneous/Language.h | 2 ++ src/server/scripts/Commands/cs_npc.cpp | 15 +++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1767205751101911600.sql diff --git a/data/sql/updates/pending_db_world/rev_1767205751101911600.sql b/data/sql/updates/pending_db_world/rev_1767205751101911600.sql new file mode 100644 index 000000000..45b6009cb --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1767205751101911600.sql @@ -0,0 +1,8 @@ +-- +DELETE FROM `acore_string` WHERE `entry` = 603; +INSERT INTO `acore_string` (`entry`, `content_default`) VALUES +(603, 'Do Action performed on [GUID: {}, entry: {}, name: {}] Action: {}'); + +DELETE FROM `command` WHERE `name` = 'npc do'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES +('npc do', 3, 'Syntax: .npc do $action\nRequests the NPC to perform DoAction with the specified ActionID. Used for testing scripts.'); diff --git a/src/server/game/Miscellaneous/Language.h b/src/server/game/Miscellaneous/Language.h index 66268e3b4..7f972a0a9 100644 --- a/src/server/game/Miscellaneous/Language.h +++ b/src/server/game/Miscellaneous/Language.h @@ -671,6 +671,8 @@ enum AcoreStrings LANG_REWARDED = 602, + LANG_NPC_DO_ACTION = 603, + // 603-704 - free LANG_WAIT_BEFORE_SPEAKING = 705, diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 09cc7dd39..66c50537e 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -188,6 +188,7 @@ public: { "whisper", HandleNpcWhisperCommand, SEC_GAMEMASTER, Console::No }, { "yell", HandleNpcYellCommand, SEC_GAMEMASTER, Console::No }, { "tame", HandleNpcTameCommand, SEC_GAMEMASTER, Console::No }, + { "do", HandleNpcDoActionCommand, SEC_GAMEMASTER, Console::No }, { "add", npcAddCommandTable }, { "delete", npcDeleteCommandTable }, { "follow", npcFollowCommandTable }, @@ -1212,6 +1213,20 @@ public: return true; } + static bool HandleNpcDoActionCommand(ChatHandler* handler, uint32 actionId) + { + Creature* creature = handler->getSelectedCreature(); + if (!creature) + { + handler->SendErrorMessage(LANG_SELECT_CREATURE); + return false; + } + + creature->AI()->DoAction(actionId); + handler->PSendSysMessage(LANG_NPC_DO_ACTION, creature->GetGUID().ToString(), creature->GetEntry(), creature->GetName(), actionId); + return true; + } + static bool HandleNpcAddFormationCommand(ChatHandler* handler, ObjectGuid::LowType leaderGUID) { Creature* creature = handler->getSelectedCreature();