Core/Auras: Prevent assertion fail due code in AuraEffect::HandleAuraLinked, also improve the sync between auras linked by this aura type.
This commit is contained in:
@@ -6554,25 +6554,38 @@ void AuraEffect::HandleAuraConvertRune(AuraApplication const * aurApp, uint8 mod
|
||||
|
||||
void AuraEffect::HandleAuraLinked(AuraApplication const * aurApp, uint8 mode, bool apply) const
|
||||
{
|
||||
if (!(mode & (AURA_EFFECT_HANDLE_REAL | AURA_EFFECT_HANDLE_REAPPLY)))
|
||||
return;
|
||||
|
||||
Unit * target = aurApp->GetTarget();
|
||||
|
||||
if (apply)
|
||||
{
|
||||
Unit * caster = GetTriggeredSpellCaster(m_spellProto, GetCaster(), target);
|
||||
uint32 triggeredSpellId = m_spellProto->EffectTriggerSpell[m_effIndex];
|
||||
|
||||
if (!caster)
|
||||
return;
|
||||
// If amount avalible cast with basepoints (Crypt Fever for example)
|
||||
if (GetAmount())
|
||||
caster->CastCustomSpell(target, m_spellProto->EffectTriggerSpell[m_effIndex], &m_amount, NULL, NULL, true, NULL, this);
|
||||
if (mode & AURA_EFFECT_HANDLE_REAL)
|
||||
{
|
||||
if (apply)
|
||||
{
|
||||
Unit * caster = GetTriggeredSpellCaster(m_spellProto, GetCaster(), target);
|
||||
|
||||
if (!caster)
|
||||
return;
|
||||
// If amount avalible cast with basepoints (Crypt Fever for example)
|
||||
if (GetAmount())
|
||||
caster->CastCustomSpell(target, triggeredSpellId, &m_amount, NULL, NULL, true, NULL, this);
|
||||
else
|
||||
caster->CastSpell(target, triggeredSpellId, true, NULL, this);
|
||||
}
|
||||
else
|
||||
caster->CastSpell(target, m_spellProto->EffectTriggerSpell[m_effIndex], true, NULL, this);
|
||||
{
|
||||
uint64 casterGUID = IsSpellRequiringFocusedTarget(GetSpellProto()) ? GetCasterGUID() : target->GetGUID();
|
||||
target->RemoveAura(triggeredSpellId, casterGUID, 0, aurApp->GetRemoveMode());
|
||||
}
|
||||
}
|
||||
else if (mode & AURA_EFFECT_HANDLE_REAPPLY && apply)
|
||||
{
|
||||
uint64 casterGUID = IsSpellRequiringFocusedTarget(GetSpellProto()) ? GetCasterGUID() : target->GetGUID();
|
||||
|
||||
// change the stack amount to be equal to stack amount of our aura
|
||||
if (Aura* triggeredAura = target->GetAura(triggeredSpellId, casterGUID))
|
||||
triggeredAura->ModStackAmount(GetBase()->GetStackAmount() - triggeredAura->GetStackAmount());
|
||||
}
|
||||
else
|
||||
target->RemoveAura(m_spellProto->EffectTriggerSpell[m_effIndex], GetCasterGUID(), 0, AuraRemoveMode(aurApp->GetRemoveMode()));
|
||||
}
|
||||
|
||||
void AuraEffect::HandleAuraOpenStable(AuraApplication const * aurApp, uint8 mode, bool apply) const
|
||||
|
||||
@@ -427,7 +427,7 @@ uint32 CalculatePowerCost(SpellEntry const * spellInfo, Unit const * caster, Spe
|
||||
return powerCost;
|
||||
}
|
||||
|
||||
Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target)
|
||||
bool IsSpellRequiringFocusedTarget(SpellEntry const * spellInfo)
|
||||
{
|
||||
for (uint8 i = 0 ; i < MAX_SPELL_EFFECTS; ++i)
|
||||
{
|
||||
@@ -437,8 +437,15 @@ Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_CHANNEL
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetA[i]] == TARGET_TYPE_DEST_TARGET
|
||||
|| SpellTargetType[spellInfo->EffectImplicitTargetB[i]] == TARGET_TYPE_DEST_TARGET)
|
||||
return caster;
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Unit* GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target)
|
||||
{
|
||||
if (IsSpellRequiringFocusedTarget(spellInfo))
|
||||
return caster;
|
||||
return target;
|
||||
}
|
||||
|
||||
|
||||
@@ -173,6 +173,7 @@ enum SpellLinkedType
|
||||
SPELL_LINK_REMOVE = 0,
|
||||
};
|
||||
|
||||
bool IsSpellRequiringFocusedTarget(SpellEntry const * spellInfo);
|
||||
Unit * GetTriggeredSpellCaster(SpellEntry const * spellInfo, Unit * caster, Unit * target);
|
||||
SpellSpecific GetSpellSpecific(SpellEntry const * spellInfo);
|
||||
AuraState GetSpellAuraState(SpellEntry const * spellInfo);
|
||||
|
||||
Reference in New Issue
Block a user