diff options
| author | ariel- <ariel-@users.noreply.github.com> | 2017-12-21 02:25:04 -0300 |
|---|---|---|
| committer | funjoker <funjoker109@gmail.com> | 2021-04-15 05:53:27 +0200 |
| commit | bebc20b4de7db2fa1b80ac481902a39d92bd4dc8 (patch) | |
| tree | dc920e6c6566176a62209242e1f40e525d1e8555 /src/server/game/Spells/Spell.cpp | |
| parent | 72bdadfa9dff5334915144ee3efe3579ff4a2cf7 (diff) | |
Core/Spell: implement SPELL_FAILED_AURA_BOUNCED on DR spells
Closes #13695
(cherry picked from commit 5e2c5a52cd8a4ce12e189034df66b42d0d0b2c01)
Diffstat (limited to 'src/server/game/Spells/Spell.cpp')
| -rw-r--r-- | src/server/game/Spells/Spell.cpp | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 754e25011d7..a9a5c34f38a 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -2650,9 +2650,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask) diminishLevel = unit->GetDiminishing(diminishGroup); DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(); // Increase Diminishing on unit, current informations for actually casts will use values above - if ((type == DRTYPE_PLAYER && - (unit->GetCharmerOrOwnerPlayerOrPlayerItself() || (unit->GetTypeId() == TYPEID_UNIT && unit->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))) || - type == DRTYPE_ALL) + if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && unit->IsAffectedByDiminishingReturns())) unit->IncrDiminishing(m_spellInfo); } @@ -3203,11 +3201,9 @@ void Spell::_cast(bool skipCheck) // skip check if done already (for instant cast spells for example) if (!skipCheck) { - uint32 param1 = 0, param2 = 0; - SpellCastResult castResult = CheckCast(false, ¶m1, ¶m2); - if (castResult != SPELL_CAST_OK) + auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr) { - SendCastResult(castResult, ¶m1, ¶m2); + SendCastResult(res, p1, p2); SendInterrupted(0); if (modOwner) @@ -3215,6 +3211,13 @@ void Spell::_cast(bool skipCheck) finish(false); SetExecutedCurrently(false); + }; + + uint32 param1 = 0, param2 = 0; + SpellCastResult castResult = CheckCast(false, ¶m1, ¶m2); + if (castResult != SPELL_CAST_OK) + { + cleanupSpell(castResult, ¶m1, ¶m2); return; } @@ -3230,14 +3233,34 @@ void Spell::_cast(bool skipCheck) { // Spell will be cast after completing the trade. Silently ignore at this place my_trade->SetSpell(m_spellInfo->Id, m_CastItem); - SendCastResult(SPELL_FAILED_DONT_REPORT); - SendInterrupted(0); + cleanupSpell(SPELL_FAILED_DONT_REPORT); + return; + } + } + } + } - modOwner->SetSpellModTakingSpell(this, false); + // check diminishing returns (again, only after finish cast bar, tested on retail) + if (Unit* target = m_targets.GetUnitTarget()) + { + uint8 aura_effmask = 0; + for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) + if (m_spellInfo->GetEffect(i)->IsUnitOwnedAuraEffect()) + aura_effmask |= 1 << i; - finish(false); - SetExecutedCurrently(false); - return; + if (aura_effmask) + { + if (DiminishingGroup diminishGroup = m_spellInfo->GetDiminishingReturnsGroupForSpell()) + { + DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(); + if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && target->IsAffectedByDiminishingReturns())) + { + Unit* caster = m_originalCaster ? m_originalCaster : m_caster; + if (target->HasStrongerAuraWithDR(m_spellInfo, caster)) + { + cleanupSpell(SPELL_FAILED_AURA_BOUNCED); + return; + } } } } |
