[Spells] Add content filtering to NPC spells (#4309)

* [Spells] Add content filtering to NPC spells

* Update mob_ai.cpp

* Add NPC spell reloading

* Oops

* Naming

---------

Co-authored-by: Kinglykrab <kinglykrab@gmail.com>
This commit is contained in:
Chris Miles 2024-05-17 10:59:20 -05:00 committed by GitHub
parent c0a8fd097e
commit 099c6d657b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
12 changed files with 221 additions and 135 deletions

View File

@ -5620,7 +5620,21 @@ ALTER TABLE `npc_types`
ADD COLUMN `greed` tinyint(8) UNSIGNED NOT NULL DEFAULT 0 AFTER `merchant_id`; ADD COLUMN `greed` tinyint(8) UNSIGNED NOT NULL DEFAULT 0 AFTER `merchant_id`;
)", )",
.content_schema_update = true .content_schema_update = true
} },
ManifestEntry{
.version = 9279,
.description = "2024_05_13_content_flagging_npc_spells_entries.sql",
.check = "SHOW COLUMNS FROM `npc_spells_entries` LIKE 'content_flags'",
.condition = "empty",
.match = "",
.sql = R"(
ALTER TABLE `npc_spells_entries` ADD `min_expansion` tinyint(4) NOT NULL DEFAULT -1;
ALTER TABLE `npc_spells_entries` ADD `max_expansion` tinyint(4) NOT NULL DEFAULT -1;
ALTER TABLE `npc_spells_entries` ADD `content_flags` varchar(100) NULL;
ALTER TABLE `npc_spells_entries` ADD `content_flags_disabled` varchar(100) NULL;
)",
.content_schema_update = true
},
// -- template; copy/paste this when you need to create a new entry // -- template; copy/paste this when you need to create a new entry
// ManifestEntry{ // ManifestEntry{
// .version = 9228, // .version = 9228,

View File

