diff --git a/sql/updates/world/custom/custom_2019_05_11_03_world.sql b/sql/updates/world/custom/custom_2019_05_11_03_world.sql index e63499f5b9a..017fb600dc3 100644 --- a/sql/updates/world/custom/custom_2019_05_11_03_world.sql +++ b/sql/updates/world/custom/custom_2019_05_11_03_world.sql @@ -1,6 +1,6 @@ DELETE FROM `spell_proc` WHERE `SpellId` IN (-34293); INSERT INTO `spell_proc` (`SpellId`, `SchoolMask`, `SpellFamilyName`, `SpellFamilyMask0`, `SpellFamilyMask1`, `SpellFamilyMask2`, `ProcFlags`, `SpellTypeMask`, `SpellPhaseMask`, `HitMask`, `AttributesMask`, `Chance`, `Cooldown`) VALUES -(-34293, 4, 3, 0, 0, 0x00000008, 0x00010000, 5, 2, 0, 0, 100, 0); +(-34293, 4, 3, 0, 0, 0x00000008, 0x00010000, 5, 2, 0, 2, 100, 0); DELETE FROM `spell_script_names` WHERE `ScriptName`= 'spell_mage_pyromaniac'; INSERT INTO `spell_script_names` (`spell_id`, `ScriptName`) VALUES diff --git a/src/server/scripts/Spells/spell_mage.cpp b/src/server/scripts/Spells/spell_mage.cpp index d1cb37fef06..9d565ce490c 100644 --- a/src/server/scripts/Spells/spell_mage.cpp +++ b/src/server/scripts/Spells/spell_mage.cpp @@ -2091,7 +2091,6 @@ class spell_mage_pyromaniac : public AuraScript void HandleProc(AuraEffect const* aurEff, ProcEventInfo& eventInfo) { PreventDefaultAction(); - Unit* target = GetTarget(); _dotTargetGuids.insert(eventInfo.GetProcTarget()->GetGUID()); @@ -2099,27 +2098,10 @@ class spell_mage_pyromaniac : public AuraScript if (_buffActive) return; - uint8 dotTargetCount = 0; - GuidSet _targetGuids = _dotTargetGuids; - for (ObjectGuid guid : _targetGuids) - { - if (Unit* dotTarget = ObjectAccessor::GetUnit(*target, guid)) - { - std::list _dotAuraEffects = dotTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); - for (AuraEffect const* dotEff : _dotAuraEffects) - { - if (dotEff->GetCasterGUID() == target->GetGUID() && dotEff->GetSpellInfo()->SpellFamilyFlags[2] & 0x00000008) - { - dotTargetCount++; - break; - } - } - } - else - _dotTargetGuids.erase(guid); - } + Unit* target = GetTarget(); + CleanDotTargets(target); - if (dotTargetCount >= 3) + if (_dotTargetGuids.size() >= 3) { target->CastCustomSpell(SPELL_MAGE_PYROMANIAC_TRIGGERED, SPELLVALUE_BASE_POINT0, aurEff->GetAmount(), target, true, nullptr, aurEff); _buffActive = true; @@ -2133,29 +2115,7 @@ class spell_mage_pyromaniac : public AuraScript return; Unit* target = GetTarget(); - GuidSet _targetGuids = _dotTargetGuids; - for (ObjectGuid guid : _targetGuids) - { - bool _next = false; - if (Unit* dotTarget = ObjectAccessor::GetUnit(*target, guid)) - { - uint8 dotTargetCount = 0; - std::list _dotAuraEffects = dotTarget->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); - for (AuraEffect const* dotEff : _dotAuraEffects) - { - if (dotEff->GetCasterGUID() == target->GetGUID() && dotEff->GetSpellInfo()->SpellFamilyFlags[2] & 0x00000008) - { - dotTargetCount++; - break; - } - } - - if (!dotTargetCount) - _dotTargetGuids.erase(guid); - } - else - _dotTargetGuids.erase(guid); - } + CleanDotTargets(target); if (_dotTargetGuids.size() < 3) { @@ -2173,6 +2133,31 @@ class spell_mage_pyromaniac : public AuraScript private: GuidSet _dotTargetGuids; bool _buffActive; + + void CleanDotTargets(Unit* caster) + { + GuidSet guids = _dotTargetGuids; + for (ObjectGuid guid : guids) + if (!IsValidDotTarget(caster, guid)) + _dotTargetGuids.erase(guid); + } + + bool IsValidDotTarget(Unit* caster, ObjectGuid guid) const + { + Unit* target = ObjectAccessor::GetUnit(*caster, guid); + if (!target) + return false; + + std::list dotAuraEffects = target->GetAuraEffectsByType(SPELL_AURA_PERIODIC_DAMAGE); + if (dotAuraEffects.empty()) + return false; + + for (AuraEffect const* effect : dotAuraEffects) + if (effect->GetCasterGUID() == caster->GetGUID() && effect->GetSpellInfo()->SpellFamilyFlags[2] & 0x00000008) + return true; + + return true; + } }; void AddSC_mage_spell_scripts()