Skip to content

Commit

Permalink
fix(ICC/Sindragosa): add a cooldown to proccing Unchained Magic (azer…
Browse files Browse the repository at this point in the history
…othcore#18901)

* add cooldown to proc

* convert to spell and aurascript pair macro

* remove no longer needed validate override

* set cooldown with Cooldown field in table spell_proc_event
  • Loading branch information
sogladev authored and ikkj committed Jun 11, 2024
1 parent 38c6ed2 commit 9fd5edd
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 74 deletions.
2 changes: 2 additions & 0 deletions data/sql/updates/pending_db_world/rev_1716477609336515289.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
--
UPDATE `spell_proc_event` SET `Cooldown`=600 WHERE `entry`=69762;
92 changes: 18 additions & 74 deletions src/server/scripts/Northrend/IcecrownCitadel/boss_sindragosa.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -894,85 +894,29 @@ 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") { }

class spell_sindragosa_unchained_magic_SpellScript : public SpellScript
{
PrepareSpellScript(spell_sindragosa_unchained_magic_SpellScript);

void FilterTargets(std::list<WorldObject*>& unitList)
{
std::list<WorldObject*> healList = unitList;
std::list<WorldObject*> 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_SpellScript::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};
PrepareSpellScript(spell_sindragosa_unchained_magic);

SpellScript* GetSpellScript() const override
void FilterTargets(std::list<WorldObject*>& unitList)
{
return new spell_sindragosa_unchained_magic_SpellScript();
std::list<WorldObject*> healList = unitList;
std::list<WorldObject*> 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);
}

class spell_sindragosa_unchained_magic_AuraScript : public AuraScript
{
PrepareAuraScript(spell_sindragosa_unchained_magic_AuraScript);

std::map<uint32, uint32> _lastMSTimeForSpell;

bool Validate(SpellInfo const* /*spellInfo*/) override
{
_lastMSTimeForSpell.clear();
return true;
}

bool CheckProc(ProcEventInfo& eventInfo)
{
SpellInfo const* spellInfo = eventInfo.GetSpellInfo();
if (!spellInfo)
return false;

uint32 currMSTime = GameTime::GetGameTimeMS().count();
std::map<uint32, uint32>::iterator itr = _lastMSTimeForSpell.find(spellInfo->Id);
if (itr != _lastMSTimeForSpell.end())
{
uint32 lastMSTime = itr->second;
itr->second = currMSTime;
if (getMSTimeDiff(lastMSTime, currMSTime) < 600)
return false;

return true;
}

_lastMSTimeForSpell[spellInfo->Id] = currMSTime;
return true;
}

void Register() override
{
DoCheckProc += AuraCheckProcFn(spell_sindragosa_unchained_magic_AuraScript::CheckProc);
}
};

AuraScript* GetAuraScript() const override
void Register() override
{
return new spell_sindragosa_unchained_magic_AuraScript();
OnObjectAreaTargetSelect += SpellObjectAreaTargetSelectFn(spell_sindragosa_unchained_magic::FilterTargets, EFFECT_0, TARGET_UNIT_SRC_AREA_ENEMY);
}
};

Expand Down Expand Up @@ -2053,7 +1997,7 @@ void AddSC_boss_sindragosa()
new boss_sindragosa();
new npc_ice_tomb();
new spell_sindragosa_s_fury();
new spell_sindragosa_unchained_magic();
RegisterSpellScript(spell_sindragosa_unchained_magic);
new spell_sindragosa_permeating_chill();
new spell_sindragosa_instability();
new spell_sindragosa_icy_grip();
Expand Down

0 comments on commit 9fd5edd

Please sign in to comment.