eqemu-server/zone/gm_commands/permarace.cpp
Kinglykrab e87b8e2682
[Commands] Cleanup #gender Command. (#1832)
- Cleanup message and logic.
- Cleanup other spots using similar logic so they're all uniform.
2021-11-26 10:01:35 -05:00

53 lines
1.2 KiB
C++
Executable File

#include "../client.h"
void command_permarace(Client *c, const Seperator *sep)
{
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;
}
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" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
),
GetRaceIDName(race_id),
race_id
).c_str()
);
}