From 6303f129afb4b338ef0401686b75c1d0407dbd8a Mon Sep 17 00:00:00 2001 From: Kinglykrab <89047260+Kinglykrab@users.noreply.github.com> Date: Mon, 14 Feb 2022 19:02:27 -0500 Subject: [PATCH] [Commands] Cleanup #setskillall Command. (#1992) - Cleanup messages and logic. --- zone/command.cpp | 2 +- zone/gm_commands/setskillall.cpp | 62 +++++++++++++++++++++----------- 2 files changed, 43 insertions(+), 21 deletions(-) diff --git a/zone/command.cpp b/zone/command.cpp index 36da9fc95..ed5d34eaa 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -339,7 +339,7 @@ int command_init(void) command_add("setpass", "[accountname] [password] - Set local password for accountname", AccountStatus::GMLeadAdmin, command_setpass) || command_add("setpvppoints", "[Amount] - Set your or your player target's PVP points", AccountStatus::GMAdmin, command_setpvppoints) || command_add("setskill", "[skillnum] [value] - Set your target's skill skillnum to value", AccountStatus::Guide, command_setskill) || - command_add("setskillall", "[value] - Set all of your target's skills to value", AccountStatus::Guide, command_setskillall) || + command_add("setskillall", "[Skill Level] - Set all of your or your target's skills to the specified skill level", AccountStatus::Guide, command_setskillall) || command_add("setstartzone", "[Zone ID|Zone Short Name] - Sets your or your target's starting zone (Use '0' or 'Reset' to allow the player use of /setstartcity)", AccountStatus::QuestTroupe, command_setstartzone) || command_add("setstat", "- Sets the stats to a specific value.", AccountStatus::Max, command_setstat) || command_add("setxp", "[value] - Set your or your player target's experience", AccountStatus::GMAdmin, command_setxp) || diff --git a/zone/gm_commands/setskillall.cpp b/zone/gm_commands/setskillall.cpp index dd8b9992a..8cc853814 100755 --- a/zone/gm_commands/setskillall.cpp +++ b/zone/gm_commands/setskillall.cpp @@ -2,28 +2,50 @@ void command_setskillall(Client *c, const Seperator *sep) { - if (c->GetTarget() == 0) { - c->Message(Chat::White, "Error: #setallskill: No target."); + auto target = c; + if (c->GetTarget() && c->GetTarget()->IsClient()) { + target = c->GetTarget()->CastToClient(); } - else if (!c->GetTarget()->IsClient()) { - c->Message(Chat::White, "Error: #setskill: Target must be a client."); - } - else if (!sep->IsNumber(1) || atoi(sep->arg[1]) < 0 || atoi(sep->arg[1]) > HIGHEST_CAN_SET_SKILL) { - c->Message(Chat::White, "Usage: #setskillall value "); - c->Message(Chat::White, " value = 0 to %d", HIGHEST_CAN_SET_SKILL); - } - else { - if (c->Admin() >= commandSetSkillsOther || c->GetTarget() == c || c->GetTarget() == 0) { - LogInfo("Set ALL skill request from [{}], target:[{}]", c->GetName(), c->GetTarget()->GetName()); - uint16 level = atoi(sep->arg[1]); - for (EQ::skills::SkillType skill_num = EQ::skills::Skill1HBlunt; - skill_num <= EQ::skills::HIGHEST_SKILL; - skill_num = (EQ::skills::SkillType) (skill_num + 1)) { - c->GetTarget()->CastToClient()->SetSkill(skill_num, level); + + if (!sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #setskillall [Skill Level] - Set all of your or your target's skills to the specified skill level"); + c->Message( + Chat::White, + fmt::format( + "Note: Skill Level ranges from 0 to {}", + HIGHEST_CAN_SET_SKILL + ).c_str() + ); + } else { + if (c->Admin() >= commandSetSkillsOther || c->GetTarget() == c) { + LogInfo( + "Set ALL skill request from [{}], target:[{}]", + c->GetCleanName(), + target->GetCleanName() + ); + + auto skill_level = static_cast(std::stoul(sep->arg[1])); + + c->Message( + Chat::White, + fmt::format( + "Setting all skills to {} for {}.", + skill_level, + c == target ? + "yourself" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ).c_str() + ); + + for (EQ::skills::SkillType skill_num = EQ::skills::Skill1HBlunt; skill_num <= EQ::skills::HIGHEST_SKILL; skill_num = (EQ::skills::SkillType) (skill_num + 1)) { + target->SetSkill(skill_num, skill_level); } - } - else { - c->Message(Chat::White, "Error: Your status is not high enough to set anothers skills"); + } else { + c->Message(Chat::White, "Your status is not high enough to set another player's skills."); } } }