MichaelCrow

Cooldown mod spell effect

Dec 25th, 2023
1,584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.33 KB | None | 0 0
  1. void Spell::EffectModifyCurrentSpellCooldown(SpellEffIndex effIndex)
  2. {
  3.     if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
  4.         return;
  5.  
  6.     if (m_caster->GetTypeId() != TYPEID_PLAYER)
  7.         return;
  8.  
  9.     SpellInfo const* spellInfo = GetSpellInfo();
  10.     flag96 spellMask = spellInfo->Effects[effIndex].SpellClassMask;
  11.     int32 amount = spellInfo->Effects[effIndex].CalcValue();
  12.     int32 ignoreSpellMask = spellInfo->Effects[effIndex].MiscValue;
  13.     int32 ignoreSpellFamily = spellInfo->Effects[effIndex].MiscValueB;
  14.     Player* player = m_caster->ToPlayer();
  15.     SpellCooldowns const spellCDs = player->GetSpellCooldowns();
  16.  
  17.     for (SpellCooldowns::const_iterator itr = spellCDs.begin(); itr != spellCDs.end(); ++itr)
  18.     {
  19.         SpellInfo const* cdSpell = sSpellMgr->GetSpellInfo(itr->first);
  20.         if (cdSpell && cdSpell->SpellFamilyName == spellInfo->SpellFamilyName && (cdSpell->SpellFamilyFlags & spellMask) && !ignoreSpellMask && !ignoreSpellFamily)
  21.             player->ModifySpellCooldown(cdSpell->Id, amount);
  22.         else if (cdSpell && cdSpell->SpellFamilyName == spellInfo->SpellFamilyName && ignoreSpellMask && !ignoreSpellFamily)
  23.             player->ModifySpellCooldown(cdSpell->Id, amount);
  24.         else if (cdSpell && ignoreSpellFamily)
  25.             player->ModifySpellCooldown(cdSpell->Id, amount);
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment