mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/World: implement database support for default map and realm wide world states
Co-Authored-By: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
@@ -133,6 +133,10 @@ template<>
|
||||
struct is_script_database_bound<QuestScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<WorldStateScript>
|
||||
: std::true_type { };
|
||||
|
||||
enum Spells
|
||||
{
|
||||
SPELL_HOTSWAP_VISUAL_SPELL_EFFECT = 40162 // 59084
|
||||
@@ -2322,6 +2326,7 @@ void ScriptMgr::OnSceneComplete(Player* player, uint32 sceneInstanceID, SceneTem
|
||||
tmpscript->OnSceneComplete(player, sceneInstanceID, sceneTemplate);
|
||||
}
|
||||
|
||||
// Quest
|
||||
void ScriptMgr::OnQuestStatusChange(Player* player, Quest const* quest, QuestStatus oldStatus, QuestStatus newStatus)
|
||||
{
|
||||
ASSERT(player);
|
||||
@@ -2349,6 +2354,15 @@ void ScriptMgr::OnQuestObjectiveChange(Player* player, Quest const* quest, Quest
|
||||
tmpscript->OnQuestObjectiveChange(player, quest, objective, oldAmount, newAmount);
|
||||
}
|
||||
|
||||
// WorldState
|
||||
void ScriptMgr::OnWorldStateValueChange(WorldStateTemplate const* worldStateTemplate, int32 oldValue, int32 newValue, Map const* map)
|
||||
{
|
||||
ASSERT(worldStateTemplate);
|
||||
|
||||
GET_SCRIPT(WorldStateScript, worldStateTemplate->ScriptId, tmpscript);
|
||||
tmpscript->OnValueChange(worldStateTemplate->Id, oldValue, newValue, map);
|
||||
}
|
||||
|
||||
SpellScriptLoader::SpellScriptLoader(char const* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
@@ -2638,6 +2652,14 @@ QuestScript::QuestScript(char const* name)
|
||||
|
||||
QuestScript::~QuestScript() = default;
|
||||
|
||||
WorldStateScript::WorldStateScript(char const* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
ScriptRegistry<WorldStateScript>::Instance()->AddScript(this);
|
||||
}
|
||||
|
||||
WorldStateScript::~WorldStateScript() = default;
|
||||
|
||||
// Specialize for each script type class like so:
|
||||
template class TC_GAME_API ScriptRegistry<SpellScriptLoader>;
|
||||
template class TC_GAME_API ScriptRegistry<ServerScript>;
|
||||
@@ -2671,3 +2693,4 @@ template class TC_GAME_API ScriptRegistry<AreaTriggerEntityScript>;
|
||||
template class TC_GAME_API ScriptRegistry<ConversationScript>;
|
||||
template class TC_GAME_API ScriptRegistry<SceneScript>;
|
||||
template class TC_GAME_API ScriptRegistry<QuestScript>;
|
||||
template class TC_GAME_API ScriptRegistry<WorldStateScript>;
|
||||
|
||||
@@ -77,6 +77,7 @@ struct MapEntry;
|
||||
struct Position;
|
||||
struct QuestObjective;
|
||||
struct SceneTemplate;
|
||||
struct WorldStateTemplate;
|
||||
|
||||
namespace Trinity::ChatCommands { struct ChatCommandBuilder; }
|
||||
|
||||
@@ -987,6 +988,20 @@ class TC_GAME_API QuestScript : public ScriptObject
|
||||
virtual void OnQuestObjectiveChange(Player* /*player*/, Quest const* /*quest*/, QuestObjective const& /*objective*/, int32 /*oldAmount*/, int32 /*newAmount*/) { }
|
||||
};
|
||||
|
||||
class TC_GAME_API WorldStateScript : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
|
||||
WorldStateScript(char const* name);
|
||||
|
||||
public:
|
||||
|
||||
~WorldStateScript();
|
||||
|
||||
// Called when worldstate changes value, map is optional
|
||||
virtual void OnValueChange([[maybe_unused]] int32 worldStateId, [[maybe_unused]] int32 oldValue, [[maybe_unused]] int32 newValue, [[maybe_unused]] Map const* map) { }
|
||||
};
|
||||
|
||||
// Manages registration, loading, and execution of scripts.
|
||||
class TC_GAME_API ScriptMgr
|
||||
{
|
||||
@@ -1289,6 +1304,10 @@ class TC_GAME_API ScriptMgr
|
||||
void OnQuestAcknowledgeAutoAccept(Player* player, Quest const* quest);
|
||||
void OnQuestObjectiveChange(Player* player, Quest const* quest, QuestObjective const& objective, int32 oldAmount, int32 newAmount);
|
||||
|
||||
public: /* WorldStateScript */
|
||||
|
||||
void OnWorldStateValueChange(WorldStateTemplate const* worldStateTemplate, int32 oldValue, int32 newValue, Map const* map);
|
||||
|
||||
private:
|
||||
uint32 _scriptCount;
|
||||
bool _scriptIdUpdated;
|
||||
|
||||
Reference in New Issue
Block a user