Core/Spells: Cleanup spell effects

Port From (https://github.com/TrinityCore/TrinityCore/commit/8a4e1119ac21e2d1112d1717337597fe073e495f)
This commit is contained in:
hondacrx
2021-09-08 17:40:50 -04:00
parent 2af5cad79f
commit 5c4a7511ff
41 changed files with 2378 additions and 1987 deletions
+6 -10
View File
@@ -2045,12 +2045,12 @@ namespace Game.Entities
return false;
bool immunedToAllEffects = true;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
if (effect == null || !effect.IsEffect())
if (!spellEffectInfo.IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, effect.EffectIndex, caster))
if (!IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster))
{
immunedToAllEffects = false;
break;
@@ -2063,16 +2063,12 @@ namespace Game.Entities
return base.IsImmunedToSpell(spellInfo, caster);
}
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, WorldObject caster)
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, WorldObject caster)
{
SpellEffectInfo effect = spellInfo.GetEffect(index);
if (effect == null)
if (GetCreatureTemplate().CreatureType == CreatureType.Mechanical && spellEffectInfo.IsEffect(SpellEffectName.Heal))
return true;
if (GetCreatureTemplate().CreatureType == CreatureType.Mechanical && effect.Effect == SpellEffectName.Heal)
return true;
return base.IsImmunedToSpellEffect(spellInfo, index, caster);
return base.IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster);
}
public bool IsElite()
+3 -3
View File
@@ -444,9 +444,9 @@ namespace Game.Misc
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(quest.RewardSpell, Difficulty.None);
if (spellInfo != null)
{
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
if (effect != null && effect.IsEffect(SpellEffectName.LearnSpell))
packet.LearnSpells.Add(effect.TriggerSpell);
foreach (var spellEffectInfo in spellInfo.GetEffects())
if (spellEffectInfo.IsEffect(SpellEffectName.LearnSpell))
packet.LearnSpells.Add(spellEffectInfo.TriggerSpell);
}
quest.BuildQuestRewards(packet.Rewards, _session.GetPlayer());
+3 -3
View File
@@ -129,13 +129,13 @@ namespace Game.Entities
// check ranks
bool hasLearnSpellEffect = false;
bool knowsAllLearnedSpells = true;
foreach (SpellEffectInfo spellEffect in Global.SpellMgr.GetSpellInfo(trainerSpell.SpellId, Difficulty.None).GetEffects())
foreach (var spellEffectInfo in Global.SpellMgr.GetSpellInfo(trainerSpell.SpellId, Difficulty.None).GetEffects())
{
if (spellEffect == null || !spellEffect.IsEffect(SpellEffectName.LearnSpell))
if (!spellEffectInfo.IsEffect(SpellEffectName.LearnSpell))
continue;
hasLearnSpellEffect = true;
if (!player.HasSpell(spellEffect.TriggerSpell))
if (!player.HasSpell(spellEffectInfo.TriggerSpell))
knowsAllLearnedSpells = false;
}
@@ -2219,11 +2219,11 @@ namespace Game.Entities
SpellInfo transform = Global.SpellMgr.GetSpellInfo(unit.GetTransForm(), unit.GetMap().GetDifficultyID());
if (transform != null)
{
foreach (SpellEffectInfo effect in transform.GetEffects())
foreach (var spellEffectInfo in transform.GetEffects())
{
if (effect != null && effect.IsAura(AuraType.Transform))
if (spellEffectInfo.IsAura(AuraType.Transform))
{
CreatureTemplate transformInfo = Global.ObjectMgr.GetCreatureTemplate((uint)effect.MiscValue);
CreatureTemplate transformInfo = Global.ObjectMgr.GetCreatureTemplate((uint)spellEffectInfo.MiscValue);
if (transformInfo != null)
{
cinfo = transformInfo;
+4 -5
View File
@@ -1682,18 +1682,17 @@ namespace Game.Entities
return null;
}
public int CalculateSpellDamage(Unit target, SpellInfo spellProto, uint effIndex, int? basePoints = null, uint castItemId = 0, int itemLevel = -1)
public int CalculateSpellDamage(Unit target, SpellEffectInfo spellEffectInfo, int? basePoints = null, uint castItemId = 0, int itemLevel = -1)
{
return CalculateSpellDamage(out _, target, spellProto, effIndex, basePoints, castItemId, itemLevel);
return CalculateSpellDamage(out _, target, spellEffectInfo, basePoints, castItemId, itemLevel);
}
// function uses real base points (typically value - 1)
public int CalculateSpellDamage(out float variance, Unit target, SpellInfo spellProto, uint effIndex, int? basePoints = null, uint castItemId = 0, int itemLevel = -1)
public int CalculateSpellDamage(out float variance, Unit target, SpellEffectInfo spellEffectInfo, int? basePoints = null, uint castItemId = 0, int itemLevel = -1)
{
SpellEffectInfo effect = spellProto.GetEffect(effIndex);
variance = 0.0f;
return effect != null ? effect.CalcValue(out variance, this, basePoints, target, castItemId, itemLevel) : 0;
return spellEffectInfo != null ? spellEffectInfo.CalcValue(out variance, this, basePoints, target, castItemId, itemLevel) : 0;
}
public float GetSpellMaxRangeForTarget(Unit target, SpellInfo spellInfo)
+4 -3
View File
@@ -5136,9 +5136,10 @@ namespace Game.Entities
CastSpellExtraArgs args = new(TriggerCastFlags.FullMask);
args.CastItem = artifact;
if (artifactPowerRank.AuraPointsOverride != 0)
for (int i = 0; i < SpellConst.MaxEffects; ++i)
if (spellInfo.GetEffect((uint)i) != null)
args.AddSpellMod(SpellValueMod.BasePoint0 + i, (int)artifactPowerRank.AuraPointsOverride);
{
foreach (var spellEffectInfo in spellInfo.GetEffects())
args.AddSpellMod(SpellValueMod.BasePoint0 + (int)spellEffectInfo.EffectIndex, (int)artifactPowerRank.AuraPointsOverride);
}
CastSpell(this, artifactPowerRank.SpellID, args);
}
+2 -5
View File
@@ -107,9 +107,9 @@ namespace Game.Entities
// check learned spells state
bool found = false;
foreach (SpellEffectInfo eff in spellInfo.GetEffects())
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
if (eff != null && eff.Effect == SpellEffectName.LearnSpell && !HasSpell(eff.TriggerSpell))
if (spellEffectInfo.IsEffect(SpellEffectName.LearnSpell) && !HasSpell(spellEffectInfo.TriggerSpell))
{
found = true;
break;
@@ -121,9 +121,6 @@ namespace Game.Entities
return;
SpellEffectInfo effect = spellInfo.GetEffect(0);
if (effect == null)
return;
uint learned_0 = effect.TriggerSpell;
if (!HasSpell(learned_0))
{
+7 -7
View File
@@ -1711,8 +1711,8 @@ namespace Game.Entities
// special check to filter things like Shield Wall, the aura is not permanent and must stay even without required item
if (!spellInfo.IsPassive())
{
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
if (effect != null && effect.IsAura())
foreach (var spellEffectInfo in spellInfo.GetEffects())
if (spellEffectInfo.IsAura())
return true;
}
}
@@ -2284,9 +2284,9 @@ namespace Game.Entities
// passive spells which apply aura and have an item requirement are to be added manually, instead of casted
if (spellInfo.EquippedItemClass >= 0)
{
foreach (SpellEffectInfo effectInfo in spellInfo.GetEffects())
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
if (effectInfo != null && effectInfo.IsAura())
if (spellEffectInfo.IsAura())
{
if (!HasAura(spellInfo.Id) && HasItemFitToSpellRequirements(spellInfo))
AddAura(spellInfo.Id, this);
@@ -3289,10 +3289,10 @@ namespace Game.Entities
int effectPct = Math.Max(0, 100 - (lvlDifference * lvlPenaltyFactor));
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
if (spellInfo.GetEffect(i).IsEffect())
args.AddSpellMod(SpellValueMod.BasePoint0 + i, MathFunctions.CalculatePct(spellInfo.GetEffect(i).CalcValue(this), effectPct));
if (spellEffectInfo.IsEffect())
args.AddSpellMod(SpellValueMod.BasePoint0 + (int)spellEffectInfo.EffectIndex, MathFunctions.CalculatePct(spellEffectInfo.CalcValue(this), effectPct));
}
}
@@ -91,9 +91,9 @@ namespace Game.Entities
RemoveSpell(talent.SpellID, true);
// search for spells that the talent teaches and unlearn them
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
if (effect != null && effect.TriggerSpell > 0 && effect.Effect == SpellEffectName.LearnSpell)
RemoveSpell(effect.TriggerSpell, true);
foreach (var spellEffectInfo in spellInfo.GetEffects())
if (spellEffectInfo.IsEffect(SpellEffectName.LearnSpell) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
if (talent.OverridesSpellID != 0)
RemoveOverrideSpell(talent.OverridesSpellID, talent.SpellID);
@@ -301,9 +301,9 @@ namespace Game.Entities
RemoveSpell(talentInfo.SpellID, true);
// search for spells that the talent teaches and unlearn them
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
if (effect != null && effect.TriggerSpell > 0 && effect.Effect == SpellEffectName.LearnSpell)
RemoveSpell(effect.TriggerSpell, true);
foreach (var spellEffectInfo in spellInfo.GetEffects())
if (spellEffectInfo.IsEffect(SpellEffectName.LearnSpell) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
if (talentInfo.OverridesSpellID != 0)
RemoveOverrideSpell(talentInfo.OverridesSpellID, talentInfo.SpellID);
@@ -318,9 +318,9 @@ namespace Game.Entities
RemoveSpell(talentInfo.SpellID, true);
// search for spells that the talent teaches and unlearn them
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
if (effect != null && effect.TriggerSpell > 0 && effect.Effect == SpellEffectName.LearnSpell)
RemoveSpell(effect.TriggerSpell, true);
foreach (var spellEffectInfo in spellInfo.GetEffects())
if (spellEffectInfo.IsEffect(SpellEffectName.LearnSpell) && spellEffectInfo.TriggerSpell > 0)
RemoveSpell(spellEffectInfo.TriggerSpell, true);
if (talentInfo.OverridesSpellID != 0)
RemoveOverrideSpell(talentInfo.OverridesSpellID, talentInfo.SpellID);
+6 -9
View File
@@ -3636,19 +3636,16 @@ namespace Game.Entities
return false;
}
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, WorldObject caster)
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, WorldObject caster)
{
SpellEffectInfo effect = spellInfo.GetEffect(index);
if (effect == null || !effect.IsEffect())
return false;
// players are immune to taunt (the aura and the spell effect).
if (effect.IsAura(AuraType.ModTaunt))
return true;
if (effect.IsEffect(SpellEffectName.AttackMe))
if (spellEffectInfo.IsAura(AuraType.ModTaunt))
return true;
return base.IsImmunedToSpellEffect(spellInfo, index, caster);
if (spellEffectInfo.IsEffect(SpellEffectName.AttackMe))
return true;
return base.IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster);
}
void RegenerateAll()
+8 -11
View File
@@ -1005,12 +1005,12 @@ namespace Game.Entities
return 0;
int resistMech = 0;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
if (effect == null || !effect.IsEffect())
if (!spellEffectInfo.IsEffect())
break;
int effect_mech = (int)spellInfo.GetEffectMechanic(effect.EffectIndex);
int effect_mech = (int)spellInfo.GetEffectMechanic(spellEffectInfo.EffectIndex);
if (effect_mech != 0)
{
int temp = GetTotalAuraModifierByMiscValue(AuraType.ModMechanicResistance, effect_mech);
@@ -1538,21 +1538,18 @@ namespace Game.Entities
if (chrSpec == null)
return;
for (uint i = 0; i < PlayerConst.MaxMasterySpells; ++i)
foreach (uint masterySpellId in chrSpec.MasterySpellID)
{
Aura aura = GetAura(chrSpec.MasterySpellID[i]);
Aura aura = GetAura(masterySpellId);
if (aura != null)
{
foreach (SpellEffectInfo effect in aura.GetSpellInfo().GetEffects())
foreach (var spellEffectInfo in aura.GetSpellInfo().GetEffects())
{
if (effect == null)
continue;
float mult = effect.BonusCoefficient;
float mult = spellEffectInfo.BonusCoefficient;
if (MathFunctions.fuzzyEq(mult, 0.0f))
continue;
aura.GetEffect(effect.EffectIndex).ChangeAmount((int)(value * mult));
aura.GetEffect(spellEffectInfo.EffectIndex).ChangeAmount((int)(value * mult));
}
}
}
+4 -5
View File
@@ -143,17 +143,16 @@ namespace Game.Entities
AddObjectToRemoveList();
}
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, WorldObject caster)
public override bool IsImmunedToSpellEffect(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, WorldObject caster)
{
// @todo possibly all negative auras immune?
if (GetEntry() == 5925)
return false;
SpellEffectInfo effect = spellInfo.GetEffect(index);
if (effect == null)
if (spellEffectInfo == null)
return true;
switch (effect.ApplyAuraName)
switch (spellEffectInfo.ApplyAuraName)
{
case AuraType.PeriodicDamage:
case AuraType.PeriodicLeech:
@@ -164,7 +163,7 @@ namespace Game.Entities
break;
}
return base.IsImmunedToSpellEffect(spellInfo, index, caster);
return base.IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster);
}
public uint GetSpell(byte slot = 0) { return m_spells[slot]; }
+3 -3
View File
@@ -226,12 +226,12 @@ namespace Game.Entities
SpellInfo spInfo = Global.SpellMgr.GetSpellInfo(minion.ToTotem().GetSpell(), GetMap().GetDifficultyID());
if (spInfo != null)
{
foreach (SpellEffectInfo effect in spInfo.GetEffects())
foreach (var spellEffectInfo in spInfo.GetEffects())
{
if (effect == null || effect.Effect != SpellEffectName.Summon)
if (spellEffectInfo == null || !spellEffectInfo.IsEffect(SpellEffectName.Summon))
continue;
RemoveAllMinionsByEntry((uint)effect.MiscValue);
RemoveAllMinionsByEntry((uint)spellEffectInfo.MiscValue);
}
}
}
+40 -53
View File
@@ -69,7 +69,7 @@ namespace Game.Entities
return DoneAdvertisedBenefit;
}
public uint SpellDamageBonusDone(Unit victim, SpellInfo spellProto, uint pdamage, DamageEffectType damagetype, SpellEffectInfo effect, uint stack = 1)
public uint SpellDamageBonusDone(Unit victim, SpellInfo spellProto, uint pdamage, DamageEffectType damagetype, SpellEffectInfo spellEffectInfo, uint stack = 1)
{
if (spellProto == null || victim == null || damagetype == DamageEffectType.Direct)
return pdamage;
@@ -83,7 +83,7 @@ namespace Game.Entities
{
Unit owner = GetOwner();
if (owner != null)
return owner.SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, effect, stack);
return owner.SpellDamageBonusDone(victim, spellProto, pdamage, damagetype, spellEffectInfo, stack);
}
int DoneTotal = 0;
@@ -100,9 +100,9 @@ namespace Game.Entities
DoneAdvertisedBenefit += ((Guardian)this).GetBonusDamage();
// Check for table values
if (effect.BonusCoefficientFromAP > 0.0f)
if (spellEffectInfo.BonusCoefficientFromAP > 0.0f)
{
float ApCoeffMod = effect.BonusCoefficientFromAP;
float ApCoeffMod = spellEffectInfo.BonusCoefficientFromAP;
Player modOwner = GetSpellModOwner();
if (modOwner)
{
@@ -130,7 +130,7 @@ namespace Game.Entities
}
// Default calculation
float coeff = effect.BonusCoefficient;
float coeff = spellEffectInfo.BonusCoefficient;
if (DoneAdvertisedBenefit != 0)
{
Player modOwner1 = GetSpellModOwner();
@@ -382,14 +382,14 @@ namespace Game.Entities
return damage;
}
public uint SpellHealingBonusDone(Unit victim, SpellInfo spellProto, uint healamount, DamageEffectType damagetype, SpellEffectInfo effect, uint stack = 1)
public uint SpellHealingBonusDone(Unit victim, SpellInfo spellProto, uint healamount, DamageEffectType damagetype, SpellEffectInfo spellEffectInfo, uint stack = 1)
{
// For totems get healing bonus from owner (statue isn't totem in fact)
if (IsTypeId(TypeId.Unit) && IsTotem())
{
Unit owner = GetOwner();
if (owner)
return owner.SpellHealingBonusDone(victim, spellProto, healamount, damagetype, effect, stack);
return owner.SpellHealingBonusDone(victim, spellProto, healamount, damagetype, spellEffectInfo, stack);
}
// No bonus healing for potion spells
@@ -428,14 +428,14 @@ namespace Game.Entities
DoneAdvertisedBenefit += (uint)((Guardian)this).GetBonusDamage();
// Check for table values
float coeff = effect.BonusCoefficient;
if (effect.BonusCoefficientFromAP > 0.0f)
float coeff = spellEffectInfo.BonusCoefficient;
if (spellEffectInfo.BonusCoefficientFromAP > 0.0f)
{
WeaponAttackType attType = (spellProto.IsRangedWeaponSpell() && spellProto.DmgClass != SpellDmgClass.Melee) ? WeaponAttackType.RangedAttack : WeaponAttackType.BaseAttack;
float APbonus = (float)victim.GetTotalAuraModifier(attType == WeaponAttackType.BaseAttack ? AuraType.MeleeAttackPowerAttackerBonus : AuraType.RangedAttackPowerAttackerBonus);
APbonus += GetTotalAttackPowerValue(attType);
DoneTotal += (int)(effect.BonusCoefficientFromAP * stack * APbonus);
DoneTotal += (int)(spellEffectInfo.BonusCoefficientFromAP * stack * APbonus);
}
else if (coeff <= 0.0f) // no AP and no SP coefs, skip
{
@@ -458,12 +458,9 @@ namespace Game.Entities
DoneTotal += (int)(DoneAdvertisedBenefit * coeff * stack);
}
foreach (SpellEffectInfo eff in spellProto.GetEffects())
foreach (var otherSpellEffectInfo in spellProto.GetEffects())
{
if (eff == null)
continue;
switch (eff.ApplyAuraName)
switch (otherSpellEffectInfo.ApplyAuraName)
{
// Bonus healing does not apply to these spells
case AuraType.PeriodicLeech:
@@ -471,7 +468,7 @@ namespace Game.Entities
DoneTotal = 0;
break;
}
if (eff.Effect == SpellEffectName.HealthLeech)
if (otherSpellEffectInfo.IsEffect(SpellEffectName.HealthLeech))
DoneTotal = 0;
}
@@ -1247,14 +1244,14 @@ namespace Game.Entities
}
bool immuneToAllEffects = true;
foreach (SpellEffectInfo effect in spellInfo.GetEffects())
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
// State/effect immunities applied by aura expect full spell immunity
// Ignore effects with mechanic, they are supposed to be checked separately
if (effect == null || !effect.IsEffect())
if (!spellEffectInfo.IsEffect())
continue;
if (!IsImmunedToSpellEffect(spellInfo, effect.EffectIndex, caster))
if (!IsImmunedToSpellEffect(spellInfo, spellEffectInfo, caster))
{
immuneToAllEffects = false;
break;
@@ -1313,22 +1310,20 @@ namespace Game.Entities
return mask;
}
public virtual bool IsImmunedToSpellEffect(SpellInfo spellInfo, uint index, WorldObject caster)
public virtual bool IsImmunedToSpellEffect(SpellInfo spellInfo, SpellEffectInfo spellEffectInfo, WorldObject caster)
{
if (spellInfo == null)
return false;
SpellEffectInfo effect = spellInfo.GetEffect(index);
if (effect == null || !effect.IsEffect())
if (spellEffectInfo == null || !spellEffectInfo.IsEffect())
return false;
// If m_immuneToEffect type contain this effect type, IMMUNE effect.
uint eff = (uint)effect.Effect;
var effectList = m_spellImmune[(int)SpellImmunity.Effect];
if (effectList.ContainsKey(eff))
if (effectList.ContainsKey((uint)spellEffectInfo.Effect))
return true;
uint mechanic = (uint)effect.Mechanic;
uint mechanic = (uint)spellEffectInfo.Mechanic;
if (mechanic != 0)
{
var mechanicList = m_spellImmune[(int)SpellImmunity.Mechanic];
@@ -1338,7 +1333,7 @@ namespace Game.Entities
if (!spellInfo.HasAttribute(SpellAttr3.IgnoreHitResult))
{
uint aura = (uint)effect.ApplyAuraName;
uint aura = (uint)spellEffectInfo.ApplyAuraName;
if (aura != 0)
{
var list = m_spellImmune[(int)SpellImmunity.State];
@@ -1351,7 +1346,7 @@ namespace Game.Entities
var immuneAuraApply = GetAuraEffectsByType(AuraType.ModImmuneAuraApplySchool);
foreach (var auraEffect in immuneAuraApply)
if (Convert.ToBoolean(auraEffect.GetMiscValue() & (int)spellInfo.GetSchoolMask()) && // Check school
((caster && !IsFriendlyTo(caster)) || !spellInfo.IsPositiveEffect(index))) // Harmful
((caster && !IsFriendlyTo(caster)) || !spellInfo.IsPositiveEffect(spellEffectInfo.EffectIndex))) // Harmful
return true;
}
}
@@ -2195,9 +2190,9 @@ namespace Game.Entities
}
// turn off snare auras by setting amount to 0
foreach (SpellEffectInfo spellEffectInfo in aura.GetSpellInfo().GetEffects())
foreach (var spellEffectInfo in aura.GetSpellInfo().GetEffects())
{
if (spellEffectInfo != null && pair.Value.HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.Mechanic == Mechanics.Snare)
if (pair.Value.HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.Mechanic == Mechanics.Snare)
aura.GetEffect(spellEffectInfo.EffectIndex).ChangeAmount(0);
}
}
@@ -2492,12 +2487,13 @@ namespace Game.Entities
if (target.IsImmunedToSpell(spellInfo, this))
return null;
for (byte i = 0; i < SpellConst.MaxEffects; ++i)
foreach (var spellEffectInfo in spellInfo.GetEffects())
{
if (!Convert.ToBoolean(effMask & (1 << i)))
if ((effMask & (1 << (int)spellEffectInfo.EffectIndex)) == 0)
continue;
if (target.IsImmunedToSpellEffect(spellInfo, i, this))
effMask &= ~(uint)(1 << i);
if (target.IsImmunedToSpellEffect(spellInfo, spellEffectInfo, this))
effMask &= ~(1u << (int)spellEffectInfo.EffectIndex);
}
if (effMask == 0)
@@ -2546,12 +2542,9 @@ namespace Game.Entities
{
byte i = 0;
bool valid = false;
foreach (SpellEffectInfo effect in spellEntry.GetEffects())
foreach (var spellEffectInfo in spellEntry.GetEffects())
{
if (effect == null)
continue;
if (effect.ApplyAuraName == AuraType.ControlVehicle)
if (spellEffectInfo.ApplyAuraName == AuraType.ControlVehicle)
{
valid = true;
break;
@@ -2575,11 +2568,8 @@ namespace Game.Entities
else // This can happen during Player._LoadAuras
{
int[] bp = new int[SpellConst.MaxEffects];
foreach (SpellEffectInfo effect in spellEntry.GetEffects())
{
if (effect != null)
bp[effect.EffectIndex] = effect.BasePoints;
}
foreach (var spellEffectInfo in spellEntry.GetEffects())
bp[spellEffectInfo.EffectIndex] = spellEffectInfo.BasePoints;
bp[i] = seatId;
@@ -2643,7 +2633,7 @@ namespace Game.Entities
if (spellInfo.Mechanic != 0 && Convert.ToBoolean(mechanicMask & (1 << (int)spellInfo.Mechanic)))
return true;
foreach (SpellEffectInfo spellEffectInfo in spellInfo.GetEffects())
foreach (var spellEffectInfo in spellInfo.GetEffects())
if (spellEffectInfo != null && pair.Value.HasEffect(spellEffectInfo.EffectIndex) && spellEffectInfo.IsEffect() && spellEffectInfo.Mechanic != 0)
if ((mechanicMask & (1 << (int)spellEffectInfo.Mechanic)) != 0)
return true;
@@ -3891,22 +3881,19 @@ namespace Game.Entities
return null;
// update basepoints with new values - effect amount will be recalculated in ModStackAmount
foreach (SpellEffectInfo effect in createInfo.GetSpellInfo().GetEffects())
foreach (var spellEffectInfo in createInfo.GetSpellInfo().GetEffects())
{
if (effect == null)
continue;
AuraEffect eff = foundAura.GetEffect(effect.EffectIndex);
if (eff == null)
AuraEffect auraEff = foundAura.GetEffect(spellEffectInfo.EffectIndex);
if (auraEff == null)
continue;
int bp;
if (createInfo.BaseAmount != null)
bp = createInfo.BaseAmount[effect.EffectIndex];
bp = createInfo.BaseAmount[spellEffectInfo.EffectIndex];
else
bp = effect.BasePoints;
bp = spellEffectInfo.BasePoints;
eff.m_baseAmount = bp;
auraEff.m_baseAmount = bp;
}
// correct cast item guid if needed
+6 -10
View File
@@ -2089,7 +2089,7 @@ namespace Game.Entities
RemoveDynamicUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.ChannelObjects), index);
}
public static bool IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo spellInfo = null, sbyte effIndex = -1)
public static bool IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo spellInfo = null, SpellEffectInfo spellEffectInfo = null)
{
// only physical spells damage gets reduced by armor
if ((schoolMask & SpellSchoolMask.Normal) == 0)
@@ -2101,16 +2101,12 @@ namespace Game.Entities
if (spellInfo.HasAttribute(SpellCustomAttributes.IgnoreArmor))
return false;
if (effIndex != -1)
// bleeding effects are not reduced by armor
if (spellEffectInfo != null)
{
// bleeding effects are not reduced by armor
SpellEffectInfo effect = spellInfo.GetEffect((uint)effIndex);
if (effect != null)
{
if (effect.ApplyAuraName == AuraType.PeriodicDamage || effect.Effect == SpellEffectName.SchoolDamage)
if (spellInfo.GetEffectMechanicMask((byte)effIndex).HasAnyFlag((1u << (int)Mechanics.Bleed)))
return false;
}
if (spellEffectInfo.ApplyAuraName == AuraType.PeriodicDamage || spellEffectInfo.Effect == SpellEffectName.SchoolDamage)
if (spellInfo.GetEffectMechanicMask(spellEffectInfo.EffectIndex).HasAnyFlag((1u << (int)Mechanics.Bleed)))
return false;
}
}