Core/World: adapted Master branch version of world state handling
This commit is contained in:
1 parent
6b8314454f
commit
2521489e2b
27 files changed
+258
-152
No files matched your search
@@ -105,6 +105,10 @@ template<>
|
||||
struct is_script_database_bound<WorldMapScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<WorldStateScript>
|
||||
: std::true_type { };
|
||||
|
||||
enum Spells
|
||||
{
|
||||
SPELL_HOTSWAP_VISUAL_SPELL_EFFECT = 40162 // 59084
|
||||
@@ -1919,6 +1923,7 @@ void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newAre
|
||||
FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea);
|
||||
}
|
||||
|
||||
// Quest
|
||||
void ScriptMgr::OnQuestStatusChange(Player* player, uint32 questId)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnQuestStatusChange(player, questId);
|
||||
@@ -2074,6 +2079,15 @@ void ScriptMgr::ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& dama
|
||||
FOREACH_SCRIPT(UnitScript)->ModifySpellDamageTaken(target, attacker, damage);
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
@@ -2264,6 +2278,14 @@ GroupScript::GroupScript(char const* name)
|
||||
ScriptRegistry<GroupScript>::Instance()->AddScript(this);
|
||||
}
|
||||
|
||||
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>;
|
||||
@@ -2291,3 +2313,4 @@ template class TC_GAME_API ScriptRegistry<GuildScript>;
|
||||
template class TC_GAME_API ScriptRegistry<GroupScript>;
|
||||
template class TC_GAME_API ScriptRegistry<UnitScript>;
|
||||
template class TC_GAME_API ScriptRegistry<AccountScript>;
|
||||
template class TC_GAME_API ScriptRegistry<WorldStateScript>;
|
||||
@@ -70,6 +70,7 @@ struct CreatureData;
|
||||
struct ItemTemplate;
|
||||
struct MapEntry;
|
||||
struct Position;
|
||||
struct WorldStateTemplate;
|
||||
|
||||
enum BattlegroundTypeId : uint32;
|
||||
enum ContentLevels : uint8;
|
||||
@@ -792,6 +793,20 @@ class TC_GAME_API GroupScript : public ScriptObject
|
||||
virtual void OnDisband(Group* /*group*/) { }
|
||||
};
|
||||
|
||||
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
|
||||
{
|
||||
@@ -1046,6 +1061,10 @@ class TC_GAME_API ScriptMgr
|
||||
void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage);
|
||||
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage);
|
||||
|
||||
public: /* WorldStateScript */
|
||||
|
||||
void OnWorldStateValueChange(WorldStateTemplate const* worldStateTemplate, int32 oldValue, int32 newValue, Map const* map);
|
||||
|
||||
private:
|
||||
uint32 _scriptCount;
|
||||
|
||||
|
||||
Reference in new issue
Block a user