Core/Spell: implement SPELL_FAILED_AURA_BOUNCED on DR spells

Closes #13695
This commit is contained in:
ariel-
2017-12-21 02:25:04 -03:00
parent bd12f481d5
commit 5e2c5a52cd
4 changed files with 74 additions and 45 deletions

View File

@@ -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,18 +3209,39 @@ 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);
modOwner->SetSpellModTakingSpell(this, false);
finish(false);
SetExecutedCurrently(false);
cleanupSpell(SPELL_FAILED_DONT_REPORT);
return;
}
}
}
}
// 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;
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;
}
}
}
}
}
}
// if the spell allows the creature to turn while casting, then adjust server-side orientation to face the target now