From 04fda24c8e0a19cb8a10203ad18ce6224f876870 Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Sun, 21 Nov 2021 10:12:02 -0500 Subject: [PATCH] [Commands] Cleanup #aggrozone Command. (#1798) - Cleanup message and logic. - Add the ability to aggro the zone on your target if you have one. --- zone/gm_commands/aggrozone.cpp | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/zone/gm_commands/aggrozone.cpp b/zone/gm_commands/aggrozone.cpp index afdf4ad64..797ed2128 100755 --- a/zone/gm_commands/aggrozone.cpp +++ b/zone/gm_commands/aggrozone.cpp @@ -2,18 +2,30 @@ void command_aggrozone(Client *c, const Seperator *sep) { - if (!c) { - return; + Mob *target = c; + if (c->GetTarget()) { + target = c->GetTarget(); } - Mob *m = c->CastToMob(); - - if (!m) { - return; + uint32 hate = 0; + if (sep->IsNumber(1)) { + hate = std::stoul(sep->arg[1]); } - uint32 hate = atoi(sep->arg[1]); //should default to 0 if we don't enter anything - entity_list.AggroZone(m, hate); - c->Message(Chat::White, "Train to you! Last chance to go invulnerable..."); + entity_list.AggroZone(target, hate); + c->Message( + Chat::White, + fmt::format( + "Aggroing zone on {}.", + ( + c == target ? + "yourself" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ) + ).c_str() + ); } -