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

+40 -29
View File
@@ -914,10 +914,10 @@ void Spell::EffectApplyAura(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
if (!m_spellAura || !unitTarget)
if (!_spellAura || !unitTarget)
return;
ASSERT(unitTarget == m_spellAura->GetOwner());
m_spellAura->_ApplyEffectForTargets(effIndex);
_spellAura->_ApplyEffectForTargets(effIndex);
}
void Spell::EffectApplyAreaAura(SpellEffIndex effIndex)
@@ -925,10 +925,10 @@ void Spell::EffectApplyAreaAura(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
return;
if (!m_spellAura || !unitTarget)
if (!_spellAura || !unitTarget)
return;
ASSERT (unitTarget == m_spellAura->GetOwner());
m_spellAura->_ApplyEffectForTargets(effIndex);
_spellAura->_ApplyEffectForTargets(effIndex);
}
void Spell::EffectUnlearnSpecialization(SpellEffIndex effIndex)
@@ -1405,34 +1405,45 @@ void Spell::EffectPersistentAA(SpellEffIndex effIndex)
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT)
return;
if (!m_spellAura)
// only handle at last effect
for (uint8 i = effIndex + 1; i < MAX_SPELL_EFFECTS; ++i)
if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_PERSISTENT_AREA_AURA)
return;
ASSERT(!_dynObjAura);
Unit* caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
float radius = m_spellInfo->Effects[effIndex].CalcRadius(caster);
// Caster not in world, might be spell triggered from aura removal
if (!caster->IsInWorld())
return;
DynamicObject* dynObj = new DynamicObject(false);
if (!dynObj->CreateDynamicObject(caster->GetMap()->GenerateLowGuid<HighGuid::DynamicObject>(), caster, m_spellInfo, *destTarget, radius, DYNAMIC_OBJECT_AREA_SPELL))
{
Unit* caster = m_caster->GetEntry() == WORLD_TRIGGER ? m_originalCaster : m_caster;
float radius = m_spellInfo->Effects[effIndex].CalcRadius(caster);
// Caster not in world, might be spell triggered from aura removal
if (!caster->IsInWorld())
return;
DynamicObject* dynObj = new DynamicObject(false);
if (!dynObj->CreateDynamicObject(caster->GetMap()->GenerateLowGuid<HighGuid::DynamicObject>(), caster, m_spellInfo, *destTarget, radius, DYNAMIC_OBJECT_AREA_SPELL))
{
delete dynObj;
return;
}
if (Aura* aura = Aura::TryCreate(m_spellInfo, MAX_EFFECT_MASK, dynObj, caster, &m_spellValue->EffectBasePoints[0]))
{
m_spellAura = aura;
m_spellAura->_RegisterForTargets();
}
else
return;
delete dynObj;
return;
}
ASSERT(m_spellAura->GetDynobjOwner());
m_spellAura->_ApplyEffectForTargets(effIndex);
AuraCreateInfo createInfo(m_spellInfo, MAX_EFFECT_MASK, dynObj);
createInfo
.SetCaster(caster)
.SetBaseAmount(m_spellValue->EffectBasePoints);
if (Aura* aura = Aura::TryCreate(createInfo))
{
_dynObjAura = aura->ToDynObjAura();
_dynObjAura->_RegisterForTargets();
}
else
return;
ASSERT(_dynObjAura->GetDynobjOwner());
_dynObjAura->_ApplyEffectForTargets(effIndex);
}
void Spell::EffectEnergize(SpellEffIndex effIndex)
{
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)