[Commands] Cleanup #sensetrap Command. (#2137)

* [Commands] Cleanup #sensetrap Command.
- Cleanup messages and logic.

* Update sensetrap.cpp
This commit is contained in:
Kinglykrab 2022-05-06 20:01:29 -04:00 committed by GitHub
parent a0ed0d57c5
commit 132c936c90
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -2,23 +2,29 @@
void command_sensetrap(Client *c, const Seperator *sep) void command_sensetrap(Client *c, const Seperator *sep)
{ {
Mob *target = c->GetTarget(); if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
if (!target) { c->Message(Chat::White, "You must target an NPC to use this command.");
c->Message(Chat::Red, "You must have a target.");
return; return;
} }
if (target->IsNPC()) { auto target = c->GetTarget()->CastToNPC();
if (c->HasSkill(EQ::skills::SkillSenseTraps)) {
if (DistanceSquaredNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { if (!c->HasSkill(EQ::skills::SkillSenseTraps)) {
c->Message(Chat::Red, "%s is too far away.", target->GetCleanName()); c->Message(Chat::White, "You do not have the Sense Traps skill.");
return; return;
}
c->HandleLDoNSenseTraps(target->CastToNPC(), c->GetSkill(EQ::skills::SkillSenseTraps), LDoNTypeMechanical);
}
else {
c->Message(Chat::Red, "You do not have the sense traps skill.");
}
} }
if (DistanceSquaredNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) {
c->Message(
Chat::White,
fmt::format(
"{} ({}) is too far away.",
target->GetCleanName(),
target->GetID()
).c_str()
);
}
c->HandleLDoNSenseTraps(target, c->GetSkill(EQ::skills::SkillSenseTraps), LDoNTypeMechanical);
} }