@ -31,6 +31,10 @@ public:
int32_t resist_adjust; int32_t resist_adjust;
int16_t min_hp; int16_t min_hp;
int16_t max_hp; int16_t max_hp;
int8_t min_expansion;
int8_t max_expansion;
std::string content_flags;
std::string content_flags_disabled;
}; };
static std::string PrimaryKey() static std::string PrimaryKey()
@ -53,6 +57,10 @@ public:
"resist_adjust", "resist_adjust",
"min_hp", "min_hp",
"max_hp", "max_hp",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
}; };
} }
@ -71,6 +79,10 @@ public:
"resist_adjust", "resist_adjust",
"min_hp", "min_hp",
"max_hp", "max_hp",
"min_expansion",
"max_expansion",
"content_flags",
"content_flags_disabled",
}; };
} }
@ -123,6 +135,10 @@ public:
e.resist_adjust = 0; e.resist_adjust = 0;
e.min_hp = 0; e.min_hp = 0;
e.max_hp = 0; e.max_hp = 0;
e.min_expansion = -1;
e.max_expansion = -1;
e.content_flags = "";
e.content_flags_disabled = "";
return e; return e;
} }
@ -171,6 +187,10 @@ public:
e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0; e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0; e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0; e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.min_expansion = row[12] ? static_cast<int8_t>(atoi(row[12])) : -1;
e.max_expansion = row[13] ? static_cast<int8_t>(atoi(row[13])) : -1;
e.content_flags = row[14] ? row[14] : "";
e.content_flags_disabled = row[15] ? row[15] : "";
return e; return e;
} }
@ -215,6 +235,10 @@ public:
v.push_back(columns[9] + " = " + std::to_string(e.resist_adjust)); v.push_back(columns[9] + " = " + std::to_string(e.resist_adjust));
v.push_back(columns[10] + " = " + std::to_string(e.min_hp)); v.push_back(columns[10] + " = " + std::to_string(e.min_hp));
v.push_back(columns[11] + " = " + std::to_string(e.max_hp)); v.push_back(columns[11] + " = " + std::to_string(e.max_hp));
v.push_back(columns[12] + " = " + std::to_string(e.min_expansion));
v.push_back(columns[13] + " = " + std::to_string(e.max_expansion));
v.push_back(columns[14] + " = '" + Strings::Escape(e.content_flags) + "'");
v.push_back(columns[15] + " = '" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@ -248,6 +272,10 @@ public:
v.push_back(std::to_string(e.resist_adjust)); v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp)); v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp)); v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@ -289,6 +317,10 @@ public:
v.push_back(std::to_string(e.resist_adjust)); v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp)); v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp)); v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
} }
@ -334,6 +366,10 @@ public:
e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0; e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0; e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0; e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.min_expansion = row[12] ? static_cast<int8_t>(atoi(row[12])) : -1;
e.max_expansion = row[13] ? static_cast<int8_t>(atoi(row[13])) : -1;
e.content_flags = row[14] ? row[14] : "";
e.content_flags_disabled = row[15] ? row[15] : "";
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -370,6 +406,10 @@ public:
e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0; e.resist_adjust = row[9] ? static_cast<int32_t>(atoi(row[9])) : 0;
e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0; e.min_hp = row[10] ? static_cast<int16_t>(atoi(row[10])) : 0;
e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0; e.max_hp = row[11] ? static_cast<int16_t>(atoi(row[11])) : 0;
e.min_expansion = row[12] ? static_cast<int8_t>(atoi(row[12])) : -1;
e.max_expansion = row[13] ? static_cast<int8_t>(atoi(row[13])) : -1;
e.content_flags = row[14] ? row[14] : "";
e.content_flags_disabled = row[15] ? row[15] : "";
all_entries.push_back(e); all_entries.push_back(e);
} }
@ -456,6 +496,10 @@ public:
v.push_back(std::to_string(e.resist_adjust)); v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp)); v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp)); v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
auto results = db.QueryDatabase( auto results = db.QueryDatabase(
fmt::format( fmt::format(
@ -490,6 +534,10 @@ public:
v.push_back(std::to_string(e.resist_adjust)); v.push_back(std::to_string(e.resist_adjust));
v.push_back(std::to_string(e.min_hp)); v.push_back(std::to_string(e.min_hp));
v.push_back(std::to_string(e.max_hp)); v.push_back(std::to_string(e.max_hp));
v.push_back(std::to_string(e.min_expansion));
v.push_back(std::to_string(e.max_expansion));
v.push_back("'" + Strings::Escape(e.content_flags) + "'");
v.push_back("'" + Strings::Escape(e.content_flags_disabled) + "'");
insert_chunks.push_back("(" + Strings::Implode(",", v) + ")"); insert_chunks.push_back("(" + Strings::Implode(",", v) + ")");
} }

View File

@ -277,6 +277,7 @@
#define ServerOP_ReloadLoot 0x4127 #define ServerOP_ReloadLoot 0x4127
#define ServerOP_ReloadBaseData 0x4128 #define ServerOP_ReloadBaseData 0x4128
#define ServerOP_ReloadSkillCaps 0x4129 #define ServerOP_ReloadSkillCaps 0x4129
#define ServerOP_ReloadNPCSpells 0x4130
#define ServerOP_CZDialogueWindow 0x4500 #define ServerOP_CZDialogueWindow 0x4500
#define ServerOP_CZLDoNUpdate 0x4501 #define ServerOP_CZLDoNUpdate 0x4501

View File

@ -42,7 +42,7 @@
* Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt * Manifest: https://github.com/EQEmu/Server/blob/master/utils/sql/db_update_manifest.txt
*/ */
#define CURRENT_BINARY_DATABASE_VERSION 9278 #define CURRENT_BINARY_DATABASE_VERSION 9279
#define CURRENT_BINARY_BOTS_DATABASE_VERSION 9044 #define CURRENT_BINARY_BOTS_DATABASE_VERSION 9044
#endif #endif

View File

@ -152,6 +152,7 @@ std::vector<Reload> reload_types = {
Reload{.command = "loot", .opcode = ServerOP_ReloadLoot, .desc = "Loot"}, Reload{.command = "loot", .opcode = ServerOP_ReloadLoot, .desc = "Loot"},
Reload{.command = "merchants", .opcode = ServerOP_ReloadMerchants, .desc = "Merchants"}, Reload{.command = "merchants", .opcode = ServerOP_ReloadMerchants, .desc = "Merchants"},
Reload{.command = "npc_emotes", .opcode = ServerOP_ReloadNPCEmotes, .desc = "NPC Emotes"}, Reload{.command = "npc_emotes", .opcode = ServerOP_ReloadNPCEmotes, .desc = "NPC Emotes"},
Reload{.command = "npc_spells", .opcode = ServerOP_ReloadNPCSpells, .desc = "NPC Spells"},
Reload{.command = "objects", .opcode = ServerOP_ReloadObjects, .desc = "Objects"}, Reload{.command = "objects", .opcode = ServerOP_ReloadObjects, .desc = "Objects"},
Reload{.command = "opcodes", .opcode = ServerOP_ReloadOpcodes, .desc = "Opcodes"}, Reload{.command = "opcodes", .opcode = ServerOP_ReloadOpcodes, .desc = "Opcodes"},
Reload{.command = "perl_export", .opcode = ServerOP_ReloadPerlExportSettings, .desc = "Perl Event Export Settings"}, Reload{.command = "perl_export", .opcode = ServerOP_ReloadPerlExportSettings, .desc = "Perl Event Export Settings"},

View File

@ -1410,6 +1410,7 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
case ServerOP_ReloadLevelEXPMods: case ServerOP_ReloadLevelEXPMods:
case ServerOP_ReloadMerchants: case ServerOP_ReloadMerchants:
case ServerOP_ReloadNPCEmotes: case ServerOP_ReloadNPCEmotes:
case ServerOP_ReloadNPCSpells:
case ServerOP_ReloadObjects: case ServerOP_ReloadObjects:
case ServerOP_ReloadPerlExportSettings: case ServerOP_ReloadPerlExportSettings:
case ServerOP_ReloadStaticZoneData: case ServerOP_ReloadStaticZoneData:

View File

@ -9367,6 +9367,7 @@ void Client::ShowDevToolsMenu()
menu_reload_five += Saylink::Silent("#reload merchants", "Merchants"); menu_reload_five += Saylink::Silent("#reload merchants", "Merchants");
menu_reload_five += " | " + Saylink::Silent("#reload npc_emotes", "NPC Emotes"); menu_reload_five += " | " + Saylink::Silent("#reload npc_emotes", "NPC Emotes");
menu_reload_five += " | " + Saylink::Silent("#reload npc_spells", "NPC Spells");
menu_reload_five += " | " + Saylink::Silent("#reload objects", "Objects"); menu_reload_five += " | " + Saylink::Silent("#reload objects", "Objects");
menu_reload_five += " | " + Saylink::Silent("#reload opcodes", "Opcodes"); menu_reload_five += " | " + Saylink::Silent("#reload opcodes", "Opcodes");
@ -11448,6 +11449,15 @@ void Client::SendReloadCommandMessages() {
).c_str() ).c_str()
); );
auto npc_spells_link = Saylink::Silent("#reload npc_spells");
Message(
Chat::White,
fmt::format(
"Usage: {} - Reloads NPC Spells globally",
npc_spells_link
).c_str()
);
auto objects_link = Saylink::Silent("#reload objects"); auto objects_link = Saylink::Silent("#reload objects");
Message( Message(

View File

@ -29,6 +29,7 @@ void command_reload(Client *c, const Seperator *sep)
bool is_loot = !strcasecmp(sep->arg[1], "loot"); bool is_loot = !strcasecmp(sep->arg[1], "loot");
bool is_merchants = !strcasecmp(sep->arg[1], "merchants"); bool is_merchants = !strcasecmp(sep->arg[1], "merchants");
bool is_npc_emotes = !strcasecmp(sep->arg[1], "npc_emotes"); bool is_npc_emotes = !strcasecmp(sep->arg[1], "npc_emotes");
bool is_npc_spells = !strcasecmp(sep->arg[1], "npc_spells");
bool is_objects = !strcasecmp(sep->arg[1], "objects"); bool is_objects = !strcasecmp(sep->arg[1], "objects");
bool is_opcodes = !strcasecmp(sep->arg[1], "opcodes") || is_opcodes_reload_alias; bool is_opcodes = !strcasecmp(sep->arg[1], "opcodes") || is_opcodes_reload_alias;
bool is_perl_export = !strcasecmp(sep->arg[1], "perl_export"); bool is_perl_export = !strcasecmp(sep->arg[1], "perl_export");
@ -62,6 +63,7 @@ void command_reload(Client *c, const Seperator *sep)
!is_loot && !is_loot &&
!is_merchants && !is_merchants &&
!is_npc_emotes && !is_npc_emotes &&
!is_npc_spells &&
!is_objects && !is_objects &&
!is_opcodes && !is_opcodes &&
!is_perl_export && !is_perl_export &&
@ -137,6 +139,9 @@ void command_reload(Client *c, const Seperator *sep)
} else if (is_npc_emotes) { } else if (is_npc_emotes) {
c->Message(Chat::White, "Attempting to reload NPC Emotes globally."); c->Message(Chat::White, "Attempting to reload NPC Emotes globally.");
pack = new ServerPacket(ServerOP_ReloadNPCEmotes, 0); pack = new ServerPacket(ServerOP_ReloadNPCEmotes, 0);
} else if (is_npc_spells) {
c->Message(Chat::White, "Attempting to reload NPC Spells globally.");
pack = new ServerPacket(ServerOP_ReloadNPCSpells, 0);
} else if (is_objects) { } else if (is_objects) {
c->Message(Chat::White, "Attempting to reload Objects globally."); c->Message(Chat::White, "Attempting to reload Objects globally.");
pack = new ServerPacket(ServerOP_ReloadObjects, 0); pack = new ServerPacket(ServerOP_ReloadObjects, 0);

View File

@ -33,6 +33,9 @@
#include "../common/data_verification.h" #include "../common/data_verification.h"
#include "bot.h" #include "bot.h"
#include "../common/repositories/npc_spells_repository.h"
#include "../common/repositories/npc_spells_entries_repository.h"
#include "../common/repositories/criteria/content_filter_criteria.h"
#include <glm/gtx/projection.hpp> #include <glm/gtx/projection.hpp>
#include <algorithm> #include <algorithm>
@ -2841,101 +2844,91 @@ void NPC::AISpellsList(Client *c)
return; return;
} }
DBnpcspells_Struct *ZoneDatabase::GetNPCSpells(uint32 iDBSpellsID) DBnpcspells_Struct *ZoneDatabase::GetNPCSpells(uint32 npc_spells_id)
{ {
if (iDBSpellsID == 0) if (npc_spells_id == 0) {
return nullptr; return nullptr;
}
auto it = npc_spells_cache.find(iDBSpellsID); auto it = npc_spells_cache.find(npc_spells_id);
if (it != npc_spells_cache.end()) { // it's in the cache, easy =) if (it != npc_spells_cache.end()) { // it's in the cache, easy =)
return &it->second; return &it->second;
} }
if (!npc_spells_loadtried.count(iDBSpellsID)) { // no reason to ask the DB again if we have failed once already if (!npc_spells_loadtried.count(npc_spells_id)) { // no reason to ask the DB again if we have failed once already
npc_spells_loadtried.insert(iDBSpellsID); npc_spells_loadtried.insert(npc_spells_id);
std::string query = StringFormat("SELECT id, parent_list, attack_proc, proc_chance, " auto ns = NpcSpellsRepository::FindOne(*this, npc_spells_id);
"range_proc, rproc_chance, defensive_proc, dproc_chance, " if (!ns.id) {
"fail_recast, engaged_no_sp_recast_min, engaged_no_sp_recast_max, "
"engaged_b_self_chance, engaged_b_other_chance, engaged_d_chance, "
"pursue_no_sp_recast_min, pursue_no_sp_recast_max, "
"pursue_d_chance, idle_no_sp_recast_min, idle_no_sp_recast_max, "
"idle_b_chance FROM npc_spells WHERE id=%d",
iDBSpellsID);
auto results = QueryDatabase(query);
if (!results.Success()) {
return nullptr; return nullptr;
} }
if (results.RowCount() != 1) DBnpcspells_Struct ss;
return nullptr;
auto row = results.begin(); ss.parent_list = ns.parent_list;
DBnpcspells_Struct spell_set; ss.attack_proc = ns.attack_proc;
ss.proc_chance = ns.proc_chance;
ss.range_proc = ns.range_proc;
ss.rproc_chance = ns.rproc_chance;
ss.defensive_proc = ns.defensive_proc;
ss.dproc_chance = ns.dproc_chance;
ss.fail_recast = ns.fail_recast;
ss.engaged_no_sp_recast_min = ns.engaged_no_sp_recast_min;
ss.engaged_no_sp_recast_max = ns.engaged_no_sp_recast_max;
ss.engaged_beneficial_self_chance = ns.engaged_b_self_chance;
ss.engaged_beneficial_other_chance = ns.engaged_b_other_chance;
ss.engaged_detrimental_chance = ns.engaged_d_chance;
ss.pursue_no_sp_recast_min = ns.pursue_no_sp_recast_min;
ss.pursue_no_sp_recast_max = ns.pursue_no_sp_recast_max;
ss.pursue_detrimental_chance = ns.pursue_d_chance;
ss.idle_no_sp_recast_min = ns.idle_no_sp_recast_min;
ss.idle_no_sp_recast_max = ns.idle_no_sp_recast_max;
ss.idle_beneficial_chance = ns.idle_b_chance;
spell_set.parent_list = Strings::ToInt(row[1]); auto entries = NpcSpellsEntriesRepository::GetWhere(
spell_set.attack_proc = Strings::ToInt(row[2]); *this,
spell_set.proc_chance = Strings::ToInt(row[3]); fmt::format(
spell_set.range_proc = Strings::ToInt(row[4]); "npc_spells_id = {} {} ORDER BY minlevel",
spell_set.rproc_chance = Strings::ToInt(row[5]); npc_spells_id,
spell_set.defensive_proc = Strings::ToInt(row[6]); ContentFilterCriteria::apply()
spell_set.dproc_chance = Strings::ToInt(row[7]); )
spell_set.fail_recast = Strings::ToInt(row[8]); );
spell_set.engaged_no_sp_recast_min = Strings::ToInt(row[9]);
spell_set.engaged_no_sp_recast_max = Strings::ToInt(row[10]);
spell_set.engaged_beneficial_self_chance = Strings::ToInt(row[11]);
spell_set.engaged_beneficial_other_chance = Strings::ToInt(row[12]);
spell_set.engaged_detrimental_chance = Strings::ToInt(row[13]);
spell_set.pursue_no_sp_recast_min = Strings::ToInt(row[14]);
spell_set.pursue_no_sp_recast_max = Strings::ToInt(row[15]);
spell_set.pursue_detrimental_chance = Strings::ToInt(row[16]);
spell_set.idle_no_sp_recast_min = Strings::ToInt(row[17]);
spell_set.idle_no_sp_recast_max = Strings::ToInt(row[18]);
spell_set.idle_beneficial_chance = Strings::ToInt(row[19]);
// pulling fixed values from an auto-increment field is dangerous... if (entries.empty()) {
query = StringFormat(
"SELECT spellid, type, minlevel, maxlevel, "
"manacost, recast_delay, priority, min_hp, max_hp, resist_adjust "
"FROM npc_spells_entries "
"WHERE npc_spells_id=%d ORDER BY minlevel",
iDBSpellsID);
results = QueryDatabase(query);
if (!results.Success()) {
return nullptr; return nullptr;
} }
int entryIndex = 0; for (auto &e: entries) {
for (row = results.begin(); row != results.end(); ++row, ++entryIndex) { DBnpcspells_entries_Struct se{};
DBnpcspells_entries_Struct entry;
int spell_id = Strings::ToInt(row[0]); se.spellid = e.spellid;
entry.spellid = spell_id; se.type = e.type;
entry.type = Strings::ToUnsignedInt(row[1]); se.minlevel = e.minlevel;
entry.minlevel = Strings::ToInt(row[2]); se.maxlevel = e.maxlevel;
entry.maxlevel = Strings::ToInt(row[3]); se.manacost = e.manacost;
entry.manacost = Strings::ToInt(row[4]); se.recast_delay = e.recast_delay;
entry.recast_delay = Strings::ToInt(row[5]); se.priority = e.priority;
entry.priority = Strings::ToInt(row[6]); se.min_hp = e.min_hp;
entry.min_hp = Strings::ToInt(row[7]); se.max_hp = e.max_hp;
entry.max_hp = Strings::ToInt(row[8]);
// some spell types don't make much since to be priority 0, so fix that // some spell types don't make much since to be priority 0, so fix that
if (!(entry.type & SPELL_TYPES_INNATE) && entry.priority == 0) if (!(se.type & SPELL_TYPES_INNATE) && se.priority == 0) {
entry.priority = 1; se.priority = 1;
if (row[9])
entry.resist_adjust = Strings::ToInt(row[9]);
else if (IsValidSpell(spell_id))
entry.resist_adjust = spells[spell_id].resist_difficulty;
spell_set.entries.push_back(entry);
} }
npc_spells_cache.emplace(std::make_pair(iDBSpellsID, spell_set)); if (e.resist_adjust) {
se.resist_adjust = e.resist_adjust;
}
else if (IsValidSpell(e.id)) {
se.resist_adjust = spells[e.id].resist_difficulty;
}
return &npc_spells_cache[iDBSpellsID]; ss.entries.push_back(se);
}
npc_spells_cache.emplace(std::make_pair(npc_spells_id, ss));
return &npc_spells_cache[npc_spells_id];
} }
return nullptr; return nullptr;

