From 132c936c9098fc10952f9577ba9795b368c5595e Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Fri, 6 May 2022 20:01:29 -0400 Subject: [PATCH] [Commands] Cleanup #sensetrap Command. (#2137) * [Commands] Cleanup #sensetrap Command. - Cleanup messages and logic. * Update sensetrap.cpp --- zone/gm_commands/sensetrap.cpp | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/zone/gm_commands/sensetrap.cpp b/zone/gm_commands/sensetrap.cpp index 792d7867d..03363c06f 100755 --- a/zone/gm_commands/sensetrap.cpp +++ b/zone/gm_commands/sensetrap.cpp @@ -2,23 +2,29 @@ void command_sensetrap(Client *c, const Seperator *sep) { - Mob *target = c->GetTarget(); - if (!target) { - c->Message(Chat::Red, "You must have a target."); + if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { + c->Message(Chat::White, "You must target an NPC to use this command."); return; } - if (target->IsNPC()) { - if (c->HasSkill(EQ::skills::SkillSenseTraps)) { - if (DistanceSquaredNoZ(c->GetPosition(), target->GetPosition()) > RuleI(Adventure, LDoNTrapDistanceUse)) { - c->Message(Chat::Red, "%s is too far away.", target->GetCleanName()); - return; - } - c->HandleLDoNSenseTraps(target->CastToNPC(), c->GetSkill(EQ::skills::SkillSenseTraps), LDoNTypeMechanical); - } - else { - c->Message(Chat::Red, "You do not have the sense traps skill."); - } + auto target = c->GetTarget()->CastToNPC(); + + if (!c->HasSkill(EQ::skills::SkillSenseTraps)) { + c->Message(Chat::White, "You do not have the Sense Traps skill."); + return; } + + 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); }