Alex King a90d41480a
[Commands] Cleanup #wc Command (#3049)
# Notes
- Cleanup messages and logic.
2023-03-05 22:18:35 -05:00

45 lines
1.2 KiB
C++
Executable File

#include "../client.h"
#include "../../common/data_verification.h"
void command_wc(Client *c, const Seperator *sep)
{
const auto arguments = sep->argnum;
if (
arguments < 2 ||
!sep->IsNumber(1) ||
!sep->IsNumber(2)
) {
c->Message(Chat::White, "Usage: #wc [Slot ID] [Material]");
c->Message(Chat::White, "Usage: #wc [Slot ID] [Material] [Hero Forge Model] [Elite Material]");
return;
}
Mob* t = c;
if (c->GetTarget()) {
t = c->GetTarget();
}
const auto slot_id = static_cast<uint8>(Strings::ToUnsignedInt(sep->arg[1]));
const auto texture = static_cast<uint16>(Strings::ToUnsignedInt(sep->arg[2]));
uint32 hero_forge_model = 0;
uint32 elite_material = 0;
if (arguments >= 3 && sep->IsNumber(3)) {
hero_forge_model = Strings::ToUnsignedInt(sep->arg[3]);
if (EQ::ValueWithin(hero_forge_model, 1, 999)) { // Shorthand Hero Forge ID. Otherwise use the value the user entered.
hero_forge_model = (hero_forge_model * 100) + slot_id;
}
}
if (arguments >= 4 && sep->IsNumber(4)) {
elite_material = Strings::ToUnsignedInt(sep->arg[4]);
}
c->GetTarget()->SendTextureWC(
slot_id,
texture,
hero_forge_model,
elite_material
);
}