From 25b6102a03cb4bfbe45695c0455bab463c63579b Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Tue, 14 May 2024 16:32:31 +0200 Subject: [PATCH 1/4] add cooldown to proc --- .../IcecrownCitadel/boss_sindragosa.cpp | 28 +++++++------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index d21c9935da3878..0625cd3bd63015 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -909,40 +909,32 @@ class spell_sindragosa_unchained_magic : public SpellScriptLoader { PrepareAuraScript(spell_sindragosa_unchained_magic_AuraScript); - std::map _lastMSTimeForSpell; - bool Validate(SpellInfo const* /*spellInfo*/) override { - _lastMSTimeForSpell.clear(); return true; } - bool CheckProc(ProcEventInfo& eventInfo) + bool AfterCheckProc(ProcEventInfo& /*eventInfo*/, bool isTriggeredAtSpellProcEvent) { - SpellInfo const* spellInfo = eventInfo.GetSpellInfo(); - if (!spellInfo) + if (!isTriggeredAtSpellProcEvent) + { return false; - + } uint32 currMSTime = GameTime::GetGameTimeMS().count(); - std::map::iterator itr = _lastMSTimeForSpell.find(spellInfo->Id); - if (itr != _lastMSTimeForSpell.end()) + if (_lastMSTime && getMSTimeDiff(_lastMSTime, currMSTime) < 600) { - uint32 lastMSTime = itr->second; - itr->second = currMSTime; - if (getMSTimeDiff(lastMSTime, currMSTime) < 600) - return false; - - return true; + return false; } - - _lastMSTimeForSpell[spellInfo->Id] = currMSTime; + _lastMSTime = currMSTime; return true; } void Register() override { - DoCheckProc += AuraCheckProcFn(spell_sindragosa_unchained_magic_AuraScript::CheckProc); + DoAfterCheckProc += AuraAfterCheckProcFn(spell_sindragosa_unchained_magic_AuraScript::AfterCheckProc); } + private: + uint32 _lastMSTime; }; AuraScript* GetAuraScript() const override From cc9d7b53c15b6c6725f7c2a3e45caa4907e1fa31 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Tue, 14 May 2024 16:50:27 +0200 Subject: [PATCH 2/4] convert to spell and aurascript pair macro --- .../IcecrownCitadel/boss_sindragosa.cpp | 96 ++++++++----------- 1 file changed, 40 insertions(+), 56 deletions(-) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index 0625cd3bd63015..adbb1c3a3f87a0 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -869,78 +869,62 @@ class UnchainedMagicTargetSelector bool _removeHealers; }; -class spell_sindragosa_unchained_magic : public SpellScriptLoader +class spell_sindragosa_unchained_magic : public SpellScript { -public: - spell_sindragosa_unchained_magic() : SpellScriptLoader("spell_sindragosa_unchained_magic") { } + PrepareSpellScript(spell_sindragosa_unchained_magic); - class spell_sindragosa_unchained_magic_SpellScript : public SpellScript + void FilterTargets(std::list& unitList) { - PrepareSpellScript(spell_sindragosa_unchained_magic_SpellScript); + std::list healList = unitList; + std::list dpsList = unitList; + unitList.clear(); + uint32 maxSize = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 3 : 1); + healList.remove_if(UnchainedMagicTargetSelector(false)); + if (healList.size() > maxSize) + Acore::Containers::RandomResize(healList, maxSize); + dpsList.remove_if(UnchainedMagicTargetSelector(true)); + if (dpsList.size() > maxSize) + Acore::Containers::RandomResize(dpsList, maxSize); + unitList.splice(unitList.begin(), healList); + unitList.splice(unitList.begin(), dpsList); + } - void FilterTargets(std::list& unitList) - { - std::list healList = unitList; - std::list dpsList = unitList; - unitList.clear(); - uint32 maxSize = uint32(GetCaster()->GetMap()->GetSpawnMode() & 1 ? 3 : 1); - healList.remove_if(UnchainedMagicTargetSelector(false)); - if (healList.size() > maxSize) - Acore::Containers::RandomResize(healList, maxSize); - dpsList.remove_if(UnchainedMagicTargetSelector(true)); - if (dpsList.size() > maxSize) - Acore::Containers::RandomResize(dpsList, maxSize); - unitList.splice(unitList.begin(), healList); - unitList.splice(unitList.begin(), dpsList); - } + void Register() override + { + OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_unchained_magic::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); + } +}; - void Register() override - { - OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_unchained_magic_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY); - } - }; +class spell_sindragosa_unchained_magic_aura : public AuraScript +{ + PrepareAuraScript(spell_sindragosa_unchained_magic_aura); - SpellScript* GetSpellScript() const override + bool Validate(SpellInfo const* /*spellInfo*/) override { - return new spell_sindragosa_unchained_magic_SpellScript(); + return true; } - class spell_sindragosa_unchained_magic_AuraScript : public AuraScript + bool AfterCheckProc(ProcEventInfo& /*eventInfo*/, bool isTriggeredAtSpellProcEvent) { - PrepareAuraScript(spell_sindragosa_unchained_magic_AuraScript); - - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return true; - } - - bool AfterCheckProc(ProcEventInfo& /*eventInfo*/, bool isTriggeredAtSpellProcEvent) + if (!isTriggeredAtSpellProcEvent) { - if (!isTriggeredAtSpellProcEvent) - { - return false; - } - uint32 currMSTime = GameTime::GetGameTimeMS().count(); - if (_lastMSTime && getMSTimeDiff(_lastMSTime, currMSTime) < 600) - { - return false; - } - _lastMSTime = currMSTime; - return true; + return false; } - - void Register() override + uint32 currMSTime = GameTime::GetGameTimeMS().count(); + if (_lastMSTime && getMSTimeDiff(_lastMSTime, currMSTime) < 600) { - DoAfterCheckProc += AuraAfterCheckProcFn(spell_sindragosa_unchained_magic_AuraScript::AfterCheckProc); + return false; } - private: - uint32 _lastMSTime; - }; + _lastMSTime = currMSTime; + return true; + } - AuraScript* GetAuraScript() const override + void Register() override { - return new spell_sindragosa_unchained_magic_AuraScript(); + DoAfterCheckProc += AuraAfterCheckProcFn(spell_sindragosa_unchained_magic_aura::AfterCheckProc); } +private: + uint32 _lastMSTime; }; class spell_sindragosa_permeating_chill : public SpellScriptLoader @@ -2004,7 +1988,7 @@ void AddSC_boss_sindragosa() new boss_sindragosa(); new npc_ice_tomb(); new spell_sindragosa_s_fury(); - new spell_sindragosa_unchained_magic(); + RegisterSpellAndAuraScriptPair(spell_sindragosa_unchained_magic, spell_sindragosa_unchained_magic_aura); new spell_sindragosa_permeating_chill(); new spell_sindragosa_instability(); new spell_sindragosa_icy_grip(); From d73da98978ee7617ba2bc8c90eef4e0e465ddec4 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Wed, 15 May 2024 17:14:11 +0200 Subject: [PATCH 3/4] remove no longer needed validate override --- .../scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index adbb1c3a3f87a0..f3c5df8bec2b85 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -899,11 +899,6 @@ class spell_sindragosa_unchained_magic_aura : public AuraScript { PrepareAuraScript(spell_sindragosa_unchained_magic_aura); - bool Validate(SpellInfo const* /*spellInfo*/) override - { - return true; - } - bool AfterCheckProc(ProcEventInfo& /*eventInfo*/, bool isTriggeredAtSpellProcEvent) { if (!isTriggeredAtSpellProcEvent) From 1e8c0047e297571a2e65a5dd9d950a240867a7d7 Mon Sep 17 00:00:00 2001 From: Jelle Meeus Date: Thu, 23 May 2024 17:32:21 +0200 Subject: [PATCH 4/4] set cooldown with Cooldown field in table spell_proc_event --- .../rev_1716477609336515289.sql | 2 ++ .../IcecrownCitadel/boss_sindragosa.cpp | 29 +------------------ 2 files changed, 3 insertions(+), 28 deletions(-) create mode 100644 data/sql/updates/pending_db_world/rev_1716477609336515289.sql diff --git a/data/sql/updates/pending_db_world/rev_1716477609336515289.sql b/data/sql/updates/pending_db_world/rev_1716477609336515289.sql new file mode 100644 index 00000000000000..953bfff02c4b67 --- /dev/null +++ b/data/sql/updates/pending_db_world/rev_1716477609336515289.sql @@ -0,0 +1,2 @@ +-- +UPDATE `spell_proc_event` SET `Cooldown`=600 WHERE `entry`=69762; diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp index f3c5df8bec2b85..b9326859aa1294 100644 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp @@ -895,33 +895,6 @@ class spell_sindragosa_unchained_magic : public SpellScript } }; -class spell_sindragosa_unchained_magic_aura : public AuraScript -{ - PrepareAuraScript(spell_sindragosa_unchained_magic_aura); - - bool AfterCheckProc(ProcEventInfo& /*eventInfo*/, bool isTriggeredAtSpellProcEvent) - { - if (!isTriggeredAtSpellProcEvent) - { - return false; - } - uint32 currMSTime = GameTime::GetGameTimeMS().count(); - if (_lastMSTime && getMSTimeDiff(_lastMSTime, currMSTime) < 600) - { - return false; - } - _lastMSTime = currMSTime; - return true; - } - - void Register() override - { - DoAfterCheckProc += AuraAfterCheckProcFn(spell_sindragosa_unchained_magic_aura::AfterCheckProc); - } -private: - uint32 _lastMSTime; -}; - class spell_sindragosa_permeating_chill : public SpellScriptLoader { public: @@ -1983,7 +1956,7 @@ void AddSC_boss_sindragosa() new boss_sindragosa(); new npc_ice_tomb(); new spell_sindragosa_s_fury(); - RegisterSpellAndAuraScriptPair(spell_sindragosa_unchained_magic, spell_sindragosa_unchained_magic_aura); + RegisterSpellScript(spell_sindragosa_unchained_magic); new spell_sindragosa_permeating_chill(); new spell_sindragosa_instability(); new spell_sindragosa_icy_grip();