Core/Auras: Remove m_effIndex member of AuraEffect and always take it from SpellEffectInfo

Port From (https://github.com/TrinityCore/TrinityCore/commit/efdca47aff354079bc73d248e022c2e914d94e7b)
This commit is contained in:
hondacrx
2021-03-15 15:37:07 -04:00
parent 0491a60e48
commit cee1fbe0d2
5 changed files with 15 additions and 18 deletions
+4 -4
View File
@@ -154,7 +154,7 @@ namespace Game.Spells
_flags |= positiveFound ? AuraFlags.Positive : AuraFlags.Negative;
}
bool effectNeedsAmount(AuraEffect effect) => effect != null && (GetEffectsToApply() & (1 << effect.GetEffIndex())) != 0 && Aura.EffectTypeNeedsSendingAmount(effect.GetAuraType());
bool effectNeedsAmount(AuraEffect effect) => effect != null && (GetEffectsToApply() & (1 << (int)effect.GetEffIndex())) != 0 && Aura.EffectTypeNeedsSendingAmount(effect.GetAuraType());
if (GetBase().GetSpellInfo().HasAttribute(SpellAttr8.AuraSendAmount) || GetBase().GetAuraEffects().Any(effectNeedsAmount))
_flags |= AuraFlags.Scalable;
@@ -343,7 +343,7 @@ namespace Game.Spells
foreach (SpellEffectInfo effect in GetSpellInfo().GetEffects())
{
if (effect != null && Convert.ToBoolean(effMask & (1 << (int)effect.EffectIndex)))
_effects[effect.EffectIndex] = new AuraEffect(this, effect.EffectIndex, baseAmount != null ? baseAmount[effect.EffectIndex] : (int?)null, caster);
_effects[effect.EffectIndex] = new AuraEffect(this, effect, baseAmount != null ? baseAmount[effect.EffectIndex] : (int?)null, caster);
}
}
@@ -1057,7 +1057,7 @@ namespace Game.Spells
continue;
effect.SetAmount(amount[effect.GetEffIndex()]);
effect.SetCanBeRecalculated(Convert.ToBoolean(recalculateMask & (1 << effect.GetEffIndex())));
effect.SetCanBeRecalculated(Convert.ToBoolean(recalculateMask & (1 << (int)effect.GetEffIndex())));
effect.CalculatePeriodic(caster, false, true);
effect.CalculateSpellMod();
effect.RecalculateAmount(caster);
@@ -2350,7 +2350,7 @@ namespace Game.Spells
uint effMask = 0;
foreach (AuraEffect effect in GetAuraEffects())
if (effect != null)
effMask |= (uint)(1 << effect.GetEffIndex());
effMask |= (uint)(1 << (int)effect.GetEffIndex());
return effMask;
}
+6 -9
View File
@@ -32,14 +32,13 @@ namespace Game.Spells
{
public class AuraEffect
{
public AuraEffect(Aura baseAura, uint effIndex, int? baseAmount, Unit caster)
public AuraEffect(Aura baseAura, SpellEffectInfo spellEfffectInfo, int? baseAmount, Unit caster)
{
auraBase = baseAura;
m_spellInfo = baseAura.GetSpellInfo();
_effectInfo = m_spellInfo.GetEffect(effIndex);
_effectInfo = spellEfffectInfo;
m_baseAmount = baseAmount.HasValue ? baseAmount.Value : _effectInfo.CalcBaseValue(caster, baseAura.GetAuraType() == AuraObjectType.Unit ? baseAura.GetOwner().ToUnit() : null, baseAura.GetCastItemId(), baseAura.GetCastItemLevel());
m_donePct = 1.0f;
m_effIndex = (byte)effIndex;
m_canBeRecalculated = true;
m_isPeriodic = false;
@@ -873,7 +872,7 @@ namespace Game.Spells
public SpellInfo GetSpellInfo() { return m_spellInfo; }
public uint GetId() { return m_spellInfo.Id; }
public byte GetEffIndex() { return m_effIndex; }
public uint GetEffIndex() { return _effectInfo.EffectIndex; }
public int GetBaseAmount() { return m_baseAmount; }
public int GetPeriod() { return m_period; }
@@ -939,20 +938,18 @@ namespace Game.Spells
Aura auraBase;
SpellInfo m_spellInfo;
SpellEffectInfo _effectInfo;
public int m_baseAmount;
SpellModifier m_spellmod;
public int m_baseAmount;
int m_amount;
int m_damage;
float m_critChance;
float m_donePct;
SpellModifier m_spellmod;
int m_periodicTimer;
int m_period;
uint m_tickNumber;
byte m_effIndex;
bool m_canBeRecalculated;
bool m_isPeriodic;
#endregion
@@ -4154,7 +4151,7 @@ namespace Game.Spells
// pet auras
if (target.GetTypeId() == TypeId.Player && mode.HasAnyFlag(AuraEffectHandleModes.Real))
{
PetAura petSpell = Global.SpellMgr.GetPetAura(GetId(), m_effIndex);
PetAura petSpell = Global.SpellMgr.GetPetAura(GetId(), (byte)GetEffIndex());
if (petSpell != null)
{
if (apply)
+1 -1
View File
@@ -5539,7 +5539,7 @@ namespace Game.Spells
foundNotMechanic = true;
// fill up aura mechanic info to send client proper error message
_param1 = (uint)aurEff.GetSpellInfo().GetEffect(aurEff.GetEffIndex()).Mechanic;
_param1 = (uint)aurEff.GetSpellEffectInfo().Mechanic;
if (_param1 == 0)
_param1 = (uint)aurEff.GetSpellInfo().Mechanic;
+1 -1
View File
@@ -428,7 +428,7 @@ namespace Scripts.Spells.Druid
spellMod.op = SpellModOp.Dot;
spellMod.type = SpellModType.Flat;
spellMod.spellId = GetId();
spellMod.mask = GetSpellInfo().GetEffect(aurEff.GetEffIndex()).SpellClassMask;
spellMod.mask = aurEff.GetSpellEffectInfo().SpellClassMask;
}
spellMod.value = aurEff.GetAmount() / 7;
}
+3 -3
View File
@@ -1610,14 +1610,14 @@ namespace Scripts.Spells.Quest
// 51769 - Emblazon Runeblade
[Script]
class spell_q12619_emblazon_runeblade : AuraScript
class spell_q12619_emblazon_runeblade_AuraScript : AuraScript
{
void HandleEffectPeriodic(AuraEffect aurEff)
{
PreventDefaultAction();
Unit caster = GetCaster();
if (caster)
caster.CastSpell(caster, GetSpellInfo().GetEffect(aurEff.GetEffIndex()).TriggerSpell, true, null, aurEff);
caster.CastSpell(caster, aurEff.GetSpellEffectInfo().TriggerSpell, true, null, aurEff);
}
public override void Register()
@@ -1628,7 +1628,7 @@ namespace Scripts.Spells.Quest
// 51770 - Emblazon Runeblade
[Script]
class spell_q12619_emblazon_runeblade_effect : SpellScript
class spell_q12619_emblazon_runeblade : SpellScript
{
void HandleScript(uint effIndex)
{