summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKargatum <dowlandtop@yandex.ru>2018-06-23 09:33:09 +0700
committerBarbz <BarbzYHOOL@users.noreply.github.com>2018-07-08 01:04:38 +0200
commit7a5ed0c5bbcb62e0f26e8b8718b28b0bef8488e1 (patch)
tree46b58ebcbe28885d8d9d5a4bf2325f85c4adba6f
parente5d58de64134c0fa4bfec318a283a32a8ad0aed1 (diff)
Core/Scripts: Add SpellSC and new hook OnCalcMaxDuration
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp15
-rw-r--r--src/server/game/Scripting/ScriptMgr.h19
-rw-r--r--src/server/game/Spells/Auras/SpellAuras.cpp2
3 files changed, 36 insertions, 0 deletions
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 2c5b752dfa..784e831c7b 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -58,6 +58,7 @@ template class ScriptRegistry<AllCreatureScript>;
template class ScriptRegistry<AllMapScript>;
template class ScriptRegistry<MovementHandlerScript>;
template class ScriptRegistry<BGScript>;
+template class ScriptRegistry<SpellSC>;
#include "ScriptMgrMacros.h"
@@ -209,6 +210,7 @@ void ScriptMgr::Unload()
SCR_CLEAR(GlobalScript);
SCR_CLEAR(ModuleScript);
SCR_CLEAR(BGScript);
+ SCR_CLEAR(SpellSC);
#undef SCR_CLEAR
}
@@ -279,6 +281,7 @@ void ScriptMgr::CheckIfScriptsInDatabaseExist()
!ScriptRegistry<PlayerScript>::GetScriptById(sid) &&
!ScriptRegistry<GuildScript>::GetScriptById(sid) &&
!ScriptRegistry<BGScript>::GetScriptById(sid) &&
+ !ScriptRegistry<SpellSC>::GetScriptById(sid) &&
!ScriptRegistry<GroupScript>::GetScriptById(sid))
sLog->outErrorDb("Script named '%s' is assigned in database, but has no code!", (*itr).c_str());
}
@@ -1984,6 +1987,12 @@ void ScriptMgr::OnBattlegroundAddPlayer(Battleground* bg, Player* player)
FOREACH_SCRIPT(BGScript)->OnBattlegroundAddPlayer(bg, player);
}
+// SpellSC
+void ScriptMgr::OnCalcMaxDuration(Aura const* aura, int32& maxDuration)
+{
+ FOREACH_SCRIPT(SpellSC)->OnCalcMaxDuration(aura, maxDuration);
+}
+
AllMapScript::AllMapScript(const char* name)
: ScriptObject(name)
{
@@ -2165,6 +2174,12 @@ BGScript::BGScript(char const* name)
ScriptRegistry<BGScript>::AddScript(this);
}
+SpellSC::SpellSC(char const* name)
+ : ScriptObject(name)
+{
+ ScriptRegistry<SpellSC>::AddScript(this);
+}
+
ModuleScript::ModuleScript(const char* name)
: ScriptObject(name)
{
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index ac94a0fdf8..3d17d09088 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -1061,6 +1061,21 @@ public:
virtual void OnBattlegroundAddPlayer(Battleground* /*bg*/, Player* /*player*/) { }
};
+class SpellSC : public ScriptObject
+{
+protected:
+
+ SpellSC(const char* name);
+
+public:
+
+ bool IsDatabaseBound() const { return false; }
+
+ // Calculate max duration in applying aura
+ virtual void OnCalcMaxDuration(Aura const* /*aura*/, int32& /*maxDuration*/) { }
+
+};
+
// this class can be used to be extended by Modules
// creating their own custom hooks inside module itself
class ModuleScript : public ScriptObject
@@ -1387,6 +1402,10 @@ class ScriptMgr
void OnBattlegroundUpdate(Battleground* bg, uint32 diff);
void OnBattlegroundAddPlayer(Battleground* bg, Player* player);
+ public: /* SpellSC */
+
+ void OnCalcMaxDuration(Aura const* aura, int32& maxDuration);
+
private:
uint32 _scriptCount;
diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp
index 0afef3234a..a1a2281b12 100644
--- a/src/server/game/Spells/Auras/SpellAuras.cpp
+++ b/src/server/game/Spells/Auras/SpellAuras.cpp
@@ -815,6 +815,8 @@ int32 Aura::CalcMaxDuration(Unit* caster) const
if (IsPassive() && !m_spellInfo->DurationEntry)
maxDuration = -1;
+ sScriptMgr->OnCalcMaxDuration(this, maxDuration);
+
// IsPermanent() checks max duration (which we are supposed to calculate here)
if (maxDuration != -1 && modOwner)
modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration);