mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/SAI: Implemented new source type SMART_SCRIPT_TYPE_EVENT (3) (#28816)
This commit is contained in:
@@ -87,7 +87,7 @@ struct is_script_database_bound<AreaTriggerScript>
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<BattlefieldScript>
|
||||
: std::true_type { };
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<BattlegroundScript>
|
||||
@@ -137,6 +137,10 @@ template<>
|
||||
struct is_script_database_bound<WorldStateScript>
|
||||
: std::true_type { };
|
||||
|
||||
template<>
|
||||
struct is_script_database_bound<EventScript>
|
||||
: std::true_type { };
|
||||
|
||||
enum Spells
|
||||
{
|
||||
SPELL_HOTSWAP_VISUAL_SPELL_EFFECT = 40162 // 59084
|
||||
@@ -2358,6 +2362,15 @@ void ScriptMgr::OnWorldStateValueChange(WorldStateTemplate const* worldStateTemp
|
||||
tmpscript->OnValueChange(worldStateTemplate->Id, oldValue, newValue, map);
|
||||
}
|
||||
|
||||
// Event
|
||||
void ScriptMgr::OnEventTrigger(WorldObject* object, WorldObject* invoker, uint32 eventId)
|
||||
{
|
||||
ASSERT(invoker);
|
||||
|
||||
GET_SCRIPT(EventScript, sObjectMgr->GetEventScriptId(eventId), tmpscript);
|
||||
tmpscript->OnTrigger(object, invoker, eventId);
|
||||
}
|
||||
|
||||
SpellScriptLoader::SpellScriptLoader(char const* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
@@ -3209,6 +3222,18 @@ void WorldStateScript::OnValueChange(int32 /*worldStateId*/, int32 /*oldValue*/,
|
||||
{
|
||||
}
|
||||
|
||||
EventScript::EventScript(char const* name)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
ScriptRegistry<EventScript>::Instance()->AddScript(this);
|
||||
}
|
||||
|
||||
EventScript::~EventScript() = default;
|
||||
|
||||
void EventScript::OnTrigger(WorldObject* /*object*/, WorldObject* /*invoker*/, uint32 /*eventId*/)
|
||||
{
|
||||
}
|
||||
|
||||
// Specialize for each script type class like so:
|
||||
template class TC_GAME_API ScriptRegistry<SpellScriptLoader>;
|
||||
template class TC_GAME_API ScriptRegistry<ServerScript>;
|
||||
@@ -3243,3 +3268,4 @@ 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>;
|
||||
template class TC_GAME_API ScriptRegistry<EventScript>;
|
||||
|
||||
@@ -990,6 +990,20 @@ class TC_GAME_API WorldStateScript : public ScriptObject
|
||||
virtual void OnValueChange(int32 worldStateId, int32 oldValue, int32 newValue, Map const* map);
|
||||
};
|
||||
|
||||
class TC_GAME_API EventScript : public ScriptObject
|
||||
{
|
||||
protected:
|
||||
|
||||
explicit EventScript(char const* name);
|
||||
|
||||
public:
|
||||
|
||||
~EventScript();
|
||||
|
||||
// Called when a game event is triggered
|
||||
virtual void OnTrigger(WorldObject* object, WorldObject* invoker, uint32 eventId);
|
||||
};
|
||||
|
||||
// Manages registration, loading, and execution of scripts.
|
||||
class TC_GAME_API ScriptMgr
|
||||
{
|
||||
@@ -1296,6 +1310,10 @@ class TC_GAME_API ScriptMgr
|
||||
|
||||
void OnWorldStateValueChange(WorldStateTemplate const* worldStateTemplate, int32 oldValue, int32 newValue, Map const* map);
|
||||
|
||||
public: /* EventScript */
|
||||
|
||||
void OnEventTrigger(WorldObject* object, WorldObject* invoker, uint32 eventId);
|
||||
|
||||
private:
|
||||
uint32 _scriptCount;
|
||||
bool _scriptIdUpdated;
|
||||
|
||||
Reference in New Issue
Block a user