[Commands] Cleanup #wpinfo Command. (#1866)

- Cleanup message and logic.
- Only display grid/waypoints if NPC has a grid.
This commit is contained in:
Kinglykrab
2021-12-04 21:53:29 -05:00
committed by GitHub
parent aa4536e1ef
commit 8ec4afe721
6 changed files with 78 additions and 37 deletions
+17 -6
View File
@@ -2,14 +2,25 @@
void command_wpinfo(Client *c, const Seperator *sep)
{
Mob *t = c->GetTarget();
if (t == nullptr || !t->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this.");
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
NPC *n = t->CastToNPC();
n->DisplayWaypointInfo(c);
auto target = c->GetTarget()->CastToNPC();
if (!target->GetGrid()) {
c->Message(
Chat::White,
fmt::format(
"{} ({}) is not a part of any grid.",
target->GetCleanName(),
target->GetID()
).c_str()
);
return;
}
target->DisplayWaypointInfo(c);
}