[Commands] Add #sethp Command. (#1840)

- Add #sethp [Health] command to set an NPC or player's health to a specified amount, or to max if the amount is greater than their max.
- Cleanup #heal command message and logic.
This commit is contained in:
Kinglykrab
2021-11-27 19:08:00 -05:00
committed by GitHub
parent c4c5256438
commit a5348e207b
5 changed files with 80 additions and 14 deletions
+22 -14
View File
@@ -2,20 +2,28 @@
void command_heal(Client *c, const Seperator *sep)
{
auto target = c->GetTarget() ? c->GetTarget() : c;
Mob* target = c;
if (c->GetTarget()) {
target = c->GetTarget();
}
target->Heal();
if (c != target) {
c->Message(
Chat::White,
fmt::format(
"Healed {} ({}) to full.",
target->GetCleanName(),
target->GetID()
).c_str()
);
}
else {
c->Message(Chat::White, "Healed yourself to full.");
}
c->Message(
Chat::White,
fmt::format(
"Set {} to full Health ({}).",
(
c == target ?
"yourself" :
fmt::format(
"{} ({})",
target->GetCleanName(),
target->GetID()
)
),
target->GetMaxHP()
).c_str()
);
}