feat(Core/Commands): Allow .npc info to use GUID when no target selected (#24922)

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Ryan Turner <16946913+TheSCREWEDSoftware@users.noreply.github.com>
This commit is contained in:
dataCenter430
2026-03-09 13:45:57 -04:00
committed by GitHub
parent 7fc3049449
commit a137dfcb66
2 changed files with 52 additions and 2 deletions

View File

@@ -620,16 +620,38 @@ public:
return true;
}
static bool HandleNpcInfoCommand(ChatHandler* handler)
static bool HandleNpcInfoCommand(ChatHandler* handler, Optional<CreatureSpawnId> 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<HighGuid::Unit>(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();