Core/Spell: do not allow auras from dynamic objects to stack if they come from the same spell cast by the same caster.

(cherry picked from commit b87350807d)
This commit is contained in:
Wyrserth
2019-07-06 19:54:58 +02:00
committed by Shauren
parent e005c13ed1
commit 55611104be

View File

@@ -654,30 +654,25 @@ void Aura::UpdateTargetMap(Unit* caster, bool apply)
if (addUnit && !itr->first->IsHighestExclusiveAura(this, true))
addUnit = false;
// Dynobj auras don't hit flying targets
if (GetType() == DYNOBJ_AURA_TYPE && itr->first->IsInFlight())
addUnit = false;
// Do not apply aura if it cannot stack with existing auras
if (addUnit)
{
// persistent area aura does not hit flying targets
if (GetType() == DYNOBJ_AURA_TYPE)
// Allow to remove by stack when aura is going to be applied on owner
if (itr->first != GetOwner())
{
if (itr->first->IsInFlight())
addUnit = false;
}
// unit auras can not stack with each other
else // (GetType() == UNIT_AURA_TYPE)
{
// Allow to remove by stack when aura is going to be applied on owner
if (itr->first != GetOwner())
// check if not stacking aura already on target
// this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
{
// check if not stacking aura already on target
// this one prevents unwanted usefull buff loss because of stacking and prevents overriding auras periodicaly by 2 near area aura owners
for (Unit::AuraApplicationMap::iterator iter = itr->first->GetAppliedAuras().begin(); iter != itr->first->GetAppliedAuras().end(); ++iter)
Aura const* aura = iter->second->GetBase();
if (!CanStackWith(aura))
{
Aura const* aura = iter->second->GetBase();
if (!CanStackWith(aura))
{
addUnit = false;
break;
}
addUnit = false;
break;
}
}
}
@@ -1571,12 +1566,16 @@ bool Aura::CanStackWith(Aura const* existingAura) const
if (this == existingAura)
return true;
// Dynobj auras always stack
if (GetType() == DYNOBJ_AURA_TYPE || existingAura->GetType() == DYNOBJ_AURA_TYPE)
return true;
SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
bool sameCaster = GetCasterGUID() == existingAura->GetCasterGUID();
SpellInfo const* existingSpellInfo = existingAura->GetSpellInfo();
// Dynobj auras do not stack when they come from the same spell cast by the same caster
if (GetType() == DYNOBJ_AURA_TYPE || existingAura->GetType() == DYNOBJ_AURA_TYPE)
{
if (sameCaster && m_spellInfo->Id == existingSpellInfo->Id)
return false;
return true;
}
// passive auras don't stack with another rank of the spell cast by same caster
if (IsPassive() && sameCaster && (m_spellInfo->IsDifferentRankOf(existingSpellInfo) || (m_spellInfo->Id == existingSpellInfo->Id && m_castItemGuid.IsEmpty())))