[Commands] Cleanup #invul Command. (#1780)

- Cleanup message and logic.
This commit is contained in:
Kinglykrab 2021-11-21 09:58:13 -05:00 committed by GitHub
parent fb2f901539
commit f1d9221b4c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 11 deletions

View File

@ -221,7 +221,7 @@ int command_init(void)
command_add("interrogateinv", "- use [help] argument for available options", AccountStatus::Player, command_interrogateinv) ||
command_add("interrupt", "[message id] [color] - Interrupt your casting. Arguments are optional.", AccountStatus::Guide, command_interrupt) ||
command_add("invsnapshot", "- Manipulates inventory snapshots for your current target", AccountStatus::QuestTroupe, command_invsnapshot) ||
command_add("invul", "[on/off] - Turn player target's or your invulnerable flag on or off", AccountStatus::QuestTroupe, command_invul) ||
command_add("invul", "[On|Off]] - Turn player target's or your invulnerable flag on or off", AccountStatus::QuestTroupe, command_invul) ||
command_add("ipban", "[IP address] - Ban IP by character name", AccountStatus::GMMgmt, command_ipban) ||
command_add("iplookup", "[charname] - Look up IP address of charname", AccountStatus::GMMgmt, command_iplookup) ||
command_add("iteminfo", "- Get information about the item on your cursor", AccountStatus::Steward, command_iteminfo) ||

View File

@ -2,19 +2,27 @@
void command_invul(Client *c, const Seperator *sep)
{
bool state = atobool(sep->arg[1]);
Client *t = c;
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #invul [On|Off]");
return;
}
bool invul_flag = atobool(sep->arg[1]);
Client *target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
t = c->GetTarget()->CastToClient();
target = c->GetTarget()->CastToClient();
}
if (sep->arg[1][0] != 0) {
t->SetInvul(state);
c->Message(Chat::White, "%s is %s invulnerable from attack.", t->GetName(), state ? "now" : "no longer");
}
else {
c->Message(Chat::White, "Usage: #invulnerable [on/off]");
}
target->SetInvul(invul_flag);
c->Message(
Chat::White,
fmt::format(
"{} {} now {}.",
c == target ? "You" : target->GetCleanName(),
c == target ? "are" : "is",
invul_flag ? "invulnerable" : "vulnerable"
).c_str()
);
}