diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h index 869d77f9b..bc4b1391b 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -72,6 +72,7 @@ struct TargetInfo; #define VISIBLE_RANGE 166.0f //MAX visible range (size of grid) +// Check out our guide on how to create new hooks in our wiki! https://www.azerothcore.org/wiki/hooks-script /* TODO: Add more script type classes. @@ -81,72 +82,6 @@ struct TargetInfo; */ -/* - Standard procedure when adding new script type classes: - - First of all, define the actual class, and have it inherit from ScriptObject, like so: - - class MyScriptType : public ScriptObject - { - uint32 _someId; - - private: - - void RegisterSelf(); - - protected: - - MyScriptType(const char* name, uint32 someId) - : ScriptObject(name), _someId(someId) - { - ScriptRegistry::AddScript(this); - } - - public: - - // If a virtual function in your script type class is not necessarily - // required to be overridden, just declare it virtual with an empty - // body. If, on the other hand, it's logical only to override it (i.e. - // if it's the only method in the class), make it pure virtual, by adding - // = 0 to it. - virtual void OnSomeEvent(uint32 someArg1, std::string& someArg2) { } - - // This is a pure virtual function: - virtual void OnAnotherEvent(uint32 someArg) = 0; - } - - Next, you need to add a specialization for ScriptRegistry. Put this in the bottom of - ScriptMgr.cpp: - - template class ScriptRegistry; - - Now, add a cleanup routine in ScriptMgr::~ScriptMgr: - - SCR_CLEAR(MyScriptType); - - Now your script type is good to go with the script system. What you need to do now - is add functions to ScriptMgr that can be called from the core to actually trigger - certain events. For example, in ScriptMgr.h: - - void OnSomeEvent(uint32 someArg1, std::string& someArg2); - void OnAnotherEvent(uint32 someArg); - - In ScriptMgr.cpp: - - void ScriptMgr::OnSomeEvent(uint32 someArg1, std::string& someArg2) - { - FOREACH_SCRIPT(MyScriptType)->OnSomeEvent(someArg1, someArg2); - } - - void ScriptMgr::OnAnotherEvent(uint32 someArg) - { - FOREACH_SCRIPT(MyScriptType)->OnAnotherEvent(someArg1, someArg2); - } - - Now you simply call these two functions from anywhere in the core to trigger the - event on all registered scripts of that type. -*/ - class ScriptObject { friend class ScriptMgr;