diff --git a/zone/CMakeLists.txt b/zone/CMakeLists.txt index 3356c385c..1eed7b72f 100644 --- a/zone/CMakeLists.txt +++ b/zone/CMakeLists.txt @@ -492,6 +492,7 @@ SET(gm_commands gm_commands/setgraveyard.cpp gm_commands/setlanguage.cpp gm_commands/setlsinfo.cpp + gm_commands/setmana.cpp gm_commands/setpass.cpp gm_commands/setpvppoints.cpp gm_commands/setskill.cpp diff --git a/zone/command.cpp b/zone/command.cpp index 9a74605c2..ca394b941 100755 --- a/zone/command.cpp +++ b/zone/command.cpp @@ -328,6 +328,7 @@ int command_init(void) command_add("setgraveyard", "[zone name] - Creates a graveyard for the specified zone based on your target's LOC.", AccountStatus::GMMgmt, command_setgraveyard) || 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) || command_add("setpass", "[accountname] [password] - Set local password for accountname", AccountStatus::GMLeadAdmin, command_setpass) || command_add("setpvppoints", "[Amount] - Set your or your player target's PVP points", AccountStatus::GMAdmin, command_setpvppoints) || command_add("setskill", "[skillnum] [value] - Set your target's skill skillnum to value", AccountStatus::Guide, command_setskill) || diff --git a/zone/command.h b/zone/command.h index 9643c3efc..d43163f36 100644 --- a/zone/command.h +++ b/zone/command.h @@ -249,6 +249,7 @@ void command_setfaction(Client *c, const Seperator *sep); void command_setgraveyard(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); void command_setpass(Client *c, const Seperator *sep); void command_setpvppoints(Client *c, const Seperator *sep); void command_setskill(Client *c, const Seperator *sep); diff --git a/zone/gm_commands/mana.cpp b/zone/gm_commands/mana.cpp index 33fe4e388..dc75a0aa3 100755 --- a/zone/gm_commands/mana.cpp +++ b/zone/gm_commands/mana.cpp @@ -3,25 +3,31 @@ void command_mana(Client *c, const Seperator *sep) { auto target = c->GetTarget() ? c->GetTarget() : c; + int mana = 0; if (target->IsClient()) { - target->CastToClient()->SetMana(target->CastToClient()->CalcMaxMana()); + mana = target->CastToClient()->CalcMaxMana(); + target->CastToClient()->SetMana(mana); } else { - target->SetMana(target->CalcMaxMana()); + mana = target->CalcMaxMana(); + target->SetMana(mana); } - if (c != target) { - c->Message( - Chat::White, - fmt::format( - "Set {} ({}) to full Mana.", - target->GetCleanName(), - target->GetID() - ).c_str() - ); - } - else { - c->Message(Chat::White, "Restored your Mana to full."); - } + c->Message( + Chat::White, + fmt::format( + "Set {} to full Mana ({}).", + ( + c == target ? + "yourself" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ), + mana + ).c_str() + ); } diff --git a/zone/gm_commands/setmana.cpp b/zone/gm_commands/setmana.cpp new file mode 100644 index 000000000..505e85afe --- /dev/null +++ b/zone/gm_commands/setmana.cpp @@ -0,0 +1,63 @@ +#include "../client.h" + +void command_setmana(Client *c, const Seperator *sep) +{ + int arguments = sep->argnum; + if (!arguments || !sep->IsNumber(1)) { + c->Message(Chat::White, "Usage: #setmana [Mana]"); + return; + } + + auto mana = 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 (target->IsClient()) { + if (mana >= target->CastToClient()->CalcMaxMana()) { + mana = target->CastToClient()->CalcMaxMana(); + set_to_max = true; + } + + target->CastToClient()->SetMana(mana); + } else { + if (mana >= target->CalcMaxMana()) { + mana = target->CalcMaxMana(); + set_to_max = true; + } + + target->SetMana(mana); + } + + c->Message( + Chat::White, + fmt::format( + "Set {} to {} Mana{}.", + ( + c == target ? + "yourself" : + fmt::format( + "{} ({})", + target->GetCleanName(), + target->GetID() + ) + ), + ( + set_to_max ? + "full" : + std::to_string(mana) + ), + ( + set_to_max ? + fmt::format( + " ({})", + mana + ) : + "" + ) + ).c_str() + ); +} +