From b7353ce9b297d644afb59e24ad3d1e29a99c96d3 Mon Sep 17 00:00:00 2001 From: neifion-00000000 <91289495+neifion-00000000@users.noreply.github.com> Date: Tue, 19 Jul 2022 23:04:23 -0500 Subject: [PATCH] feat(Core/Commands): Introduce .npc guid (#12440) --- .../rev_1658266226251855400.sql | 3 ++ src/server/scripts/Commands/cs_npc.cpp | 31 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 data/sql/updates/pending_db_world/rev_1658266226251855400.sql diff --git a/data/sql/updates/pending_db_world/rev_1658266226251855400.sql b/data/sql/updates/pending_db_world/rev_1658266226251855400.sql new file mode 100644 index 000000000..cb1b6a970 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1658266226251855400.sql @@ -0,0 +1,3 @@ +-- +DELETE FROM `command` WHERE `name` = 'npc guid'; +INSERT INTO `command` (`name`, `security`, `help`) VALUES ('npc guid', 1, 'Syntax: .npc guid\r\n\r\nDisplays GUID, faction, NPC flags, Entry ID, Model ID for selected creature.'); diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index d722a5478..83c5fbeb0 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -186,6 +186,7 @@ public: static ChatCommandTable npcCommandTable = { { "info", HandleNpcInfoCommand, SEC_GAMEMASTER, Console::No }, + { "guid", HandleNpcGuidCommand, SEC_GAMEMASTER, Console::No }, { "near", HandleNpcNearCommand, SEC_GAMEMASTER, Console::No }, { "move", HandleNpcMoveCommand, SEC_GAMEMASTER, Console::No }, { "playemote", HandleNpcPlayEmoteCommand, SEC_GAMEMASTER, Console::No }, @@ -651,6 +652,36 @@ public: return true; } + static bool HandleNpcGuidCommand(ChatHandler* handler) + { + Creature* target = handler->getSelectedCreature(); + + if (!target) + { + handler->SendSysMessage(LANG_SELECT_CREATURE); + handler->SetSentErrorMessage(true); + return false; + } + + uint32 faction = target->GetFaction(); + uint32 npcflags = target->GetNpcFlags(); + uint32 displayid = target->GetDisplayId(); + uint32 nativeid = target->GetNativeDisplayId(); + uint32 entry = target->GetEntry(); + uint32 id1 = 0; + uint32 id2 = 0; + uint32 id3 = 0; + if (CreatureData const* cData = target->GetCreatureData()) + { + id1 = cData->id1; + id2 = cData->id2; + id3 = cData->id3; + } + + handler->PSendSysMessage(LANG_NPCINFO_CHAR, target->GetSpawnId(), target->GetGUID().GetCounter(), entry, id1, id2, id3, displayid, nativeid, faction, npcflags); + + return true; + } static bool HandleNpcNearCommand(ChatHandler* handler, Optional dist) {