Kinglykrab c4c5256438
[Commands] Add #setmana Command. (#1839)
* [Commands] Add #setmana Command.
- Add #setmana [Mana] command to set an NPC or player's mana to a specified amount, or to max if the amount is greater than their max.
- Cleanup #mana command message and logic.

* Update mana.cpp
2021-11-27 19:07:47 -05:00

34 lines
569 B
C++
Executable File

#include "../client.h"
void command_mana(Client *c, const Seperator *sep)
{
auto target = c->GetTarget() ? c->GetTarget() : c;
int mana = 0;
if (target->IsClient()) {
mana = target->CastToClient()->CalcMaxMana();
target->CastToClient()->SetMana(mana);
}
else {
mana = target->CalcMaxMana();
target->SetMana(mana);
}
c->Message(
Chat::White,
fmt::format(
"Set {} to full Mana ({}).",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
),
mana
).c_str()
);
}