[Commands] Add #petitems Command. (#1823)

- Add #petitems command to show a person's pet items if they have access to the command.
- Adds a default false parameter to QueryLoot for NPCs that keeps messages and logic from being ran on pets for no reason.
- Cleaned up message a bit for loot and stuff.
- Remove check for loottable ID when using #npcstats for NPCs that get items from a script or otherwise.
This commit is contained in:
Kinglykrab
2021-11-25 14:50:05 -05:00
committed by GitHub
parent d38b8a4867
commit e474b2a280
7 changed files with 65 additions and 34 deletions
+35 -30
View File
@@ -641,18 +641,21 @@ void NPC::ClearItemList() {
SendAppearancePacket(AT_Light, GetActiveLightType());
}
void NPC::QueryLoot(Client* to)
void NPC::QueryLoot(Client* to, bool is_pet_query)
{
if (itemlist.size() > 0) {
to->Message(
Chat::White,
fmt::format(
"Loot | Name: {} ID: {} Loottable ID: {}",
GetName(),
GetNPCTypeID(),
GetLoottableID()
).c_str()
);
if (!itemlist.empty()) {
if (!is_pet_query) {
to->Message(
Chat::White,
fmt::format(
"Loot | {} ({}) ID: {} Loottable ID: {}",
GetName(),
GetID(),
GetNPCTypeID(),
GetLoottableID()
).c_str()
);
}
int item_count = 0;
for (auto current_item : itemlist) {
@@ -674,7 +677,7 @@ void NPC::QueryLoot(Client* to)
to->Message(
Chat::White,
fmt::format(
"Item {} | Name: {} ({}){}",
"Item {} | {} ({}){}",
item_number,
linker.GenerateLink().c_str(),
current_item->item_id,
@@ -692,25 +695,27 @@ void NPC::QueryLoot(Client* to)
}
}
bool has_money = (
platinum > 0 ||
gold > 0 ||
silver > 0 ||
copper > 0
);
if (has_money) {
to->Message(
Chat::White,
fmt::format(
"Money | {}",
ConvertMoneyToString(
platinum,
gold,
silver,
copper
)
).c_str()
if (!is_pet_query) {
bool has_money = (
platinum > 0 ||
gold > 0 ||
silver > 0 ||
copper > 0
);
if (has_money) {
to->Message(
Chat::White,
fmt::format(
"Money | {}",
ConvertMoneyToString(
platinum,
gold,
silver,
copper
)
).c_str()
);
}
}
}