eqemu-server/zone/gm_commands/setcrystals.cpp
Kinglykrab 7df9b2974b
[Commands] Cleanup #reloadzps Command. (#2129)
* [Commands] Cleanup #reloadzps Command.
- Cleanup messages and logic.
- Make reloading of zone points global instead of zone specific.

* Further cleanup.
- Add zone->GetZoneDescription().
- Add mob->GetTargetDescription(mob).

* Final cleanup.

* Typo.
2022-05-07 03:23:15 -04:00

53 lines
1.3 KiB
C++
Executable File

#include "../client.h"
void command_setcrystals(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (arguments <= 1 || !sep->IsNumber(2)) {
c->Message(Chat::White, "Usage: #setcrystals [Ebon|Radiant] [Crystal Amount]");
return;
}
Client *target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
target = c->GetTarget()->CastToClient();
}
std::string crystal_type = str_tolower(sep->arg[1]);
uint32 crystal_amount = static_cast<uint32>(std::min(
std::stoull(sep->arg[2]),
(unsigned long long) 2000000000
));
bool is_ebon = crystal_type.find("ebon") != std::string::npos;
bool is_radiant = crystal_type.find("radiant") != std::string::npos;
if (!is_ebon && !is_radiant) {
c->Message(Chat::White, "Usage: #setcrystals [Ebon|Radiant] [Crystal Amount]");
return;
}
uint32 crystal_item_id = (
is_ebon ?
RuleI(Zone, EbonCrystalItemID) :
RuleI(Zone, RadiantCrystalItemID)
);
auto crystal_link = database.CreateItemLink(crystal_item_id);
if (is_radiant) {
target->SetRadiantCrystals(crystal_amount);
} else {
target->SetEbonCrystals(crystal_amount);
}
c->Message(
Chat::White,
fmt::format(
"{} now {} {} {}.",
c->GetTargetDescription(target, TargetDescriptionType::UCYou),
c == target ? "have" : "has",
crystal_amount,
crystal_link
).c_str()
);
}