[Commands] Cleanup #setanim Command. (#1791)

- Cleanup message and logic.
- SetAppearance was not sending to self, so if you modified your own appearance, you wouldn't be able to see it.
This commit is contained in:
Kinglykrab
2021-11-21 10:10:52 -05:00
committed by GitHub
parent ec1cf68ce2
commit d73194c1f6
3 changed files with 56 additions and 11 deletions
+50 -8
View File
@@ -2,15 +2,57 @@
void command_setanim(Client *c, const Seperator *sep)
{
if (c->GetTarget() && sep->IsNumber(1)) {
int num = atoi(sep->arg[1]);
if (num < 0 || num >= _eaMaxAppearance) {
c->Message(Chat::White, "Invalid animation number, between 0 and %d", _eaMaxAppearance - 1);
}
c->GetTarget()->SetAppearance(EmuAppearance(num));
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #setanim [Animation ID (IDs are 0 to 4)]");
return;
}
else {
c->Message(Chat::White, "Usage: #setanim [animnum]");
Mob* target = c;
if (c->GetTarget()) {
target = c->GetTarget();
}
int animation_id = std::stoi(sep->arg[1]);
if (
animation_id < 0 ||
animation_id > eaLooting
) {
c->Message(Chat::White, "Usage: #setanim [Animation ID (IDs are 0 to 4)]");
return;
}
target->SetAppearance(static_cast<EmuAppearance>(animation_id), false);
std::string animation_name;
if (animation_id == eaStanding) {
animation_name = "Standing";
} else if (animation_id == eaSitting) {
animation_name = "Sitting";
} else if (animation_id == eaCrouching) {
animation_name = "Crouching";
} else if (animation_id == eaDead) {
animation_name = "Dead";
} else if (animation_id == eaLooting) {
animation_name = "Looting";
}
c->Message(
Chat::White,
fmt::format(
"Set animation to {} ({}) for {}.",
animation_name,
animation_id,
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
).c_str()
)
).c_str()
);
}