[Commands] Cleanup #aggro Command. (#1799)

- Cleanup messages and logic.
- Cleanup constant names and references.
- Cleanup aggro description methods.
This commit is contained in:
Kinglykrab
2021-11-21 10:12:12 -05:00
committed by GitHub
parent 04fda24c8e
commit b9214bfdee
16 changed files with 512 additions and 319 deletions
+19 -12
View File
@@ -2,20 +2,27 @@
void command_aggro(Client *c, const Seperator *sep)
{
if (c->GetTarget() == nullptr || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "Error: you must have an NPC target.");
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #aggro [Distance] [-v] (-v is verbose Faction Information)");
return;
}
float d = atof(sep->arg[1]);
if (d == 0.0f) {
c->Message(Chat::Red, "Error: distance argument required.");
return;
}
bool verbose = false;
if (sep->arg[2][0] == '-' && sep->arg[2][1] == 'v' && sep->arg[2][2] == '\0') {
verbose = true;
}
entity_list.DescribeAggro(c, c->GetTarget()->CastToNPC(), d, verbose);
if (
!c->GetTarget() ||
(
c->GetTarget() &&
!c->GetTarget()->IsNPC()
)
) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
NPC* target = c->GetTarget()->CastToNPC();
float distance = std::stof(sep->arg[1]);
bool verbose = !strcasecmp("-v", sep->arg[2]);
entity_list.DescribeAggro(c, target, distance, verbose);
}