[Feature] Add "Keeps Sold Items" Flag to NPCs (#2671)

# Perl
- Add `$npc->GetKeepsSoldItems()`.
- Add `$npc->SetKeepsSoldItems(keeps_sold_items)`.

# Lua
- Add `npc:GetKeepsSoldItems()`.
- Add `npc:SetKeepsSoldItems(keeps_sold_items)`.

# Notes
- Allows operators to keep specific NPCs from keeping items sold to them.
- Keeps NPCs from being cluttered with stuff like Cloth Caps, Bone Chips, etc.
This commit is contained in:
Alex King
2022-12-25 16:36:20 -05:00
committed by GitHub
parent 2ed73199bf
commit a590ea1d52
19 changed files with 696 additions and 415 deletions
+2 -1
View File
@@ -8,7 +8,7 @@ void command_modifynpcstat(Client *c, const Seperator *sep)
ListModifyNPCStatMap(c);
return;
}
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "You must target an NPC to use this command.");
return;
@@ -76,6 +76,7 @@ std::map<std::string, std::string> GetModifyNPCStatMap()
{ "hp_regen_per_second", "HP Regen Per Second" },
{ "int", "Intelligence" },
{ "_int", "Intelligence" },
{ "keeps_sold_items", "Keeps Sold Items" },
{ "level", "Level" },
{ "loottable_id", "Loottable ID" },
{ "mana_regen", "Mana Regen" },
+20
View File
@@ -1491,6 +1491,22 @@ void command_npcedit(Client *c, const Seperator *sep)
);
return;
}
} else if (!strcasecmp(sep->arg[1], "keeps_sold_items")) {
if (sep->IsNumber(2)) {
auto keeps_sold_items = static_cast<uint8_t>(std::stoul(sep->arg[2]));
n.keeps_sold_items = keeps_sold_items;
d = fmt::format(
"{} will {} Keep Sold Items.",
npc_id_string,
keeps_sold_items ? "now" : "no longer"
);
} else {
c->Message(
Chat::White,
"Usage: #npcedit keeps_sold_items [Flag] - Sets an NPC's Keeps Sold Items Flag [0 = False, 1 = True]"
);
return;
}
} else if (!strcasecmp(sep->arg[1], "setanimation")) {
if (sep->IsNumber(2)) {
auto animation_id = std::stoul(sep->arg[2]);
@@ -1760,6 +1776,10 @@ void SendNPCEditSubCommands(Client *c)
Chat::White,
"Usage: #npcedit exp_mod [Modifier] - Sets an NPC's Experience Modifier [50 = 50%, 100 = 100%, 200 = 200%]"
);
c->Message(
Chat::White,
"Usage: #npcedit keeps_sold_items [Flag] - Sets an NPC's Keeps Sold Items Flag [0 = False, 1 = True]"
);
c->Message(
Chat::White,
"Usage: #npcedit setanimation [Animation ID] - Sets an NPC's Animation on Spawn (Stored in spawn2 table)"