[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 65 additions and 34 deletions

View File

@ -440,6 +440,7 @@ SET(gm_commands
gm_commands/permaclass.cpp gm_commands/permaclass.cpp
gm_commands/permagender.cpp gm_commands/permagender.cpp
gm_commands/permarace.cpp gm_commands/permarace.cpp
gm_commands/petitems.cpp
gm_commands/petitioninfo.cpp gm_commands/petitioninfo.cpp
gm_commands/petname.cpp gm_commands/petname.cpp
gm_commands/pf.cpp gm_commands/pf.cpp

View File

@ -277,6 +277,7 @@ int command_init(void)
command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) || command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) ||
command_add("permagender", "[Gender ID] - Change your or your player target's gender", AccountStatus::QuestTroupe, command_permagender) || command_add("permagender", "[Gender ID] - Change your or your player target's gender", AccountStatus::QuestTroupe, command_permagender) ||
command_add("permarace", "[Race ID] - Change your or your player target's race", AccountStatus::QuestTroupe, command_permarace) || command_add("permarace", "[Race ID] - Change your or your player target's race", AccountStatus::QuestTroupe, command_permarace) ||
command_add("petitems", "- View your pet's items if you have one", AccountStatus::ApprenticeGuide, command_petitems) ||
command_add("petitioninfo", "[petition number] - Get info about a petition", AccountStatus::ApprenticeGuide, command_petitioninfo) || command_add("petitioninfo", "[petition number] - Get info about a petition", AccountStatus::ApprenticeGuide, command_petitioninfo) ||
command_add("pf", "- Display additional mob coordinate and wandering data", AccountStatus::Player, command_pf) || command_add("pf", "- Display additional mob coordinate and wandering data", AccountStatus::Player, command_pf) ||
command_add("picklock", "Analog for ldon pick lock for the newer clients since we still don't have it working.", AccountStatus::Player, command_picklock) || command_add("picklock", "Analog for ldon pick lock for the newer clients since we still don't have it working.", AccountStatus::Player, command_picklock) ||

View File

@ -193,6 +193,7 @@ void command_peqzone(Client *c, const Seperator *sep);
void command_permaclass(Client *c, const Seperator *sep); void command_permaclass(Client *c, const Seperator *sep);
void command_permagender(Client *c, const Seperator *sep); void command_permagender(Client *c, const Seperator *sep);
void command_permarace(Client *c, const Seperator *sep); void command_permarace(Client *c, const Seperator *sep);
void command_petitems(Client *c, const Seperator *sep);
void command_petitioninfo(Client *c, const Seperator *sep); void command_petitioninfo(Client *c, const Seperator *sep);
void command_picklock(Client *c, const Seperator *sep); void command_picklock(Client *c, const Seperator *sep);
void command_profanity(Client *c, const Seperator *sep); void command_profanity(Client *c, const Seperator *sep);

View File

@ -9,9 +9,7 @@ void command_npcstats(Client *c, const Seperator *sep)
target->ShowStats(c); target->ShowStats(c);
// Loot Data // Loot Data
if (target->GetLoottableID()) { target->QueryLoot(c);
target->QueryLoot(c);
}
} }
else { else {
c->Message(Chat::White, "You must target an NPC to use this command."); c->Message(Chat::White, "You must target an NPC to use this command.");

View File

@ -0,0 +1,25 @@
#include "../client.h"
void command_petitems(Client *c, const Seperator *sep)
{
if (!c->GetPet()) {
c->Message(Chat::White, "You must have a pet to use this command.");
return;
}
auto pet = c->GetPet()->CastToNPC();
auto loot_list = pet->GetLootList();
if (!loot_list.empty()) {
pet->QueryLoot(c, true);
c->Message(
Chat::White,
fmt::format(
"Your pet has {} item{}.",
loot_list.size(),
loot_list.size() != 1 ? "s" : ""
).c_str()
);
} else {
c->Message(Chat::White, "Your pet has no items.");
}
}

View File

@ -641,18 +641,21 @@ void NPC::ClearItemList() {
SendAppearancePacket(AT_Light, GetActiveLightType()); SendAppearancePacket(AT_Light, GetActiveLightType());
} }
void NPC::QueryLoot(Client* to) void NPC::QueryLoot(Client* to, bool is_pet_query)
{ {
if (itemlist.size() > 0) { if (!itemlist.empty()) {
to->Message( if (!is_pet_query) {
Chat::White, to->Message(
fmt::format( Chat::White,
"Loot | Name: {} ID: {} Loottable ID: {}", fmt::format(
GetName(), "Loot | {} ({}) ID: {} Loottable ID: {}",
GetNPCTypeID(), GetName(),
GetLoottableID() GetID(),
).c_str() GetNPCTypeID(),
); GetLoottableID()
).c_str()
);
}
int item_count = 0; int item_count = 0;
for (auto current_item : itemlist) { for (auto current_item : itemlist) {
@ -674,7 +677,7 @@ void NPC::QueryLoot(Client* to)
to->Message( to->Message(
Chat::White, Chat::White,
fmt::format( fmt::format(
"Item {} | Name: {} ({}){}", "Item {} | {} ({}){}",
item_number, item_number,
linker.GenerateLink().c_str(), linker.GenerateLink().c_str(),
current_item->item_id, current_item->item_id,
@ -692,25 +695,27 @@ void NPC::QueryLoot(Client* to)
} }
} }
bool has_money = ( if (!is_pet_query) {
platinum > 0 || bool has_money = (
gold > 0 || platinum > 0 ||
silver > 0 || gold > 0 ||
copper > 0 silver > 0 ||
); copper > 0
if (has_money) {
to->Message(
Chat::White,
fmt::format(
"Money | {}",
ConvertMoneyToString(
platinum,
gold,
silver,
copper
)
).c_str()
); );
if (has_money) {
to->Message(
Chat::White,
fmt::format(
"Money | {}",
ConvertMoneyToString(
platinum,
gold,
silver,
copper
)
).c_str()
);
}
} }
} }

View File

@ -203,7 +203,7 @@ public:
void AddCash(uint16 in_copper, uint16 in_silver, uint16 in_gold, uint16 in_platinum); void AddCash(uint16 in_copper, uint16 in_silver, uint16 in_gold, uint16 in_platinum);
void AddCash(); void AddCash();
void RemoveCash(); void RemoveCash();
void QueryLoot(Client* to); void QueryLoot(Client* to, bool is_pet_query = false);
bool HasItem(uint32 item_id); bool HasItem(uint32 item_id);
uint16 CountItem(uint32 item_id); uint16 CountItem(uint32 item_id);
uint32 GetItemIDBySlot(uint16 loot_slot); uint32 GetItemIDBySlot(uint16 loot_slot);