diff options
author | Shauren <shauren.trinity@gmail.com> | 2025-05-30 00:19:32 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2025-05-30 00:19:32 +0200 |
commit | cc0e892d8db6bbb385039efe01f29f83c94a0ef6 (patch) | |
tree | c263cfa0f92764113c37d8a9568739ed6ecc6ca2 | |
parent | 63cad8f18206c7403af9e5ed40209e814913b5e0 (diff) |
Core/Scripts: Allow accessing removed spell HitAura in scripts
-rw-r--r-- | src/server/game/Spells/SpellScript.cpp | 9 | ||||
-rw-r--r-- | src/server/game/Spells/SpellScript.h | 2 |
2 files changed, 4 insertions, 7 deletions
diff --git a/src/server/game/Spells/SpellScript.cpp b/src/server/game/Spells/SpellScript.cpp index f8eb76085ab..d541c5f0a46 100644 --- a/src/server/game/Spells/SpellScript.cpp +++ b/src/server/game/Spells/SpellScript.cpp @@ -623,17 +623,14 @@ bool SpellScript::IsHitCrit() const } if (Unit* hitUnit = GetHitUnit()) { - auto itr = std::find_if(m_spell->m_UniqueTargetInfo.begin(), m_spell->m_UniqueTargetInfo.end(), [hitUnit](Spell::TargetInfo const& targetInfo) - { - return targetInfo.TargetGUID == hitUnit->GetGUID(); - }); + auto itr = std::ranges::find(m_spell->m_UniqueTargetInfo, hitUnit->GetGUID(), &Spell::TargetInfo::TargetGUID); ASSERT(itr != m_spell->m_UniqueTargetInfo.end()); return itr->IsCrit; } return false; } -Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const +Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/, bool withRemoved /*= false*/) const { if (!IsInTargetHook()) { @@ -645,7 +642,7 @@ Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const if (dynObjAura) aura = m_spell->_dynObjAura; - if (!aura || aura->IsRemoved()) + if (!aura || (aura->IsRemoved() && !withRemoved)) return nullptr; return aura; diff --git a/src/server/game/Spells/SpellScript.h b/src/server/game/Spells/SpellScript.h index ee962a29ec6..22b54191244 100644 --- a/src/server/game/Spells/SpellScript.h +++ b/src/server/game/Spells/SpellScript.h @@ -1044,7 +1044,7 @@ public: bool IsHitCrit() const; Spell* GetSpell() const { return m_spell; } // returns current spell hit target aura - Aura* GetHitAura(bool dynObjAura = false) const; + Aura* GetHitAura(bool dynObjAura = false, bool withRemoved = false) const; // prevents applying aura on current spell hit target void PreventHitAura(); |