[Commands] Cleanup #haste Command (#3042)

* [Commands] Cleanup #haste Command

# Notes
- Cleanup messages and logic.
- No longer requires you to re-equip your weapon for the haste to take effect.
- Can now use on targeted client if you have `#gm on` enabled.

* Update haste.cpp
This commit is contained in:
Alex King
2023-03-05 22:35:42 -05:00
committed by GitHub
parent 22d7ef6763
commit 16a8f88ae5
2 changed files with 24 additions and 13 deletions
+23 -12
View File
@@ -2,19 +2,30 @@
void command_haste(Client *c, const Seperator *sep)
{
// #haste command to set client attack speed. Takes a percentage (100 = twice normal attack speed)
if (sep->arg[1][0] != 0) {
uint16 Haste = Strings::ToInt(sep->arg[1]);
if (Haste > 85) {
Haste = 85;
}
c->SetExtraHaste(Haste);
// SetAttackTimer must be called to make this take effect, so player needs to change
// the primary weapon.
c->Message(Chat::White, "Haste set to %d%% - Need to re-equip primary weapon before it takes effect", Haste);
const auto arguments = sep->argnum;
if (!arguments || !sep->IsNumber(1)) {
c->Message(Chat::White, "Usage: #haste [Percentage] - Set GM Bonus Haste (100 is 100% more Attack Speed)");
return;
}
else {
c->Message(Chat::White, "Usage: #haste [percentage]");
auto t = c;
if (c->GetGM() && c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
}
const auto extra_haste = Strings::ToInt(sep->arg[1]);
t->SetExtraHaste(extra_haste);
t->CalcBonuses();
t->SetAttackTimer();
c->Message(
Chat::White,
fmt::format(
"GM Haste Bonus set to {}%% for {}.",
Strings::Commify(extra_haste),
c->GetTargetDescription(t)
).c_str()
);
}