diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 1eed7b72f..44a4d2b9a 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -490,6 +490,7 @@ SET(gm_commands gm_commands/setcrystals.cpp gm_commands/setfaction.cpp gm_commands/setgraveyard.cpp + gm_commands/sethp.cpp gm_commands/setlanguage.cpp gm_commands/setlsinfo.cpp gm_commands/setmana.cpp diff --git a/zone/command.cpp b/zone/command.cpp index ca394b941..f3fa9936b 100755 --- a/zone/command.cpp +++ b/zone/command.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("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("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("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) || diff --git a/zone/command.h b/zone/command.h index d43163f36..4760b09cb 100644 --- a/zone/command.h +++ b/zone/command.h @@ -247,6 +247,7 @@ void command_setanim(Client *c, const Seperator *sep); void command_setcrystals(Client *c, const Seperator *sep); void command_setfaction(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_setlsinfo(Client *c, const Seperator *sep); void command_setmana(Client *c, const Seperator *sep); diff --git a/zone/gm_commands/heal.cpp b/zone/gm_commands/heal.cpp index f309b30e3..5a68a7c55 100755 --- a/zone/gm_commands/heal.cpp +++ b/zone/gm_commands/heal.cpp @@ -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() + ); } diff --git a/zone/gm_commands/sethp.cpp b/zone/gm_commands/sethp.cpp new file mode 100644 index 000000000..c9c73c96f --- /dev/null +++ b/zone/gm_commands/sethp.cpp @@ -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(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() + ); +} +