mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-12 13:41:31 +00:00
[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:
parent
c4c5256438
commit
a5348e207b
@ -490,6 +490,7 @@ SET(gm_commands
|
|||||||
gm_commands/setcrystals.cpp
|
gm_commands/setcrystals.cpp
|
||||||
gm_commands/setfaction.cpp
|
gm_commands/setfaction.cpp
|
||||||
gm_commands/setgraveyard.cpp
|
gm_commands/setgraveyard.cpp
|
||||||
|
gm_commands/sethp.cpp
|
||||||
gm_commands/setlanguage.cpp
|
gm_commands/setlanguage.cpp
|
||||||
gm_commands/setlsinfo.cpp
|
gm_commands/setlsinfo.cpp
|
||||||
gm_commands/setmana.cpp
|
gm_commands/setmana.cpp
|
||||||
|
|||||||
@ -326,6 +326,7 @@ int command_init(void)
|
|||||||
command_add("setcrystals", "[value] - Set your or your player target's available radiant or ebon crystals", AccountStatus::GMAdmin, command_setcrystals) ||
|
command_add("setcrystals", "[value] - Set your or your player target's available radiant or ebon crystals", AccountStatus::GMAdmin, command_setcrystals) ||
|
||||||
command_add("setfaction", "[Faction ID] - Sets targeted NPC's faction in the database", AccountStatus::GMAreas, command_setfaction) ||
|
command_add("setfaction", "[Faction ID] - Sets targeted NPC's faction in the database", AccountStatus::GMAreas, command_setfaction) ||
|
||||||
command_add("setgraveyard", "[zone name] - Creates a graveyard for the specified zone based on your target's LOC.", AccountStatus::GMMgmt, command_setgraveyard) ||
|
command_add("setgraveyard", "[zone name] - Creates a graveyard for the specified zone based on your target's LOC.", AccountStatus::GMMgmt, command_setgraveyard) ||
|
||||||
|
command_add("sethp", "[Health] - Set your or your target's Health", AccountStatus::GMAdmin, command_sethp) ||
|
||||||
command_add("setlanguage", "[language ID] [value] - Set your target's language skillnum to value", AccountStatus::Guide, command_setlanguage) ||
|
command_add("setlanguage", "[language ID] [value] - Set your target's language skillnum to value", AccountStatus::Guide, command_setlanguage) ||
|
||||||
command_add("setlsinfo", "[email] [password] - Set login server email address and password (if supported by login server)", AccountStatus::Steward, command_setlsinfo) ||
|
command_add("setlsinfo", "[email] [password] - Set login server email address and password (if supported by login server)", AccountStatus::Steward, command_setlsinfo) ||
|
||||||
command_add("setmana", "[Mana] - Set your or your target's Mana", AccountStatus::GMAdmin, command_setmana) ||
|
command_add("setmana", "[Mana] - Set your or your target's Mana", AccountStatus::GMAdmin, command_setmana) ||
|
||||||
|
|||||||
@ -247,6 +247,7 @@ void command_setanim(Client *c, const Seperator *sep);
|
|||||||
void command_setcrystals(Client *c, const Seperator *sep);
|
void command_setcrystals(Client *c, const Seperator *sep);
|
||||||
void command_setfaction(Client *c, const Seperator *sep);
|
void command_setfaction(Client *c, const Seperator *sep);
|
||||||
void command_setgraveyard(Client *c, const Seperator *sep);
|
void command_setgraveyard(Client *c, const Seperator *sep);
|
||||||
|
void command_sethp(Client *c, const Seperator *sep);
|
||||||
void command_setlanguage(Client *c, const Seperator *sep);
|
void command_setlanguage(Client *c, const Seperator *sep);
|
||||||
void command_setlsinfo(Client *c, const Seperator *sep);
|
void command_setlsinfo(Client *c, const Seperator *sep);
|
||||||
void command_setmana(Client *c, const Seperator *sep);
|
void command_setmana(Client *c, const Seperator *sep);
|
||||||
|
|||||||
@ -2,20 +2,28 @@
|
|||||||
|
|
||||||
void command_heal(Client *c, const Seperator *sep)
|
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();
|
target->Heal();
|
||||||
if (c != target) {
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::White,
|
Chat::White,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Healed {} ({}) to full.",
|
"Set {} to full Health ({}).",
|
||||||
target->GetCleanName(),
|
(
|
||||||
target->GetID()
|
c == target ?
|
||||||
).c_str()
|
"yourself" :
|
||||||
);
|
fmt::format(
|
||||||
}
|
"{} ({})",
|
||||||
else {
|
target->GetCleanName(),
|
||||||
c->Message(Chat::White, "Healed yourself to full.");
|
target->GetID()
|
||||||
}
|
)
|
||||||
|
),
|
||||||
|
target->GetMaxHP()
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
55
zone/gm_commands/sethp.cpp
Normal file
55
zone/gm_commands/sethp.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
#include "../client.h"
|
||||||
|
|
||||||
|
void command_sethp(Client *c, const Seperator *sep)
|
||||||
|
{
|
||||||
|
int arguments = sep->argnum;
|
||||||
|
if (!arguments || !sep->IsNumber(1)) {
|
||||||
|
c->Message(Chat::White, "Usage: #sethp [Health]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto health = static_cast<int>(std::min(std::stoll(sep->arg[1]), (long long) 2000000000));
|
||||||
|
bool set_to_max = false;
|
||||||
|
Mob* target = c;
|
||||||
|
if (c->GetTarget()) {
|
||||||
|
target = c->GetTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (health >= target->GetMaxHP()) {
|
||||||
|
health = target->GetMaxHP();
|
||||||
|
set_to_max = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
target->SetHP(health);
|
||||||
|
target->SendHPUpdate();
|
||||||
|
|
||||||
|
c->Message(
|
||||||
|
Chat::White,
|
||||||
|
fmt::format(
|
||||||
|
"Set {} to {} Health{}.",
|
||||||
|
(
|
||||||
|
c == target ?
|
||||||
|
"yourself" :
|
||||||
|
fmt::format(
|
||||||
|
"{} ({})",
|
||||||
|
target->GetCleanName(),
|
||||||
|
target->GetID()
|
||||||
|
)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
set_to_max ?
|
||||||
|
"full" :
|
||||||
|
std::to_string(health)
|
||||||
|
),
|
||||||
|
(
|
||||||
|
set_to_max ?
|
||||||
|
fmt::format(
|
||||||
|
" ({})",
|
||||||
|
health
|
||||||
|
) :
|
||||||
|
""
|
||||||
|
)
|
||||||
|
).c_str()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user