[Commands] Cleanup #texture Command. (#1835)

* [Commands] Cleanup #texture Command.
- Cleanup message and logic.

* Update command.cpp
This commit is contained in:
Kinglykrab 2021-11-27 20:21:58 -05:00 committed by GitHub
parent 225497337c
commit a6e5534b64
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 58 additions and 45 deletions

View File

@ -363,7 +363,7 @@ int command_init(void)
command_add("tattoo", "- Change the tattoo of your target (Drakkin Only)", AccountStatus::QuestTroupe, command_tattoo) ||
command_add("tempname", "[newname] - Temporarily renames your target. Leave name blank to restore the original name.", AccountStatus::GMAdmin, command_tempname) ||
command_add("petname", "[newname] - Temporarily renames your pet. Leave name blank to restore the original name.", AccountStatus::GMAdmin, command_petname) ||
command_add("texture", "[texture] [helmtexture] - Change your or your target's appearance, use 255 to show equipment", AccountStatus::Steward, command_texture) ||
command_add("texture", "[Texture] [Helmet Texture] - Change your or your target's texture (Helmet Texture defaults to 0 if not used)", AccountStatus::Steward, command_texture) ||
command_add("time", "[HH] [MM] - Set EQ time", AccountStatus::EQSupport, command_time) ||
command_add("timers", "- Display persistent timers for target", AccountStatus::GMMgmt, command_timers) ||
command_add("timezone", "[HH] [MM] - Set timezone. Minutes are optional", AccountStatus::EQSupport, command_timezone) ||

View File

@ -2,51 +2,64 @@
void command_texture(Client *c, const Seperator *sep)
{
uint16 texture;
if (sep->IsNumber(1) && atoi(sep->arg[1]) >= 0 && atoi(sep->arg[1]) <= 255) {
texture = atoi(sep->arg[1]);
uint8 helm = 0xFF;
// Player Races Wear Armor, so Wearchange is sent instead
int i;
if (!c->GetTarget()) {
for (i = EQ::textures::textureBegin; i <= EQ::textures::LastTintableTexture; i++) {
c->SendTextureWC(i, texture);
}
}
else if ((c->GetTarget()->GetModel() > 0 && c->GetTarget()->GetModel() <= 12) ||
c->GetTarget()->GetModel() == 128 || c->GetTarget()->GetModel() == 130 ||
c->GetTarget()->GetModel() == 330 || c->GetTarget()->GetModel() == 522) {
for (i = EQ::textures::textureBegin; i <= EQ::textures::LastTintableTexture; i++) {
c->GetTarget()->SendTextureWC(i, texture);
}
}
else // Non-Player Races only need Illusion Packets to be sent for texture
{
if (sep->IsNumber(2) && atoi(sep->arg[2]) >= 0 && atoi(sep->arg[2]) <= 255) {
helm = atoi(sep->arg[2]);
}
else {
helm = texture;
int arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #texture [Texture] [Helmet Texture]");
return;
}
if (texture == 255) {
texture = 0xFFFF; // Should be pulling these from the database instead
helm = 0xFF;
auto texture = static_cast<uint16>(std::min(std::stoul(sep->arg[1]), (unsigned long) 65535));
auto helmet_texture = static_cast<uint8>(
sep->IsNumber(2) ?
std::min(std::stoul(sep->arg[2]), (unsigned long) 255) :
0
);
Mob* target = c;
if (c->GetTarget() && c->Admin() >= commandTextureOthers) {
target = c->GetTarget();
}
if ((c->GetTarget()) && (c->Admin() >= commandTextureOthers)) {
c->GetTarget()->SendIllusionPacket(c->GetTarget()->GetModel(), 0xFF, texture, helm);
if (Mob::IsPlayerRace(target->GetModel())) { // Player Races Wear Armor, so Wearchange is sent instead
for (
int texture_slot = EQ::textures::textureBegin;
texture_slot <= EQ::textures::LastTintableTexture;
texture_slot++
) {
target->SendTextureWC(texture_slot, texture);
}
else {
c->SendIllusionPacket(c->GetRace(), 0xFF, texture, helm);
}
}
}
else {
c->Message(Chat::White, "Usage: #texture [texture] [helmtexture] (0-255, 255 for show equipment)");
} else { // Non-Player Races only need Illusion Packets to be sent for texture
target->SendIllusionPacket(
target->GetModel(),
target->GetGender(),
texture,
helmet_texture
);
}
c->Message(
Chat::White,
fmt::format(
"Texture Changed for {} | Texture: {}{}",
(
c == target ?
"Yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
),
texture,
(
Mob::IsPlayerRace(target->GetModel()) ?
"" :
fmt::format(
" Helmet Texture: {}",
helmet_texture
)
)
).c_str()
);
}