Core/Spells: rework part 3: spells only handle at most one UnitAura and one DynObjAura during its lifetime

# Conflicts:
#	src/server/game/Spells/Auras/SpellAuras.h
This commit is contained in:
ariel- authored and Ovahlord committed 2022-09-12 09:15:13 +02:00
1 parent 98a988a77a
commit 3fbbea61bd
16 files changed
+538 -330

No files matched your search

+16 -7
View File
@@ -16,11 +16,13 @@
*/
#include "SpellScript.h"
#include "EventProcessor.h"
#include "Log.h"
#include "ScriptMgr.h"
#include "Spell.h"
#include "SpellAuras.h"
#include "SpellMgr.h"
#include "Unit.h"
#include <sstream>
#include <string>
@@ -345,18 +347,22 @@ void SpellScript::SetHitHeal(int32 heal)
m_spell->m_healing = heal;
}
Aura* SpellScript::GetHitAura() const
Aura* SpellScript::GetHitAura(bool dynObjAura /*= false*/) const
{
if (!IsInTargetHook())
{
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::GetHitAura was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
return nullptr;
}
if (!m_spell->m_spellAura)
Aura* aura = m_spell->_spellAura;
if (dynObjAura)
aura = m_spell->_dynObjAura;
if (!aura || aura->IsRemoved())
return nullptr;
if (m_spell->m_spellAura->IsRemoved())
return nullptr;
return m_spell->m_spellAura;
return aura;
}
void SpellScript::PreventHitAura()
@@ -366,8 +372,11 @@ void SpellScript::PreventHitAura()
TC_LOG_ERROR("scripts", "Script: `%s` Spell: `%u`: function SpellScript::PreventHitAura was called, but function has no effect in current hook!", m_scriptName->c_str(), m_scriptSpellId);
return;
}
if (m_spell->m_spellAura)
m_spell->m_spellAura->Remove();
if (UnitAura* aura = m_spell->_spellAura)
aura->Remove();
if (DynObjAura* aura = m_spell->_dynObjAura)
aura->Remove();
}
void SpellScript::PreventHitEffect(SpellEffIndex effIndex)