diff --git a/zone/command.cpp b/zone/command.cpp index 66956d85b..1fb71af5c 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -276,7 +276,7 @@ int command_init(void) command_add("peqzone", "[zonename] - Go to specified zone, if you have > 75% health", AccountStatus::Player, command_peqzone) || command_add("permaclass", "[Class ID] - Change your or your player target's class, changed client is disconnected", AccountStatus::QuestTroupe, command_permaclass) || command_add("permagender", "[gendernum] - Change your or your player target's gender (zone to take effect)", AccountStatus::QuestTroupe, command_permagender) || - command_add("permarace", "[racenum] - Change your or your player target's race (zone to take effect)", AccountStatus::QuestTroupe, command_permarace) || + command_add("permarace", "[Race ID] - Change your or your player target's race", AccountStatus::QuestTroupe, command_permarace) || command_add("petitioninfo", "[petition number] - Get info about a petition", AccountStatus::ApprenticeGuide, command_petitioninfo) || command_add("pf", "- Display additional mob coordinate and wandering data", AccountStatus::Player, command_pf) || command_add("picklock", "Analog for ldon pick lock for the newer clients since we still don't have it working.", AccountStatus::Player, command_picklock) || diff --git a/zone/gm_commands/permarace.cpp b/zone/gm_commands/permarace.cpp index ac33c8605..d6065a797 100755 --- a/zone/gm_commands/permarace.cpp +++ b/zone/gm_commands/permarace.cpp @@ -2,33 +2,43 @@ void command_permarace(Client *c, const Seperator *sep) { - Client *t = c; - - if (c->GetTarget() && c->GetTarget()->IsClient()) { - t = c->GetTarget()->CastToClient(); - } - - if (sep->arg[1][0] == 0) { - c->Message(Chat::White, "Usage: #permarace "); + int arguments = sep->argnum; + if (!arguments || !sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #permarace [Race ID]"); c->Message( Chat::White, "NOTE: Not all models are global. If a model is not global, it will appear as a human on character select and in zones without the model." ); + return; } - else if (!t->IsClient()) { - c->Message(Chat::White, "Target is not a client."); - } - else { - c->Message(Chat::White, "Setting %s's race - zone to take effect", t->GetName()); - LogInfo("Permanant race change request from [{}] for [{}], requested race:[{}]", - c->GetName(), - t->GetName(), - atoi(sep->arg[1])); - uint32 tmp = Mob::GetDefaultGender(atoi(sep->arg[1]), t->GetBaseGender()); - t->SetBaseRace(atoi(sep->arg[1])); - t->SetBaseGender(tmp); - t->Save(); - t->SendIllusionPacket(atoi(sep->arg[1])); - } -} + Client *target = c; + if (c->GetTarget() && c->GetTarget()->IsClient()) { + target = c->GetTarget()->CastToClient(); + } + + auto race_id = std::stoi(sep->arg[1]); + auto gender_id = Mob::GetDefaultGender(race_id, target->GetBaseGender()); + + LogInfo("Race changed by {} for {} to {} ({})", + c->GetCleanName(), + target->GetCleanName(), + GetRaceIDName(race_id), + race_id + ); + + target->SetBaseRace(race_id); + target->SetBaseGender(gender_id); + target->Save(); + target->SendIllusionPacket(race_id, gender_id); + + c->Message( + Chat::White, + fmt::format( + "Race changed for {} to {} ({}).", + c == target ? "yourself" : target->GetCleanName(), + GetRaceIDName(race_id), + race_id + ).c_str() + ); +}