mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-03-15 13:35:08 +00:00
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:
@@ -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';
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user