diff --git a/data/sql/updates/pending_db_world/rev_1772367957624909900.sql b/data/sql/updates/pending_db_world/rev_1772367957624909900.sql new file mode 100644 index 000000000..0c3273f9f --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1772367957624909900.sql @@ -0,0 +1,3 @@ +-- Update .npc info help text for optional GUID support +UPDATE `command` SET `help` = 'Syntax: .npc info [#creature_guid]\r\n\r\nDisplay a list of details for the selected creature, or for the creature with the given GUID if no target is selected.\r\n\r\nWhen a creature is targeted or found in the current map, the list includes:\r\n- GUID, Faction, NPC flags, Entry ID, Model ID,\r\n- Level,\r\n- Health (current/maximum),\r\n- Field flags, dynamic flags, faction template,\r\n- Position information,\r\n- and the creature type, e.g. if the creature is a vendor.\r\n\r\nWhen only a GUID is given and the creature is not in the current map, DB-stored data is shown (spawn ID, entry, phase, position, map, etc.).' +WHERE `name` = 'npc info'; diff --git a/src/server/scripts/Commands/cs_npc.cpp b/src/server/scripts/Commands/cs_npc.cpp index 99f3973d8..ce6b78213 100644 --- a/src/server/scripts/Commands/cs_npc.cpp +++ b/src/server/scripts/Commands/cs_npc.cpp @@ -620,16 +620,38 @@ public: return true; } - static bool HandleNpcInfoCommand(ChatHandler* handler) + static bool HandleNpcInfoCommand(ChatHandler* handler, Optional spawnIdArg) { Creature* target = handler->getSelectedCreature(); + ObjectGuid::LowType lowGuid = 0; - if (!target) + if (spawnIdArg) + lowGuid = *spawnIdArg; + + if (!target && lowGuid) + target = handler->GetCreatureFromPlayerMapByDbGuid(lowGuid); + + if (target) + return HandleNpcInfoCommandShowCreature(handler, target); + + if (!lowGuid) { handler->SendErrorMessage(LANG_SELECT_CREATURE); return false; } + CreatureData const* cData = sObjectMgr->GetCreatureData(lowGuid); + if (!cData) + cData = sObjectMgr->LoadCreatureDataFromDB(lowGuid); + if (cData) + return HandleNpcInfoCommandShowFromDB(handler, lowGuid, cData); + + handler->SendErrorMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid); + return false; + } + + static bool HandleNpcInfoCommandShowCreature(ChatHandler* handler, Creature* target) + { CreatureTemplate const* cInfo = target->GetCreatureTemplate(); uint32 faction = target->GetFaction(); uint32 npcflags = target->GetNpcFlags(); @@ -695,6 +717,31 @@ public: return true; } + + static bool HandleNpcInfoCommandShowFromDB(ChatHandler* handler, ObjectGuid::LowType lowGuid, CreatureData const* cData) + { + CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(cData->id1); + if (!cInfo) + { + handler->SendErrorMessage(LANG_COMMAND_CREATGUIDNOTFOUND, lowGuid); + return false; + } + + handler->PSendSysMessage("(Not in world - showing DB data)"); + uint32 scriptId = cData->ScriptId ? cData->ScriptId : cInfo->ScriptID; + handler->PSendSysMessage(LANG_NPCINFO_CHAR, lowGuid, ObjectGuid::Create(cData->id1, lowGuid).ToString(), cData->id1, + cData->id2, cData->id3, cData->displayid, cData->displayid, cInfo->faction, + cData->npcflag); + handler->PSendSysMessage(LANG_NPCINFO_PHASEMASK, cData->phaseMask); + handler->PSendSysMessage(LANG_NPCINFO_POSITION, cData->posX, cData->posY, cData->posZ); + handler->PSendSysMessage("Map: {} Spawn time: {}s", cData->mapid, + cData->spawntimesecs); + handler->PSendSysMessage(LANG_NPCINFO_EQUIPMENT, cData->equipmentId, cData->equipmentId); + handler->PSendSysMessage(LANG_NPCINFO_AIINFO, cInfo->AIName, + sObjectMgr->GetScriptName(scriptId)); + return true; + } + static bool HandleNpcGuidCommand(ChatHandler* handler) { Creature* target = handler->getSelectedCreature();