Alex King fb20d92166
[Bug Fix] Fix Appearance Issues (#3520)
* [Bug Fix] Fix Appearance Issues

# Notes
- Changing race, gender, or texture of a Mob could result in it changing sizes due to use not sending the size as part of the appearance packet.
- Also converts the parameterized method to a struct parameter so that we can optionally send things without back-filling multiple arguments.

* Gender cleanup.

* Fix.

* Formatting.
2023-07-31 20:15:13 -05:00

58 lines
1.0 KiB
C++
Executable File

#include "../../client.h"
void SetRace(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
if (arguments < 2 || !sep->IsNumber(2)) {
c->Message(
Chat::White,
fmt::format(
"Usage: #set race [0-{}, 2253-2259] (0 for back to normal)",
RuleI(NPC, MaxRaceID)
).c_str()
);
return;
}
Mob* t = c;
if (c->GetTarget()) {
t = c->GetTarget();
}
const uint16 race_id = Strings::ToUnsignedInt(sep->arg[2]);
if (
!EQ::ValueWithin(race_id, RACE_DOUG_0, RuleI(NPC, MaxRaceID)) &&
!EQ::ValueWithin(race_id, 2253, 2259)
) {
c->Message(
Chat::White,
fmt::format(
"Usage: #race [0-{}, 2253-2259] (0 for back to normal)",
RuleI(NPC, MaxRaceID)
).c_str()
);
return;
}
t->SendIllusionPacket(
AppearanceStruct{
.race_id = race_id,
.size = t->GetSize(),
}
);
c->Message(
Chat::White,
fmt::format(
"{} {} now temporarily a(n) {} ({}).",
c->GetTargetDescription(t, TargetDescriptionType::UCYou),
c == t ? "are" : "is",
GetRaceIDName(race_id),
race_id
).c_str()
);
}