mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Dynamic Zones] Implement dz templates (#2345)
This allows shared tasks to create dz instances automatically through the `dz_template_id` field instead of using quest scripts. Quest apis were also added to create expeditions from template ids.
This commit is contained in:
@@ -9842,6 +9842,19 @@ Expedition* Client::CreateExpedition(
|
||||
return Expedition::TryCreate(this, dz, disable_messages);
|
||||
}
|
||||
|
||||
Expedition* Client::CreateExpeditionFromTemplate(uint32_t dz_template_id)
|
||||
{
|
||||
Expedition* expedition = nullptr;
|
||||
auto it = zone->dz_template_cache.find(dz_template_id);
|
||||
if (it != zone->dz_template_cache.end())
|
||||
{
|
||||
DynamicZone dz(DynamicZoneType::Expedition);
|
||||
dz.LoadTemplate(it->second);
|
||||
expedition = Expedition::TryCreate(this, dz, false);
|
||||
}
|
||||
return expedition;
|
||||
}
|
||||
|
||||
void Client::CreateTaskDynamicZone(int task_id, DynamicZone& dz_request)
|
||||
{
|
||||
if (task_state)
|
||||
@@ -11332,6 +11345,9 @@ void Client::SendReloadCommandMessages() {
|
||||
).c_str()
|
||||
);
|
||||
|
||||
auto dztemplates_link = Saylink::Create("#reload dztemplates", false, "#reload dztemplates");
|
||||
Message(Chat::White, fmt::format("Usage: {} - Reloads Dynamic Zone Templates globally", dztemplates_link).c_str());
|
||||
|
||||
auto ground_spawns_link = Saylink::Create(
|
||||
"#reload ground_spawns",
|
||||
false,
|
||||
|
||||
@@ -1389,6 +1389,7 @@ public:
|
||||
Expedition* CreateExpedition(const std::string& zone_name,
|
||||
uint32 version, uint32 duration, const std::string& expedition_name,
|
||||
uint32 min_players, uint32 max_players, bool disable_messages = false);
|
||||
Expedition* CreateExpeditionFromTemplate(uint32_t dz_template_id);
|
||||
Expedition* GetExpedition() const;
|
||||
uint32 GetExpeditionID() const { return m_expedition_id; }
|
||||
const ExpeditionLockoutTimer* GetExpeditionLockout(
|
||||
|
||||
@@ -13,6 +13,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
bool is_blocked_spells = !strcasecmp(sep->arg[1], "blocked_spells");
|
||||
bool is_content_flags = !strcasecmp(sep->arg[1], "content_flags");
|
||||
bool is_doors = !strcasecmp(sep->arg[1], "doors");
|
||||
bool is_dztemplates = !strcasecmp(sep->arg[1], "dztemplates");
|
||||
bool is_ground_spawns = !strcasecmp(sep->arg[1], "ground_spawns");
|
||||
bool is_level_mods = !strcasecmp(sep->arg[1], "level_mods");
|
||||
bool is_logs = !strcasecmp(sep->arg[1], "logs");
|
||||
@@ -38,6 +39,7 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
!is_blocked_spells &&
|
||||
!is_content_flags &&
|
||||
!is_doors &&
|
||||
!is_dztemplates &&
|
||||
!is_ground_spawns &&
|
||||
!is_level_mods &&
|
||||
!is_logs &&
|
||||
@@ -78,6 +80,9 @@ void command_reload(Client *c, const Seperator *sep)
|
||||
} else if (is_doors) {
|
||||
c->Message(Chat::White, "Attempting to reload Doors globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadDoors, 0);
|
||||
} else if (is_dztemplates) {
|
||||
c->Message(Chat::White, "Attempting to reload Dynamic Zone Templates globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadDzTemplates, 0);
|
||||
} else if (is_ground_spawns) {
|
||||
c->Message(Chat::White, "Attempting to reload Ground Spawns globally.");
|
||||
pack = new ServerPacket(ServerOP_ReloadGroundSpawns, 0);
|
||||
|
||||
@@ -1973,6 +1973,11 @@ Lua_Expedition Lua_Client::CreateExpedition(std::string zone_name, uint32 versio
|
||||
return self->CreateExpedition(zone_name, version, duration, expedition_name, min_players, max_players, disable_messages);
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::CreateExpeditionFromTemplate(uint32_t dz_template_id) {
|
||||
Lua_Safe_Call_Class(Lua_Expedition);
|
||||
return self->CreateExpeditionFromTemplate(dz_template_id);
|
||||
}
|
||||
|
||||
Lua_Expedition Lua_Client::GetExpedition() {
|
||||
Lua_Safe_Call_Class(Lua_Expedition);
|
||||
return self->GetExpedition();
|
||||
@@ -2604,6 +2609,7 @@ luabind::scope lua_register_client() {
|
||||
.def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(luabind::object))&Lua_Client::CreateExpedition)
|
||||
.def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(std::string, uint32, uint32, std::string, uint32, uint32))&Lua_Client::CreateExpedition)
|
||||
.def("CreateExpedition", (Lua_Expedition(Lua_Client::*)(std::string, uint32, uint32, std::string, uint32, uint32, bool))&Lua_Client::CreateExpedition)
|
||||
.def("CreateExpeditionFromTemplate", &Lua_Client::CreateExpeditionFromTemplate)
|
||||
.def("CreateTaskDynamicZone", &Lua_Client::CreateTaskDynamicZone)
|
||||
.def("DecreaseByID", (bool(Lua_Client::*)(uint32,int))&Lua_Client::DecreaseByID)
|
||||
.def("DeleteItemInInventory", (void(Lua_Client::*)(int,int))&Lua_Client::DeleteItemInInventory)
|
||||
|
||||
@@ -433,6 +433,7 @@ public:
|
||||
Lua_Expedition CreateExpedition(luabind::object expedition_info);
|
||||
Lua_Expedition CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players);
|
||||
Lua_Expedition CreateExpedition(std::string zone_name, uint32 version, uint32 duration, std::string expedition_name, uint32 min_players, uint32 max_players, bool disable_messages);
|
||||
Lua_Expedition CreateExpeditionFromTemplate(uint32_t dz_template_id);
|
||||
Lua_Expedition GetExpedition();
|
||||
luabind::object GetExpeditionLockouts(lua_State* L);
|
||||
luabind::object GetExpeditionLockouts(lua_State* L, std::string expedition_name);
|
||||
|
||||
@@ -1804,6 +1804,11 @@ Expedition* Perl_Client_CreateExpedition(Client* self, std::string zone_name, ui
|
||||
return self->CreateExpedition(zone_name, version, duration, expedition_name, min_players, max_players, disable_messages);
|
||||
}
|
||||
|
||||
Expedition* Perl_Client_CreateExpeditionFromTemplate(Client* self, uint32_t dz_template_id)
|
||||
{
|
||||
return self->CreateExpeditionFromTemplate(dz_template_id);
|
||||
}
|
||||
|
||||
void Perl_Client_CreateTaskDynamicZone(Client* self, int task_id, perl::reference table_ref)
|
||||
{
|
||||
perl::hash table = table_ref;
|
||||
@@ -2452,6 +2457,7 @@ void perl_register_client()
|
||||
package.add("CreateExpedition", (Expedition*(*)(Client*, perl::reference))&Perl_Client_CreateExpedition);
|
||||
package.add("CreateExpedition", (Expedition*(*)(Client*, std::string, uint32, uint32, std::string, uint32, uint32))&Perl_Client_CreateExpedition);
|
||||
package.add("CreateExpedition", (Expedition*(*)(Client*, std::string, uint32, uint32, std::string, uint32, uint32, bool))&Perl_Client_CreateExpedition);
|
||||
package.add("CreateExpeditionFromTemplate", &Perl_Client_CreateExpeditionFromTemplate);
|
||||
package.add("CreateTaskDynamicZone", &Perl_Client_CreateTaskDynamicZone);
|
||||
package.add("DecreaseByID", &Perl_Client_DecreaseByID);
|
||||
package.add("DeleteItemInInventory", (void(*)(Client*, int16))&Perl_Client_DeleteItemInInventory);
|
||||
|
||||
@@ -1929,6 +1929,15 @@ void WorldServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p)
|
||||
entity_list.RespawnAllDoors();
|
||||
break;
|
||||
}
|
||||
case ServerOP_ReloadDzTemplates:
|
||||
{
|
||||
if (zone)
|
||||
{
|
||||
zone->SendReloadMessage("Dynamic Zone Templates");
|
||||
zone->LoadDynamicZoneTemplates();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ServerOP_ReloadGroundSpawns:
|
||||
{
|
||||
zone->SendReloadMessage("Ground Spawns");
|
||||
|
||||
@@ -1192,6 +1192,8 @@ bool Zone::Init(bool is_static) {
|
||||
petition_list.ClearPetitions();
|
||||
petition_list.ReadDatabase();
|
||||
|
||||
LoadDynamicZoneTemplates();
|
||||
|
||||
LogInfo("Loading dynamic zones");
|
||||
DynamicZone::CacheAllFromDatabase();
|
||||
|
||||
@@ -2812,3 +2814,13 @@ void Zone::SendDiscordMessage(const std::string& webhook_name, const std::string
|
||||
LogDiscord("[SendDiscordMessage] Did not find valid webhook by webhook name [{}]", webhook_name);
|
||||
}
|
||||
}
|
||||
|
||||
void Zone::LoadDynamicZoneTemplates()
|
||||
{
|
||||
dz_template_cache.clear();
|
||||
auto dz_templates = DynamicZoneTemplatesRepository::All(content_db);
|
||||
for (const auto& dz_template : dz_templates)
|
||||
{
|
||||
dz_template_cache[dz_template.id] = dz_template;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include "global_loot_manager.h"
|
||||
#include "queryserv.h"
|
||||
#include "../common/discord/discord.h"
|
||||
#include "../common/repositories/dynamic_zone_templates_repository.h"
|
||||
|
||||
class DynamicZone;
|
||||
|
||||
@@ -227,6 +228,7 @@ public:
|
||||
|
||||
std::unordered_map<uint32, std::unique_ptr<DynamicZone>> dynamic_zone_cache;
|
||||
std::unordered_map<uint32, std::unique_ptr<Expedition>> expedition_cache;
|
||||
std::unordered_map<uint32, DynamicZoneTemplatesRepository::DynamicZoneTemplates> dz_template_cache;
|
||||
|
||||
time_t weather_timer;
|
||||
Timer spawn2_timer;
|
||||
@@ -267,6 +269,7 @@ public:
|
||||
void LoadAdventureFlavor();
|
||||
void LoadAlternateAdvancement();
|
||||
void LoadAlternateCurrencies();
|
||||
void LoadDynamicZoneTemplates();
|
||||
void LoadZoneBlockedSpells();
|
||||
void LoadLDoNTrapEntries();
|
||||
void LoadLDoNTraps();
|
||||
|
||||
Reference in New Issue
Block a user