diff options
| author | Shauren <shauren.trinity@gmail.com> | 2020-04-26 13:30:54 +0200 |
|---|---|---|
| committer | Shauren <shauren.trinity@gmail.com> | 2022-01-01 22:27:05 +0100 |
| commit | c9443f190abdf2467386c64c0b476e2d6ec545f6 (patch) | |
| tree | fb4ef33feacbfa13f3b08152fa92c77933f8ccdb /src/server/game/Entities/Unit | |
| parent | 88afe180b404324b3c1a5bfc31fa37c8ded48a78 (diff) | |
Core/Spells Fixed scroll stacking check when not targeting self
* Reuse code that removes non-stackable auras at apply to check before casting the spell to keep reagents/cast item
(cherry picked from commit 43d9ffd1bc127768882711a47d5e2bae92845d04)
Diffstat (limited to 'src/server/game/Entities/Unit')
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 58 | ||||
| -rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 1 |
2 files changed, 34 insertions, 25 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 377fe90c0f3..9902e97bbe8 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -13050,39 +13050,47 @@ bool Unit::IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplicat { if (!aurEff) continue; - AuraType const auraType = aurEff->GetSpellEffectInfo().ApplyAuraName; - AuraEffectList const& auras = GetAuraEffectsByType(auraType); - for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();) + + if (!IsHighestExclusiveAuraEffect(aura->GetSpellInfo(), aurEff->GetAuraType(), aurEff->GetAmount(), aura->GetEffectMask(), removeOtherAuraApplications)) + return false; + } + + return true; +} + +bool Unit::IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications /*= false*/) +{ + AuraEffectList const& auras = GetAuraEffectsByType(auraType); + for (Unit::AuraEffectList::const_iterator itr = auras.begin(); itr != auras.end();) + { + AuraEffect const* existingAurEff = (*itr); + ++itr; + + if (sSpellMgr->CheckSpellGroupStackRules(spellInfo, existingAurEff->GetSpellInfo()) == SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST) { - AuraEffect const* existingAurEff = (*itr); - ++itr; + int64 diff = int64(abs(effectAmount)) - int64(abs(existingAurEff->GetAmount())); + if (!diff) + for (int32 i = 0; i < MAX_SPELL_EFFECTS; ++i) + diff += int64((auraEffectMask & (1 << i)) >> i) - int64((existingAurEff->GetBase()->GetEffectMask() & (1 << i)) >> i); - if (sSpellMgr->CheckSpellGroupStackRules(aura->GetSpellInfo(), existingAurEff->GetSpellInfo()) - == SPELL_GROUP_STACK_RULE_EXCLUSIVE_HIGHEST) + if (diff > 0) { - int32 diff = abs(aurEff->GetAmount()) - abs(existingAurEff->GetAmount()); - if (!diff) - diff = int32(aura->GetEffectMask()) - int32(existingAurEff->GetBase()->GetEffectMask()); - - if (diff > 0) + Aura const* base = existingAurEff->GetBase(); + // no removing of area auras from the original owner, as that completely cancels them + if (removeOtherAuraApplications && (!base->IsArea() || base->GetOwner() != this)) { - Aura const* base = existingAurEff->GetBase(); - // no removing of area auras from the original owner, as that completely cancels them - if (removeOtherAuraApplications && (!base->IsArea() || base->GetOwner() != this)) + if (AuraApplication* aurApp = existingAurEff->GetBase()->GetApplicationOfTarget(GetGUID())) { - if (AuraApplication* aurApp = existingAurEff->GetBase()->GetApplicationOfTarget(GetGUID())) - { - bool hasMoreThanOneEffect = base->HasMoreThanOneEffectForType(auraType); - uint32 removedAuras = m_removedAurasCount; - RemoveAura(aurApp); - if (hasMoreThanOneEffect || m_removedAurasCount > removedAuras + 1) - itr = auras.begin(); - } + bool hasMoreThanOneEffect = base->HasMoreThanOneEffectForType(auraType); + uint32 removedAuras = m_removedAurasCount; + RemoveAura(aurApp); + if (hasMoreThanOneEffect || m_removedAurasCount > removedAuras + 1) + itr = auras.begin(); } } - else if (diff < 0) - return false; } + else if (diff < 0) + return false; } } diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 320d62804b9..778de3299a2 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1828,6 +1828,7 @@ class TC_GAME_API Unit : public WorldObject int32 GetHighestExclusiveSameEffectSpellGroupValue(AuraEffect const* aurEff, AuraType auraType, bool checkMiscValue = false, int32 miscValue = 0) const; bool IsHighestExclusiveAura(Aura const* aura, bool removeOtherAuraApplications = false); + bool IsHighestExclusiveAuraEffect(SpellInfo const* spellInfo, AuraType auraType, int32 effectAmount, uint32 auraEffectMask, bool removeOtherAuraApplications = false); virtual void Talk(std::string const& text, ChatMsg msgType, Language language, float textRange, WorldObject const* target); virtual void Say(std::string const& text, Language language, WorldObject const* target = nullptr); |
