mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 17:51:28 +00:00
[Commands] Cleanup #petitems Command (#4005)
- Adds support to `#petitems` to allow you to target bot's pets to view their items, defaults to your pet if you have one. - If you have no pet or no bot pet targeted it won't function.
This commit is contained in:
parent
e640e3cad3
commit
bfeeb0ce05
@ -2,24 +2,65 @@
|
|||||||
|
|
||||||
void command_petitems(Client *c, const Seperator *sep)
|
void command_petitems(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
if (!c->GetPet()) {
|
NPC* t = nullptr;
|
||||||
c->Message(Chat::White, "You must have a pet to use this command.");
|
|
||||||
|
if (c->GetPet()) {
|
||||||
|
t = c->GetPet()->CastToNPC();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (c->GetTarget() && c->GetTarget()->IsNPC()) {
|
||||||
|
t = c->GetTarget()->CastToNPC();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!t || !t->IsPet()) {
|
||||||
|
c->Message(Chat::White, "You must have a pet or target a bot's pet to use this command.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto pet = c->GetPet()->CastToNPC();
|
Mob* o = t->GetOwner();
|
||||||
auto loot_list = pet->GetLootList();
|
if (!o) {
|
||||||
if (!loot_list.empty()) {
|
c->Message(Chat::White, "Invalid owner for pet.");
|
||||||
pet->QueryLoot(c, true);
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
o->IsBot() &&
|
||||||
|
o->CastToBot()->GetBotOwnerCharacterID() != c->CharacterID()
|
||||||
|
) {
|
||||||
|
c->Message(Chat::White, "You do not own the targeted pet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (
|
||||||
|
o->IsClient() &&
|
||||||
|
o->GetID() != c->GetID()
|
||||||
|
) {
|
||||||
|
c->Message(Chat::White, "You do not own the targeted pet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string& pet_owner = (
|
||||||
|
o->IsClient() ?
|
||||||
|
"Your" :
|
||||||
|
fmt::format(
|
||||||
|
"Your bot {}{}",
|
||||||
|
o->GetCleanName(),
|
||||||
|
Strings::EndsWith(o->GetCleanName(), "s") ? "'" : "'s"
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
const auto& l = t->GetLootList();
|
||||||
|
if (!l.empty()) {
|
||||||
|
t->QueryLoot(c, true);
|
||||||
|
}
|
||||||
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Your pet has {} item{}.",
|
"{} pet has {} item{}.",
|
||||||
loot_list.size(),
|
pet_owner,
|
||||||
loot_list.size() != 1 ? "s" : ""
|
l.size(),
|
||||||
|
l.size() != 1 ? "s" : ""
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
} else {
|
|
||||||
c->Message(Chat::White, "Your pet has no items.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user