mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-18 06:00:10 -04:00
Core/Auras: Implemented using all aura interrupt flag fields
This commit is contained in:
@@ -319,7 +319,7 @@ Unit::Unit(bool isWorldObject) :
|
||||
|
||||
m_auraUpdateIterator = m_ownedAuras.end();
|
||||
|
||||
m_interruptMask = 0;
|
||||
m_interruptMask.fill(0);
|
||||
m_transform = 0;
|
||||
m_canModifyStats = false;
|
||||
|
||||
@@ -644,13 +644,15 @@ void Unit::RemoveVisibleAura(AuraApplication* aurApp)
|
||||
|
||||
void Unit::UpdateInterruptMask()
|
||||
{
|
||||
m_interruptMask = 0;
|
||||
for (AuraApplicationList::const_iterator i = m_interruptableAuras.begin(); i != m_interruptableAuras.end(); ++i)
|
||||
m_interruptMask |= (*i)->GetBase()->GetSpellInfo()->AuraInterruptFlags;
|
||||
m_interruptMask.fill(0);
|
||||
for (AuraApplication const* aurApp : m_interruptableAuras)
|
||||
for (std::size_t i = 0; i < m_interruptMask.size(); ++i)
|
||||
m_interruptMask[i] |= aurApp->GetBase()->GetSpellInfo()->AuraInterruptFlags[i];
|
||||
|
||||
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
|
||||
if (spell->getState() == SPELL_STATE_CASTING)
|
||||
m_interruptMask |= spell->m_spellInfo->ChannelInterruptFlags;
|
||||
for (std::size_t i = 0; i < m_interruptMask.size(); ++i)
|
||||
m_interruptMask[i] |= spell->m_spellInfo->ChannelInterruptFlags[i];
|
||||
}
|
||||
|
||||
bool Unit::HasAuraTypeWithFamilyFlags(AuraType auraType, uint32 familyName, uint32 familyFlags) const
|
||||
@@ -670,7 +672,7 @@ bool Unit::HasBreakableByDamageAuraType(AuraType type, uint32 excludeAura) const
|
||||
AuraEffectList const& auras = GetAuraEffectsByType(type);
|
||||
for (AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end(); ++itr)
|
||||
if ((!excludeAura || excludeAura != (*itr)->GetSpellInfo()->Id) && //Avoid self interrupt of channeled Crowd Control spells like Seduction
|
||||
((*itr)->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_TAKE_DAMAGE))
|
||||
(*itr)->GetSpellInfo()->HasAuraInterruptFlag(AURA_INTERRUPT_FLAG_TAKE_DAMAGE))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
@@ -912,12 +914,8 @@ uint32 Unit::DealDamage(Unit* victim, uint32 damage, CleanDamage const* cleanDam
|
||||
}
|
||||
|
||||
if (Spell* spell = victim->m_currentSpells[CURRENT_CHANNELED_SPELL])
|
||||
if (spell->getState() == SPELL_STATE_CASTING)
|
||||
{
|
||||
uint32 channelInterruptFlags = spell->m_spellInfo->ChannelInterruptFlags;
|
||||
if (((channelInterruptFlags & CHANNEL_FLAG_DELAY) != 0) && (damagetype != DOT))
|
||||
spell->DelayedChannel();
|
||||
}
|
||||
if (spell->getState() == SPELL_STATE_CASTING && spell->m_spellInfo->HasChannelInterruptFlag(CHANNEL_FLAG_DELAY) && damagetype != DOT)
|
||||
spell->DelayedChannel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3241,7 +3239,7 @@ AuraApplication * Unit::_CreateAuraApplication(Aura* aura, uint32 effMask)
|
||||
AuraApplication * aurApp = new AuraApplication(this, caster, aura, effMask);
|
||||
m_appliedAuras.insert(AuraApplicationMap::value_type(aurId, aurApp));
|
||||
|
||||
if (aurSpellInfo->AuraInterruptFlags)
|
||||
if (aurSpellInfo->HasAnyAuraInterruptFlag())
|
||||
{
|
||||
m_interruptableAuras.push_back(aurApp);
|
||||
AddInterruptMask(aurSpellInfo->AuraInterruptFlags);
|
||||
@@ -3285,7 +3283,7 @@ void Unit::_ApplyAura(AuraApplication * aurApp, uint32 effMask)
|
||||
return;
|
||||
|
||||
// Sitdown on apply aura req seated
|
||||
if (aura->GetSpellInfo()->AuraInterruptFlags & AURA_INTERRUPT_FLAG_NOT_SEATED && !IsSitState())
|
||||
if (aura->GetSpellInfo()->HasAuraInterruptFlag(AURA_INTERRUPT_FLAG_NOT_SEATED) && !IsSitState())
|
||||
SetStandState(UNIT_STAND_STATE_SIT);
|
||||
|
||||
Unit* caster = aura->GetCaster();
|
||||
@@ -3326,7 +3324,7 @@ void Unit::_UnapplyAura(AuraApplicationMap::iterator &i, AuraRemoveMode removeMo
|
||||
// Remove all pointers from lists here to prevent possible pointer invalidation on spellcast/auraapply/auraremove
|
||||
m_appliedAuras.erase(i);
|
||||
|
||||
if (aura->GetSpellInfo()->AuraInterruptFlags)
|
||||
if (aura->GetSpellInfo()->HasAnyAuraInterruptFlag())
|
||||
{
|
||||
m_interruptableAuras.remove(aurApp);
|
||||
UpdateInterruptMask();
|
||||
@@ -3904,9 +3902,10 @@ void Unit::RemoveNotOwnSingleTargetAuras(uint32 newPhase, bool phaseid)
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
|
||||
template <typename InterruptFlags>
|
||||
void Unit::RemoveAurasWithInterruptFlags(InterruptFlags flag, uint32 except)
|
||||
{
|
||||
if (!(m_interruptMask & flag))
|
||||
if (!(m_interruptMask[AuraInterruptFlagIndex<InterruptFlags>::value] & flag))
|
||||
return;
|
||||
|
||||
// interrupt auras
|
||||
@@ -3914,7 +3913,7 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
|
||||
{
|
||||
Aura* aura = (*iter)->GetBase();
|
||||
++iter;
|
||||
if ((aura->GetSpellInfo()->AuraInterruptFlags & flag) && (!except || aura->GetId() != except)
|
||||
if (aura->GetSpellInfo()->AuraInterruptFlags[AuraInterruptFlagIndex<InterruptFlags>::value] & flag && (!except || aura->GetId() != except)
|
||||
&& !(flag & AURA_INTERRUPT_FLAG_MOVE && HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, aura->GetSpellInfo())))
|
||||
{
|
||||
uint32 removedAuras = m_removedAurasCount;
|
||||
@@ -3927,14 +3926,17 @@ void Unit::RemoveAurasWithInterruptFlags(uint32 flag, uint32 except)
|
||||
// interrupt channeled spell
|
||||
if (Spell* spell = m_currentSpells[CURRENT_CHANNELED_SPELL])
|
||||
if (spell->getState() == SPELL_STATE_CASTING
|
||||
&& (spell->m_spellInfo->ChannelInterruptFlags & flag)
|
||||
&& spell->m_spellInfo->Id != except
|
||||
&& (spell->GetSpellInfo()->ChannelInterruptFlags[AuraInterruptFlagIndex<InterruptFlags>::value] & flag)
|
||||
&& spell->GetSpellInfo()->Id != except
|
||||
&& !(flag & AURA_INTERRUPT_FLAG_MOVE && HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, spell->GetSpellInfo())))
|
||||
InterruptNonMeleeSpells(false);
|
||||
|
||||
UpdateInterruptMask();
|
||||
}
|
||||
|
||||
template TC_GAME_API void Unit::RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags flag, uint32 except);
|
||||
template TC_GAME_API void Unit::RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2 flag, uint32 except);
|
||||
|
||||
void Unit::RemoveAurasWithFamily(SpellFamilyNames family, flag128 const& familyFlag, ObjectGuid casterGUID)
|
||||
{
|
||||
for (AuraApplicationMap::iterator iter = m_appliedAuras.begin(); iter != m_appliedAuras.end();)
|
||||
@@ -4374,18 +4376,23 @@ bool Unit::HasAuraTypeWithValue(AuraType auratype, int32 value) const
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Unit::HasNegativeAuraWithInterruptFlag(uint32 flag, ObjectGuid guid) const
|
||||
template <typename InterruptFlags>
|
||||
bool Unit::HasNegativeAuraWithInterruptFlag(InterruptFlags flag, ObjectGuid guid) const
|
||||
{
|
||||
if (!(m_interruptMask & flag))
|
||||
if (!(m_interruptMask[AuraInterruptFlagIndex<InterruptFlags>::value] & flag))
|
||||
return false;
|
||||
|
||||
for (AuraApplicationList::const_iterator iter = m_interruptableAuras.begin(); iter != m_interruptableAuras.end(); ++iter)
|
||||
{
|
||||
if (!(*iter)->IsPositive() && (*iter)->GetBase()->GetSpellInfo()->AuraInterruptFlags & flag && (!guid || (*iter)->GetBase()->GetCasterGUID() == guid))
|
||||
if (!(*iter)->IsPositive() && (*iter)->GetBase()->GetSpellInfo()->AuraInterruptFlags[AuraInterruptFlagIndex<InterruptFlags>::value] & flag &&
|
||||
(!guid || (*iter)->GetBase()->GetCasterGUID() == guid))
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user