[Commands] Add #setendurance Command. (#1841)

- Add #setendurance [Endurance] command to set an NPC or player's endurance to a specified amount, or to max if the amount is greater than their max.
- Cleanup #endurance command message and logic.
This commit is contained in:
Kinglykrab
2021-11-27 19:08:07 -05:00
committed by GitHub
parent a5348e207b
commit 225497337c
5 changed files with 92 additions and 18 deletions
+27 -18
View File
@@ -2,26 +2,35 @@
void command_endurance(Client *c, const Seperator *sep)
{
auto target = c->GetTarget() ? c->GetTarget() : c;
if (target->IsClient()) {
target->CastToClient()->SetEndurance(target->CastToClient()->GetMaxEndurance());
}
else {
target->SetEndurance(target->GetMaxEndurance());
Mob* target = c;
if (c->GetTarget()) {
target = c->GetTarget();
}
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"Set {} ({}) to full Endurance.",
target->GetCleanName(),
target->GetID()
).c_str()
);
}
else {
c->Message(Chat::White, "Restored your Endurance to full.");
int endurance = 0;
if (target->IsClient()) {
endurance = target->CastToClient()->GetMaxEndurance();
target->CastToClient()->SetEndurance(endurance);
} else {
endurance = target->GetMaxEndurance();
target->SetEndurance(endurance);
}
c->Message(
Chat::White,
fmt::format(
"Set {} to full Endurance ({}).",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
),
endurance
).c_str()
);
}