aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells
diff options
context:
space:
mode:
authorariel- <ariel-@users.noreply.github.com>2017-12-21 02:25:04 -0300
committerariel- <ariel-@users.noreply.github.com>2017-12-21 02:25:04 -0300
commit5e2c5a52cd8a4ce12e189034df66b42d0d0b2c01 (patch)
treea0813c95b83f4820c9310a3c7f37962ca32f1b76 /src/server/game/Spells
parentbd12f481d5d2a5fd12f875aef510ec9f577d597d (diff)
Core/Spell: implement SPELL_FAILED_AURA_BOUNCED on DR spells
Closes #13695
Diffstat (limited to 'src/server/game/Spells')
-rw-r--r--src/server/game/Spells/Spell.cpp50
1 files changed, 37 insertions, 13 deletions
diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp
index 020cf8efb8b..1418f7cff4c 100644
--- a/src/server/game/Spells/Spell.cpp
+++ b/src/server/game/Spells/Spell.cpp
@@ -2603,9 +2603,7 @@ SpellMissInfo Spell::DoSpellHitOnUnit(Unit* unit, uint32 effectMask, bool scaleA
diminishLevel = unit->GetDiminishing(diminishGroup);
DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(triggered);
// 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, triggered);
}
@@ -3179,11 +3177,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, &param1, &param2);
- if (castResult != SPELL_CAST_OK)
+ auto cleanupSpell = [this, modOwner](SpellCastResult res, uint32* p1 = nullptr, uint32* p2 = nullptr)
{
- SendCastResult(castResult, &param1, &param2);
+ SendCastResult(res, p1, p2);
SendInterrupted(0);
if (modOwner)
@@ -3191,6 +3187,13 @@ void Spell::_cast(bool skipCheck)
finish(false);
SetExecutedCurrently(false);
+ };
+
+ uint32 param1 = 0, param2 = 0;
+ SpellCastResult castResult = CheckCast(false, &param1, &param2);
+ if (castResult != SPELL_CAST_OK)
+ {
+ cleanupSpell(castResult, &param1, &param2);
return;
}
@@ -3206,14 +3209,35 @@ 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->Effects[i].IsUnitOwnedAuraEffect())
+ aura_effmask |= 1 << i;
- finish(false);
- SetExecutedCurrently(false);
- return;
+ if (aura_effmask)
+ {
+ bool const triggered = m_triggeredByAuraSpell != nullptr;
+ if (DiminishingGroup diminishGroup = m_spellInfo->GetDiminishingReturnsGroupForSpell(triggered))
+ {
+ DiminishingReturnsType type = m_spellInfo->GetDiminishingReturnsGroupType(triggered);
+ if (type == DRTYPE_ALL || (type == DRTYPE_PLAYER && target->IsAffectedByDiminishingReturns()))
+ {
+ Unit* caster = m_originalCaster ? m_originalCaster : m_caster;
+ if (target->HasStrongerAuraWithDR(m_spellInfo, caster, triggered))
+ {
+ cleanupSpell(SPELL_FAILED_AURA_BOUNCED);
+ return;
+ }
}
}
}