[Commands] Cleanup #shownpcgloballoot and #showzonegloballoot Command. (#2141)

- Cleanup messages and logic.
This commit is contained in:
Kinglykrab 2022-05-06 19:50:03 -04:00 committed by GitHub
parent 5aaaaed6f1
commit e5acc7c322
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 70 additions and 16 deletions

View File

@ -340,11 +340,11 @@ int command_init(void)
command_add("showbonusstats", "[item|spell|all] Shows bonus stats for target from items or spells. Shows both by default.", AccountStatus::Guide, command_showbonusstats) ||
command_add("showbuffs", "- List buffs active on your target or you if no target", AccountStatus::Guide, command_showbuffs) ||
command_add("shownumhits", "Shows buffs numhits for yourself.", AccountStatus::Player, command_shownumhits) ||
command_add("shownpcgloballoot", "Show GlobalLoot entires on this npc", AccountStatus::Guide, command_shownpcgloballoot) ||
command_add("shownpcgloballoot", "Show global loot entries for your target NPC", AccountStatus::Guide, command_shownpcgloballoot) ||
command_add("showskills", "[Start Skill ID] [All] - Show the values of your or your player target's skills in a popup 50 at a time, use 'all' as second argument to show non-usable skill's values", AccountStatus::Guide, command_showskills) ||
command_add("showspellslist", "Shows spell list of targeted NPC", AccountStatus::GMAdmin, command_showspellslist) ||
command_add("showstats", "- Show details about you or your target", AccountStatus::Guide, command_showstats) ||
command_add("showzonegloballoot", "Show GlobalLoot entires on this zone", AccountStatus::Guide, command_showzonegloballoot) ||
command_add("showzonegloballoot", "Show global loot entries for your current zone", AccountStatus::Guide, command_showzonegloballoot) ||
command_add("showzonepoints", "Show zone points for current zone", AccountStatus::Guide, command_showzonepoints) ||
command_add("shutdown", "- Shut this zone process down", AccountStatus::GMLeadAdmin, command_shutdown) ||
command_add("spawn", "[name] [race] [level] [material] [hp] [gender] [class] [priweapon] [secweapon] [merchantid] - Spawn an NPC", AccountStatus::Steward, command_spawn) ||

View File

@ -23,15 +23,59 @@ std::vector<int> GlobalLootManager::GetGlobalLootTables(NPC *mob) const
void GlobalLootManager::ShowZoneGlobalLoot(Client *to) const
{
for (auto &e : m_entries)
to->Message(Chat::White, " %s : %d table %d", e.GetDescription().c_str(), e.GetID(), e.GetLootTableID());
int table_number = 1;
for (auto &e : m_entries) {
to->Message(
Chat::White,
fmt::format(
"Table {} | Name: {}",
table_number,
e.GetDescription()
).c_str()
);
to->Message(
Chat::White,
fmt::format(
"Table {} | Global Table ID: {} Loot Table ID: {}",
table_number,
e.GetID(),
e.GetLootTableID()
).c_str()
);
table_number++;
}
}
void GlobalLootManager::ShowNPCGlobalLoot(Client *to, NPC *who) const
{
int table_number = 1;
for (auto &e : m_entries) {
if (e.PassesRules(who))
to->Message(Chat::White, " %s : %d table %d", e.GetDescription().c_str(), e.GetID(), e.GetLootTableID());
if (e.PassesRules(who)) {
to->Message(
Chat::White,
fmt::format(
"Table {} | Name: {}",
table_number,
e.GetDescription()
).c_str()
);
to->Message(
Chat::White,
fmt::format(
"Table {} | Global Table ID: {} Loot Table ID: {}",
table_number,
e.GetID(),
e.GetLootTableID()
).c_str()
);
table_number++;
}
}
}

View File

@ -2,15 +2,22 @@
void command_shownpcgloballoot(Client *c, const Seperator *sep)
{
auto tar = c->GetTarget();
if (!tar || !tar->IsNPC()) {
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
auto npc = tar->CastToNPC();
c->Message(Chat::White, "GlobalLoot for %s (%d)", npc->GetName(), npc->GetNPCTypeID());
zone->ShowNPCGlobalLoot(c, npc);
auto target = c->GetTarget()->CastToNPC();
c->Message(
Chat::White,
fmt::format(
"Global loot for {} ({}).",
target->GetCleanName(),
target->GetNPCTypeID()
).c_str()
);
zone->ShowNPCGlobalLoot(c, target);
}

View File

@ -4,10 +4,13 @@ void command_showzonegloballoot(Client *c, const Seperator *sep)
{
c->Message(
Chat::White,
"GlobalLoot for %s (%d:%d)",
zone->GetShortName(),
zone->GetZoneID(),
zone->GetInstanceVersion());
fmt::format(
"Global loot for {} ({}).",
zone->GetLongName(),
zone->GetZoneID()
).c_str()
);
zone->ShowZoneGlobalLoot(c);
}