Core/Spells: Refactor Player::ApplySpellMod to take SpellInfo argument instead of just spell id

Port From (https://github.com/TrinityCore/TrinityCore/commit/624881bef5c90a91e4c59e5bf404d8775c2ca55d)
This commit is contained in:
hondacrx
2021-03-04 14:43:39 -05:00
parent 879c4dfed2
commit 923def9f4a
11 changed files with 65 additions and 77 deletions
+6 -6
View File
@@ -703,7 +703,7 @@ namespace Game.Spells
// IsPermanent() checks max duration (which we are supposed to calculate here)
if (maxDuration != -1 && modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.Duration, ref maxDuration);
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.Duration, ref maxDuration);
return maxDuration;
}
@@ -716,7 +716,7 @@ namespace Game.Spells
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(GetId(), SpellModOp.Duration, ref duration);
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.Duration, ref duration);
}
}
@@ -870,7 +870,7 @@ namespace Game.Spells
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.MaxStackAmount, ref maxStackAmount);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.MaxStackAmount, ref maxStackAmount);
}
return maxStackAmount;
}
@@ -1054,7 +1054,7 @@ namespace Game.Spells
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.ResistDispelChance, ref resistChance);
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.ResistDispelChance, ref resistChance);
}
resistChance = resistChance < 0 ? 0 : resistChance;
@@ -1836,7 +1836,7 @@ namespace Game.Spells
// apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.ChanceOfSuccess, ref chance);
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.ChanceOfSuccess, ref chance);
}
// proc chance is reduced by an additional 3.333% per level past 60
@@ -2350,7 +2350,7 @@ namespace Game.Spells
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.Charges, ref maxProcCharges);
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.Charges, ref maxProcCharges);
}
return (byte)maxProcCharges;
}
+1 -1
View File
@@ -168,7 +168,7 @@ namespace Game.Spells
{
// Apply periodic time mod
if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.ActivationTime, ref m_period);
modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.ActivationTime, ref m_period);
if (caster != null)
{
+10 -10
View File
@@ -68,7 +68,7 @@ namespace Game.Spells
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(info.Id, SpellModOp.StackAmount, ref m_spellValue.AuraStackAmount, this);
modOwner.ApplySpellMod(info, SpellModOp.StackAmount, ref m_spellValue.AuraStackAmount, this);
if (!originalCasterGUID.IsEmpty())
m_originalCasterGUID = originalCasterGUID;
@@ -1089,7 +1089,7 @@ namespace Game.Spells
int maxTargets = effect.ChainTargets;
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.JumpTargets, ref maxTargets, this);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.JumpTargets, ref maxTargets, this);
if (maxTargets > 1)
{
@@ -1411,7 +1411,7 @@ namespace Game.Spells
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.JumpDistance, ref jumpRadius, this);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.JumpDistance, ref jumpRadius, this);
// chain lightning/heal spells and similar - allow to jump at larger distance and go out of los
bool isBouncingFar = (m_spellInfo.HasAttribute(SpellAttr4.AreaTargetChain)
@@ -2367,7 +2367,7 @@ namespace Game.Spells
range = m_spellInfo.GetMaxRange(m_spellInfo.IsPositive());
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.Range, ref range, this);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.Range, ref range, this);
// add little tolerance level
range += Math.Min(3.0f, range * 0.1f); // 10% but no more than 3.0f
@@ -2938,7 +2938,7 @@ namespace Game.Spells
// Apply duration mod
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.Duration, ref duration);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.Duration, ref duration);
// Apply haste mods
m_caster.ModSpellDurationTime(m_spellInfo, ref duration, this);
@@ -4213,7 +4213,7 @@ namespace Game.Spells
//lower spell cost on fail (by talent aura)
Player modOwner = m_caster.ToPlayer().GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.SpellCostRefundOnFail, ref cost.Amount);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.SpellCostRefundOnFail, ref cost.Amount);
}
break;
}
@@ -5862,7 +5862,7 @@ namespace Game.Spells
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.Range, ref maxRange, this);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.Range, ref maxRange, this);
maxRange += rangeMod;
@@ -6437,7 +6437,7 @@ namespace Game.Spells
//check pushback reduce
int delaytime = 500; // spellcasting delay is normally 500ms
int delayReduce = 100; // must be initialized to 100 for percent modifiers
m_caster.ToPlayer().ApplySpellMod(m_spellInfo.Id, SpellModOp.NotLoseCastingTime, ref delayReduce, this);
m_caster.ToPlayer().ApplySpellMod(m_spellInfo, SpellModOp.NotLoseCastingTime, ref delayReduce, this);
delayReduce += m_caster.GetTotalAuraModifier(AuraType.ReducePushback) - 100;
if (delayReduce >= 100)
return;
@@ -6472,7 +6472,7 @@ namespace Game.Spells
//check pushback reduce
int delaytime = MathFunctions.CalculatePct(m_spellInfo.GetDuration(), 25); // channeling delay is normally 25% of its time per hit
int delayReduce = 100; // must be initialized to 100 for percent modifiers
m_caster.ToPlayer().ApplySpellMod(m_spellInfo.Id, SpellModOp.NotLoseCastingTime, ref delayReduce, this);
m_caster.ToPlayer().ApplySpellMod(m_spellInfo, SpellModOp.NotLoseCastingTime, ref delayReduce, this);
delayReduce += m_caster.GetTotalAuraModifier(AuraType.ReducePushback) - 100;
if (delayReduce >= 100)
return;
@@ -7229,7 +7229,7 @@ namespace Game.Spells
// gcd modifier auras are applied only to own spells and only players have such mods
Player modOwner = m_caster.GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.GlobalCooldown, ref gcd, this);
modOwner.ApplySpellMod(m_spellInfo, SpellModOp.GlobalCooldown, ref gcd, this);
bool isMeleeOrRangedSpell = m_spellInfo.DmgClass == SpellDmgClass.Melee || m_spellInfo.DmgClass == SpellDmgClass.Ranged ||
m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellAttr0.Ability);
+2 -2
View File
@@ -361,10 +361,10 @@ namespace Game.Spells
if (modOwner)
{
if (cooldown >= 0)
modOwner.ApplySpellMod(spellInfo.Id, SpellModOp.Cooldown, ref cooldown, spell);
modOwner.ApplySpellMod(spellInfo, SpellModOp.Cooldown, ref cooldown, spell);
if (categoryCooldown >= 0 && !spellInfo.HasAttribute(SpellAttr6.IgnoreCategoryCooldownMods))
modOwner.ApplySpellMod(spellInfo.Id, SpellModOp.Cooldown, ref categoryCooldown, spell);
modOwner.ApplySpellMod(spellInfo, SpellModOp.Cooldown, ref categoryCooldown, spell);
}
if (_owner.HasAuraTypeWithAffectMask(AuraType.ModSpellCooldownByHaste, spellInfo))
+8 -8
View File
@@ -2583,7 +2583,7 @@ namespace Game.Spells
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(Id, SpellModOp.Range, ref range, spell);
modOwner.ApplySpellMod(this, SpellModOp.Range, ref range, spell);
}
return range;
}
@@ -2596,7 +2596,7 @@ namespace Game.Spells
{
Player modOwner = caster.GetSpellModOwner();
if (modOwner)
modOwner.ApplySpellMod(Id, SpellModOp.Duration, ref duration);
modOwner.ApplySpellMod(this, SpellModOp.Duration, ref duration);
}
return duration;
@@ -2803,13 +2803,13 @@ namespace Game.Spells
switch (power.OrderIndex)
{
case 0:
modOwner.ApplySpellMod(Id, SpellModOp.Cost, ref powerCost, spell);
modOwner.ApplySpellMod(this, SpellModOp.Cost, ref powerCost, spell);
break;
case 1:
modOwner.ApplySpellMod(Id, SpellModOp.SpellCost2, ref powerCost, spell);
modOwner.ApplySpellMod(this, SpellModOp.SpellCost2, ref powerCost, spell);
break;
case 2:
modOwner.ApplySpellMod(Id, SpellModOp.SpellCost3, ref powerCost, spell);
modOwner.ApplySpellMod(this, SpellModOp.SpellCost3, ref powerCost, spell);
break;
default:
break;
@@ -3917,7 +3917,7 @@ namespace Game.Spells
float multiplier = Amplitude;
Player modOwner = (caster != null ? caster.GetSpellModOwner() : null);
if (modOwner != null)
modOwner.ApplySpellMod(_spellInfo.Id, SpellModOp.ValueMultiplier, ref multiplier, spell);
modOwner.ApplySpellMod(_spellInfo, SpellModOp.ValueMultiplier, ref multiplier, spell);
return multiplier;
}
@@ -3926,7 +3926,7 @@ namespace Game.Spells
float multiplierPercent = ChainAmplitude * 100.0f;
Player modOwner = (caster != null ? caster.GetSpellModOwner() : null);
if (modOwner != null)
modOwner.ApplySpellMod(_spellInfo.Id, SpellModOp.DamageMultiplier, ref multiplierPercent, spell);
modOwner.ApplySpellMod(_spellInfo, SpellModOp.DamageMultiplier, ref multiplierPercent, spell);
return multiplierPercent / 100.0f;
}
@@ -3961,7 +3961,7 @@ namespace Game.Spells
radius = Math.Min(radius, entry.RadiusMax);
Player modOwner = caster.GetSpellModOwner();
if (modOwner != null)
modOwner.ApplySpellMod(_spellInfo.Id, SpellModOp.Radius, ref radius, spell);
modOwner.ApplySpellMod(_spellInfo, SpellModOp.Radius, ref radius, spell);
}
return radius;