[Commands] Cleanup #modifynpcstat Command. (#2499)

* [Commands] Cleanup #modifynpcstat Command.

Cleanup messages and logic,

Add map and loop through it to display all stats, can add to this in the future if we add more stuff modifiable by this command.

* Delete settings.json

* Update modifynpcstat.cpp

* Update modifynpcstat.cpp

* Update questmgr.h
This commit is contained in:
Kinglykrab
2022-10-29 21:22:07 -04:00
committed by GitHub
parent b512447448
commit dcbc9a358f
11 changed files with 288 additions and 192 deletions
+111 -13
View File
@@ -2,29 +2,127 @@
void command_modifynpcstat(Client *c, const Seperator *sep)
{
if (!c) {
auto arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #modifynpcstat [Stat] [Value]");
ListModifyNPCStatMap(c);
return;
}
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
}
if (sep->arg[1][0] == '\0') {
c->Message(Chat::White, "usage #modifynpcstat arg value");
auto target = c->GetTarget()->CastToNPC();
std::string stat = sep->arg[1];
std::string value = sep->arg[2] ? sep->arg[2] : "";
auto stat_description = GetModifyNPCStatDescription(stat);
if (!stat_description.length()) {
c->Message(
Chat::White,
"Args: ac, str, sta, agi, dex, wis, _int, cha, max_hp, mr, fr, cr, pr, dr, runspeed, special_attacks, "
"attack_speed, atk, accuracy, trackable, min_hit, max_hit, see_invis_undead, see_hide, see_improved_hide, "
"hp_regen, mana_regen, aggro, assist, slow_mitigation, loottable_id, healscale, spellscale"
fmt::format(
"Stat '{}' does not exist.",
stat
).c_str()
);
return;
}
if (!c->GetTarget()) {
return;
}
target->ModifyNPCStat(stat, value);
if (!c->GetTarget()->IsNPC()) {
return;
}
c->Message(
Chat::White,
fmt::format(
"Stat Modified | Target: {}",
c->GetTargetDescription(target)
).c_str()
);
c->GetTarget()->CastToNPC()->ModifyNPCStat(sep->arg[1], sep->arg[2]);
c->Message(
Chat::White,
fmt::format(
"Stat Modified | Stat: {} ({}) Value: {}",
GetModifyNPCStatDescription(stat),
stat,
value
).c_str()
);
}
std::map<std::string, std::string> GetModifyNPCStatMap()
{
std::map<std::string, std::string> identifiers_map = {
{ "ac", "Armor Class" },
{ "accuracy", "Accuracy" },
{ "aggro", "Aggro" },
{ "agi", "Agility" },
{ "assist", "Assist" },
{ "atk", "Attack" },
{ "attack_count", "Attack Count" },
{ "attack_delay", "Attack Delay" },
{ "attack_speed", "Attack Speed" },
{ "avoidance", "Avoidance" },
{ "cha", "Charisma" },
{ "cr", "Cold Resist" },
{ "dex", "Dexterity" },
{ "dr", "Disease Resist" },
{ "fr", "Fire Resist" },
{ "healscale", "Heal Scale" },
{ "heroic_strikethrough", "Heroic Strikethrough" },
{ "hp_regen", "HP Regen" },
{ "hp_regen_per_second", "HP Regen Per Second" },
{ "int", "Intelligence" },
{ "_int", "Intelligence" },
{ "level", "Level" },
{ "loottable_id", "Loottable ID" },
{ "mana_regen", "Mana Regen" },
{ "max_hit", "Maximum Damage" },
{ "min_hit", "Minimum Damage" },
{ "mr", "Magic Resist" },
{ "npc_spells_id", "NPC Spells ID" },
{ "npc_spells_effects_id", "NPC Spells Effects ID" },
{ "phr", "Physical Resist" },
{ "pr", "Poison Resist" },
{ "runspeed", "Run Speed" },
{ "see_invis", "See Invisible" },
{ "see_invis_undead", "See Invisible vs. Undead" },
{ "see_hide", "See Hide" },
{ "see_improved_hide", "See Improved Hide" },
{ "slow_mitigation", "Slow Mitigation" },
{ "special_attacks", "Special Attacks" },
{ "special_abilities", "Special Abilities" },
{ "spellscale", "Spell Scale" },
{ "sta", "Stamina" },
{ "str", "Strength" },
{ "trackable", "Trackable" },
{ "wis", "Wisdom" }
};
return identifiers_map;
}
std::string GetModifyNPCStatDescription(std::string stat)
{
if (GetModifyNPCStatMap().find(stat) != GetModifyNPCStatMap().end()) {
return GetModifyNPCStatMap().find(stat)->second;
}
return std::string();
}
void ListModifyNPCStatMap(Client *c)
{
for (const auto& s : GetModifyNPCStatMap()) {
c->Message(
Chat::White,
fmt::format(
"Usage: #modifynpcstat {} [Value] - Modifies an NPC's {}",
s.first,
s.second
).c_str()
);
}
}