mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-24 02:46:33 +01:00
Core/Spell: implement SPELL_FAILED_AURA_BOUNCED on DR spells
Closes #13695
This commit is contained in:
@@ -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, ¶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)
|
||||
@@ -3191,6 +3187,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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user