feat(Core/Commands): add .npc showloot to display corpse loot (#26374)

This commit is contained in:
Kitzunu
2026-07-04 23:01:54 +02:00
committed by GitHub
parent 3586fc9593
commit 8cca034053
3 changed files with 70 additions and 1 deletions
@@ -0,0 +1,14 @@
--
-- Issue #18038: add .npc showloot command entry and matching acore_string rows.
DELETE FROM `command` WHERE `name` = 'npc showloot';
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('npc showloot', 2, 'Syntax: .npc showloot\nShows the loot generated on the selected creature''s corpse.');
DELETE FROM `acore_string` WHERE `entry` IN (35456, 35457, 35458, 35459, 35460, 35461);
INSERT INTO `acore_string` (`entry`, `content_default`, `locale_koKR`, `locale_frFR`, `locale_deDE`, `locale_zhCN`, `locale_zhTW`, `locale_esES`, `locale_esMX`, `locale_ruRU`) VALUES
(35456, '{} is not dead, or its corpse contains no loot.', '{}이(가) 죽지 않았거나 시체에 전리품이 없습니다.', '{} n''est pas mort, ou son cadavre ne contient aucun butin.', '{} ist nicht tot, oder sein Leichnam enthält keine Beute.', '{} 未死亡,或其尸体上没有战利品。', '{} 未死亡,或其屍體上沒有戰利品。', '{} no está muerto, o su cadáver no contiene botín.', '{} no está muerto, o su cadáver no contiene botín.', '{} не убит или его труп не содержит добычи.'),
(35457, 'Loot for {} (Entry: {}):', '{} (ID: {})의 전리품:', 'Butin de {} (ID : {}) :', 'Beute von {} (ID: {}):', '{} (ID: {}) 的战利品:', '{} (ID: {}) 的戰利品:', 'Botín de {} (ID: {}):', 'Botín de {} (ID: {}):', 'Добыча с {} (ID: {}):'),
(35458, 'Money: {}g {}s {}c', '돈: {}금 {}은 {}동', 'Argent : {}po {}pa {}pc', 'Geld: {}G {}S {}K', '金币: {}金 {}银 {}铜', '金幣:{}金 {}銀 {}銅', 'Dinero: {}o {}p {}c', 'Dinero: {}o {}p {}c', 'Деньги: {}зол {}сер {}мед'),
(35459, 'Items ({}):', '아이템 ({}):', 'Objets ({}) :', 'Gegenstände ({}):', '物品 ({})', '物品 ({})', 'Objetos ({}):', 'Objetos ({}):', 'Предметы ({}):'),
(35460, ' {}x |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (Entry: {})', ' {}개 |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})', ' {}x |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID : {})', ' {}x |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})', ' {}个 |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})', ' {}個 |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})', ' {}x |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})', ' {}x |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})', ' {}шт. |c{:08x}|Hitem:{}:0:0:0:0:0:0:0:0|h[{}]|h|r (ID: {})'),
(35461, 'Quest items ({}):', '퀘스트 아이템 ({}):', 'Objets de quête ({}) :', 'Questgegenstände ({}):', '任务物品 ({})', '任務物品 ({})', 'Objetos de misión ({}):', 'Objetos de misión ({}):', 'Предметы заданий ({}):');
+10 -1
View File
@@ -1520,6 +1520,15 @@ enum AcoreStrings
LANG_PET_RENAME_SUCCESS = 35454,
// Wintergrasp shutdown deferral
LANG_WG_SHUTDOWN_DEFERRED = 35455
LANG_WG_SHUTDOWN_DEFERRED = 35455,
// npc showloot command
LANG_COMMAND_NOT_DEAD_OR_NO_LOOT = 35456,
LANG_COMMAND_NPC_SHOWLOOT_HEADER = 35457,
LANG_COMMAND_NPC_SHOWLOOT_MONEY = 35458,
LANG_COMMAND_NPC_SHOWLOOT_ITEMS = 35459,
LANG_COMMAND_NPC_SHOWLOOT_ENTRY = 35460,
LANG_COMMAND_NPC_SHOWLOOT_QUEST = 35461
};
#endif
+46
View File
@@ -24,6 +24,7 @@
#include "GridNotifiers.h"
#include "GridNotifiersImpl.h"
#include "Language.h"
#include "LootMgr.h"
#include "MapMgr.h"
#include "ObjectMgr.h"
#include "Pet.h"
@@ -201,6 +202,7 @@ public:
{ "follow", npcFollowCommandTable },
{ "load", HandleNpcLoadCommand, SEC_ADMINISTRATOR, Console::Yes },
{ "set", npcSetCommandTable },
{ "showloot", HandleNpcShowLootCommand, rbac::RBAC_PERM_COMMAND_NPC_SHOWLOOT, Console::No },
{ "spawngroup", HandleNpcSpawnGroupCommand, SEC_ADMINISTRATOR, Console::No },
{ "despawngroup", HandleNpcDespawnGroupCommand, SEC_ADMINISTRATOR, Console::No }
};
@@ -1490,6 +1492,50 @@ public:
return true;
}
static void ShowLootEntry(ChatHandler* handler, LootItem const& item)
{
ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(item.itemid);
std::string name = itemTemplate ? itemTemplate->Name1 : "Unknown item";
if (itemTemplate)
if (ItemLocale const* il = sObjectMgr->GetItemLocale(item.itemid))
ObjectMgr::GetLocaleString(il->Name, handler->GetSessionDbLocaleIndex(), name);
uint32 color = ItemQualityColors[itemTemplate ? itemTemplate->Quality : uint32(ITEM_QUALITY_POOR)];
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_ENTRY, item.count, color, item.itemid, name, item.itemid);
}
static bool HandleNpcShowLootCommand(ChatHandler* handler)
{
Creature* creatureTarget = handler->getSelectedCreature();
if (!creatureTarget || creatureTarget->IsPet())
{
handler->SendErrorMessage(LANG_SELECT_CREATURE);
return false;
}
Loot const& loot = creatureTarget->loot;
if (!creatureTarget->isDead() || (loot.empty() && loot.quest_items.empty()))
{
handler->SendErrorMessage(LANG_COMMAND_NOT_DEAD_OR_NO_LOOT, creatureTarget->GetName());
return false;
}
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_HEADER, creatureTarget->GetName(), creatureTarget->GetEntry());
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_MONEY, loot.gold / GOLD, (loot.gold % GOLD) / SILVER, loot.gold % SILVER);
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_ITEMS, loot.items.size());
for (LootItem const& item : loot.items)
if (!item.is_looted)
ShowLootEntry(handler, item);
handler->PSendSysMessage(LANG_COMMAND_NPC_SHOWLOOT_QUEST, loot.quest_items.size());
for (LootItem const& item : loot.quest_items)
if (!item.is_looted)
ShowLootEntry(handler, item);
return true;
}
};
void AddSC_npc_commandscript()