[Commands] Cleanup #npcedit, #lastname, #title, and #titlesuffix Commands. (#2215)

* [Commands] Cleanup #lastname, #npcedit, #title, and #titlesuffix Commands.
- Cleanup messages and logic.

* Update emu_constants.h

* Update command.cpp

* Update command.cpp

* Cleanup of GetXName methods to not define map unnecessarily.

* Update emu_constants.cpp

* Update npcedit.cpp
This commit is contained in:
Kinglykrab
2022-05-28 14:35:05 -04:00
committed by GitHub
parent 7de50d0e60
commit c8f6dbb86d
7 changed files with 2577 additions and 1358 deletions
+6 -6
View File
@@ -192,7 +192,7 @@ int command_init(void)
command_add("kick", "[Character Name] - Disconnect a player by name", AccountStatus::GMLeadAdmin, command_kick) ||
command_add("kill", "Kill your target", AccountStatus::GMAdmin, command_kill) ||
command_add("killallnpcs", "[npc_name] - Kills all npcs by search name, leave blank for all attackable NPC's", AccountStatus::GMMgmt, command_killallnpcs) ||
command_add("lastname", "[Last Name] - Set you or your player target's lastname", AccountStatus::Guide, command_lastname) ||
command_add("lastname", "[Last Name] - Set your or your player target's last name (use \"-1\" to remove last name)", AccountStatus::Guide, command_lastname) ||
command_add("level", "[Level] - Set your target's level", AccountStatus::Steward, command_level) ||
command_add("list", "[npcs|players|corpses|doors|objects] [search] - Search entities", AccountStatus::ApprenticeGuide, command_list) ||
command_add("listpetition", "List petitions", AccountStatus::Guide, command_listpetition) ||
@@ -205,7 +205,7 @@ int command_init(void)
command_add("memspell", "[Spell ID] [Spell Gem] - Memorize a Spell by ID to the specified Spell Gem for you or your target", AccountStatus::Guide, command_memspell) ||
command_add("merchant_close_shop", "Closes a merchant shop", AccountStatus::GMAdmin, command_merchantcloseshop) ||
command_add("merchant_open_shop", "Opens a merchants shop", AccountStatus::GMAdmin, command_merchantopenshop) ||
command_add("modifynpcstat", "- Modifys a NPC's stats", AccountStatus::GMLeadAdmin, command_modifynpcstat) ||
command_add("modifynpcstat", "Modifies an NPC's stats", AccountStatus::GMLeadAdmin, command_modifynpcstat) ||
command_add("motd", "[Message of the Day] - Set Message of the Day (leave empty to have no Message of the Day)", AccountStatus::GMLeadAdmin, command_motd) ||
command_add("movechar", "[Character ID|Character Name] [Zone ID|Zone Short Name] - Move an offline character to the specified zone", AccountStatus::Guide, command_movechar) ||
command_add("movement", "Various movement commands", AccountStatus::GMMgmt, command_movement) ||
@@ -230,8 +230,8 @@ int command_init(void)
command_add("nukeitem", "[Item ID] - Removes the specified Item ID from you or your player target's inventory", AccountStatus::GMLeadAdmin, command_nukeitem) ||
command_add("object", "List|Add|Edit|Move|Rotate|Copy|Save|Undo|Delete - Manipulate static and tradeskill objects within the zone", AccountStatus::GMAdmin, command_object) ||
command_add("oocmute", "[0|1] - Enable or Disable Server OOC", AccountStatus::GMMgmt, command_oocmute) ||
command_add("opcode", "- opcode management", AccountStatus::GMImpossible, command_opcode) ||
command_add("path", "- view and edit pathing", AccountStatus::GMMgmt, command_path) ||
command_add("opcode", "opcode management", AccountStatus::GMImpossible, command_opcode) ||
command_add("path", "view and edit pathing", AccountStatus::GMMgmt, command_path) ||
command_add("peekinv", "[equip/gen/cursor/poss/limbo/curlim/trib/bank/shbank/allbank/trade/world/all] - Print out contents of your player target's inventory", AccountStatus::GMAdmin, command_peekinv) ||
command_add("peqzone", "[Zone ID|Zone Short Name] - Teleports you to the specified zone if you meet the requirements.", AccountStatus::Player, command_peqzone) ||
command_add("peqzone_flags", "displays the PEQZone Flags of you or your target", AccountStatus::Player, command_peqzone_flags) ||
@@ -315,8 +315,8 @@ int command_init(void)
command_add("time", "[Hour] [Minute] - Set world time to specified time", AccountStatus::EQSupport, command_time) ||
command_add("timers", "Display persistent timers for target", AccountStatus::GMMgmt, command_timers) ||
command_add("timezone", "[Hour] [Minutes] - Set timezone (Minutes are optional)", AccountStatus::EQSupport, command_timezone) ||
command_add("title", "[Remove|Title] [Save (0 = False, 1 = True)] - Set your or your player target's title (use remove to remove title, Save defaults to false if not used)", AccountStatus::Guide, command_title) ||
command_add("titlesuffix", "[Remove|Title Suffix] [Save (0 = False, 1 = True)] - Set your or your player target's title suffix (use remove to remove title suffix, Save defaults to false if not used)", AccountStatus::Guide, command_titlesuffix) ||
command_add("title", "[Title] - Set your or your player target's title (use \"-1\" to remove title)", AccountStatus::Guide, command_title) ||
command_add("titlesuffix", "[Title Suffix] - Set your or your player target's title suffix (use \"-1\" to remove title suffix)", AccountStatus::Guide, command_titlesuffix) ||
command_add("traindisc", "[level] - Trains all the disciplines usable by the target, up to level specified. (may freeze client for a few seconds)", AccountStatus::GMLeadAdmin, command_traindisc) ||
command_add("trapinfo", "Gets infomation about the traps currently spawned in the zone.", AccountStatus::QuestTroupe, command_trapinfo) ||
command_add("tune", "Calculate statistical values related to combat.", AccountStatus::GMAdmin, command_tune) ||
+17 -6
View File
@@ -9,20 +9,31 @@ void command_lastname(Client *c, const Seperator *sep)
LogInfo("#lastname request from [{}] for [{}]", c->GetCleanName(), target->GetCleanName());
std::string last_name = sep->arg[1];
bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string last_name = is_remove ? "" : sep->argplus[1];
if (last_name.size() > 64) {
c->Message(Chat::White, "Usage: #lastname [Last Name] (Last Name must be 64 characters or less)");
c->Message(Chat::White, "Last name must be 64 characters or less.");
return;
}
target->ChangeLastName(last_name);
c->Message(
Chat::White,
fmt::format(
"{} now {} a last name of '{}'.",
c->GetTargetDescription(target, TargetDescriptionType::UCYou),
c == target ? "have" : "has",
last_name
"Last name has been {}{} for {}{}",
is_remove ? "removed" : "changed",
!is_remove ? " and saved" : "",
c->GetTargetDescription(target),
(
is_remove ?
"." :
fmt::format(
" to '{}'.",
last_name
)
)
).c_str()
);
}
+2444 -1302
View File
File diff suppressed because it is too large Load Diff
+6 -10
View File
@@ -5,16 +5,12 @@ void command_title(Client *c, const Seperator *sep)
{
int arguments = sep->argnum;
if (!arguments) {
c->Message(
Chat::White,
"Usage: #title [Remove|Title] [Save (0 = False, 1 = True)]"
);
c->Message(Chat::White, "Usage: #title [Title] (use \"-1\" to remove title)");
return;
}
bool is_remove = !strcasecmp(sep->arg[1], "remove");
std::string title = is_remove ? "" : sep->arg[1];
bool save_title = sep->IsNumber(2) ? atobool(sep->arg[2]) : false;
bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string title = is_remove ? "" : sep->argplus[1];
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
@@ -30,9 +26,9 @@ void command_title(Client *c, const Seperator *sep)
find_replace(title, "_", " ");
}
if (!save_title || is_remove) {
if (is_remove) {
target->SetAATitle(title);
} else if (save_title) {
} else {
title_manager.CreateNewPlayerTitle(target, title);
}
@@ -43,7 +39,7 @@ void command_title(Client *c, const Seperator *sep)
fmt::format(
"Title has been {}{} for {}{}",
is_remove ? "removed" : "changed",
!is_remove && save_title ? " and saved" : "",
!is_remove ? " and saved" : "",
c->GetTargetDescription(target),
(
is_remove ?
+6 -7
View File
@@ -7,14 +7,13 @@ void command_titlesuffix(Client *c, const Seperator *sep)
if (!arguments) {
c->Message(
Chat::White,
"Usage: #titlesuffix [Remove|Title] [Save (0 = False, 1 = True)]"
"Usage: #titlesuffix [Title Suffix] (use \"-1\" to remove title suffix)"
);
return;
}
bool is_remove = !strcasecmp(sep->arg[1], "remove");
std::string suffix = is_remove ? "" : sep->arg[1];
bool save_suffix = sep->IsNumber(2) ? atobool(sep->arg[2]) : false;
bool is_remove = !strcasecmp(sep->argplus[1], "-1");
std::string suffix = is_remove ? "" : sep->argplus[1];
auto target = c;
if (c->GetTarget() && c->GetTarget()->IsClient()) {
@@ -30,9 +29,9 @@ void command_titlesuffix(Client *c, const Seperator *sep)
find_replace(suffix, "_", " ");
}
if (!save_suffix || is_remove) {
if (is_remove) {
target->SetTitleSuffix(suffix);
} else if (save_suffix) {
} else {
title_manager.CreateNewPlayerSuffix(target, suffix);
}
@@ -43,7 +42,7 @@ void command_titlesuffix(Client *c, const Seperator *sep)
fmt::format(
"Title suffix has been {}{} for {}{}",
is_remove ? "removed" : "changed",
!is_remove && save_suffix ? " and saved" : "",
!is_remove ? " and saved" : "",
c->GetTargetDescription(target),
(
is_remove ?