Core/Spell: implement SPELL_FAILED_AURA_BOUNCED on DR spells
Closes #13695 (cherry picked from commit 5e2c5a52cd8a4ce12e189034df66b42d0d0b2c01)
This commit is contained in:
@@ -4633,17 +4633,6 @@ bool Unit::HasNegativeAuraWithInterruptFlag(InterruptFlags flag, ObjectGuid guid
|
||||
template TC_GAME_API bool Unit::HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags flag, ObjectGuid guid) const;
|
||||
template TC_GAME_API bool Unit::HasNegativeAuraWithInterruptFlag(SpellAuraInterruptFlags2 flag, ObjectGuid guid) const;
|
||||
|
||||
bool Unit::HasNegativeAuraWithAttribute(uint32 flag, ObjectGuid guid) const
|
||||
{
|
||||
for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
|
||||
{
|
||||
Aura const* aura = iter->second->GetBase();
|
||||
if (!iter->second->IsPositive() && aura->GetSpellInfo()->Attributes & flag && (!guid || aura->GetCasterGUID() == guid))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const
|
||||
{
|
||||
for (AuraApplicationMap::const_iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end(); ++iter)
|
||||
@@ -4661,6 +4650,26 @@ bool Unit::HasAuraWithMechanic(uint32 mechanicMask) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::HasStrongerAuraWithDR(SpellInfo const* auraSpellInfo, Unit* caster) const
|
||||
{
|
||||
DiminishingGroup diminishGroup = auraSpellInfo->GetDiminishingReturnsGroupForSpell();
|
||||
DiminishingLevels level = GetDiminishing(diminishGroup);
|
||||
for (auto itr = m_appliedAuras.begin(); itr != m_appliedAuras.end(); ++itr)
|
||||
{
|
||||
SpellInfo const* spellInfo = itr->second->GetBase()->GetSpellInfo();
|
||||
if (spellInfo->GetDiminishingReturnsGroupForSpell() != diminishGroup)
|
||||
continue;
|
||||
|
||||
int32 existingDuration = itr->second->GetBase()->GetMaxDuration();
|
||||
int32 newDuration = auraSpellInfo->GetMaxDuration();
|
||||
ApplyDiminishingToDuration(auraSpellInfo, newDuration, caster, level);
|
||||
if (newDuration > 0 && newDuration < existingDuration)
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
AuraEffect* Unit::IsScriptOverriden(SpellInfo const* spell, int32 script) const
|
||||
{
|
||||
AuraEffectList const& auras = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||
@@ -9403,31 +9412,28 @@ void Unit::ModSpellDurationTime(SpellInfo const* spellInfo, int32 & duration, Sp
|
||||
duration = int32(float(duration) * m_modAttackSpeedPct[RANGED_ATTACK]);
|
||||
}
|
||||
|
||||
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group)
|
||||
DiminishingLevels Unit::GetDiminishing(DiminishingGroup group) const
|
||||
{
|
||||
DiminishingReturn& diminish = m_Diminishing[group];
|
||||
DiminishingReturn const& diminish = m_Diminishing[group];
|
||||
if (!diminish.hitCount)
|
||||
return DIMINISHING_LEVEL_1;
|
||||
|
||||
// If last spell was cast more than 18 seconds ago - reset the count.
|
||||
// If last spell was cast more than 18 seconds ago - reset level.
|
||||
if (!diminish.stack && GetMSTimeDiffToNow(diminish.hitTime) > 18 * IN_MILLISECONDS)
|
||||
{
|
||||
diminish.hitCount = DIMINISHING_LEVEL_1;
|
||||
return DIMINISHING_LEVEL_1;
|
||||
}
|
||||
|
||||
return DiminishingLevels(diminish.hitCount);
|
||||
}
|
||||
|
||||
void Unit::IncrDiminishing(SpellInfo const* auraSpellInfo)
|
||||
{
|
||||
DiminishingGroup const group = auraSpellInfo->GetDiminishingReturnsGroupForSpell();
|
||||
DiminishingLevels const maxLevel = auraSpellInfo->GetDiminishingReturnsMaxLevel();
|
||||
DiminishingGroup group = auraSpellInfo->GetDiminishingReturnsGroupForSpell();
|
||||
uint32 currentLevel = GetDiminishing(group);
|
||||
uint32 const maxLevel = auraSpellInfo->GetDiminishingReturnsMaxLevel();
|
||||
|
||||
// Checking for existing in the table
|
||||
DiminishingReturn& diminish = m_Diminishing[group];
|
||||
if (static_cast<int32>(diminish.hitCount) < maxLevel)
|
||||
++diminish.hitCount;
|
||||
if (currentLevel < maxLevel)
|
||||
diminish.hitCount = currentLevel + 1;
|
||||
}
|
||||
|
||||
bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& duration, Unit* caster, DiminishingLevels previousLevel) const
|
||||
@@ -9447,9 +9453,7 @@ bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& dur
|
||||
Unit const* target = targetOwner ? targetOwner : this;
|
||||
Unit const* source = casterOwner ? casterOwner : caster;
|
||||
|
||||
if ((target->GetTypeId() == TYPEID_PLAYER
|
||||
|| (target->ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))
|
||||
&& source->GetTypeId() == TYPEID_PLAYER)
|
||||
if (target->IsAffectedByDiminishingReturns() && source->GetTypeId() == TYPEID_PLAYER)
|
||||
duration = limitDuration;
|
||||
}
|
||||
|
||||
@@ -9475,9 +9479,9 @@ bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& dur
|
||||
}
|
||||
case DIMINISHING_AOE_KNOCKBACK:
|
||||
{
|
||||
if ((auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_PLAYER && (((targetOwner ? targetOwner : this)->ToPlayer())
|
||||
|| (ToCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))))
|
||||
|| auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_ALL)
|
||||
if (auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_ALL ||
|
||||
(auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_PLAYER &&
|
||||
(targetOwner ? targetOwner->IsAffectedByDiminishingReturns() : IsAffectedByDiminishingReturns())))
|
||||
{
|
||||
DiminishingLevels diminish = previousLevel;
|
||||
switch (diminish)
|
||||
@@ -9491,9 +9495,9 @@ bool Unit::ApplyDiminishingToDuration(SpellInfo const* auraSpellInfo, int32& dur
|
||||
}
|
||||
default:
|
||||
{
|
||||
if ((auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_PLAYER && (((targetOwner ? targetOwner : this)->ToPlayer())
|
||||
|| (ToCreature() && (ToCreature()->GetCreatureTemplate()->flags_extra & CREATURE_FLAG_EXTRA_ALL_DIMINISH))))
|
||||
|| auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_ALL)
|
||||
if (auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_ALL ||
|
||||
(auraSpellInfo->GetDiminishingReturnsGroupType() == DRTYPE_PLAYER &&
|
||||
(targetOwner ? targetOwner->IsAffectedByDiminishingReturns() : IsAffectedByDiminishingReturns())))
|
||||
{
|
||||
DiminishingLevels diminish = previousLevel;
|
||||
switch (diminish)
|
||||
|
||||
Reference in New Issue
Block a user