View File

@ -2086,6 +2086,17 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
} }
break; break;
} }
case ServerOP_ReloadNPCSpells:
{
if (zone && zone->IsLoaded()) {
zone->SendReloadMessage("NPC Spells");
content_db.ClearNPCSpells();
for (auto& e : entity_list.GetNPCList()) {
e.second->ReloadSpells();
}
}
break;
}
case ServerOP_ReloadPerlExportSettings: case ServerOP_ReloadPerlExportSettings:
{ {
zone->SendReloadMessage("Perl Event Export Settings"); zone->SendReloadMessage("Perl Event Export Settings");

View File

@ -2899,6 +2899,8 @@ std::string Zone::GetZoneDescription()
void Zone::SendReloadMessage(std::string reload_type) void Zone::SendReloadMessage(std::string reload_type)
{ {
LogInfo("Reloaded [{}]", reload_type);
worldserver.SendEmoteMessage( worldserver.SendEmoteMessage(
0, 0,
0, 0,

View File

@ -569,7 +569,7 @@ public:
bool GetAuraEntry(uint16 spell_id, AuraRecord &record); bool GetAuraEntry(uint16 spell_id, AuraRecord &record);
void LoadGlobalLoot(); void LoadGlobalLoot();
DBnpcspells_Struct* GetNPCSpells(uint32 iDBSpellsID); DBnpcspells_Struct* GetNPCSpells(uint32 npc_spells_id);
DBnpcspellseffects_Struct* GetNPCSpellsEffects(uint32 iDBSpellsEffectsID); DBnpcspellseffects_Struct* GetNPCSpellsEffects(uint32 iDBSpellsEffectsID);
void ClearNPCSpells() { npc_spells_cache.clear(); npc_spells_loadtried.clear(); } void ClearNPCSpells() { npc_spells_cache.clear(); npc_spells_loadtried.clear(); }
const NPCType* LoadNPCTypesData(uint32 id, bool bulk_load = false); const NPCType* LoadNPCTypesData(uint32 id, bool bulk_load = false);