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
+1 -1
View File
@@ -352,7 +352,7 @@ namespace Game.Combat
Player modOwner = hatedUnit.GetSpellModOwner(); Player modOwner = hatedUnit.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(threatSpell.Id, SpellModOp.Threat, ref threat); modOwner.ApplySpellMod(threatSpell, SpellModOp.Threat, ref threat);
} }
return hatedUnit.ApplyTotalThreatModifier(threat, schoolMask); return hatedUnit.ApplyTotalThreatModifier(threat, schoolMask);
+5 -17
View File
@@ -2682,12 +2682,8 @@ namespace Game.Entities
} }
} }
public void ApplySpellMod(uint spellId, SpellModOp op, ref int basevalue, Spell spell = null) public void ApplySpellMod(SpellInfo spellInfo, SpellModOp op, ref int basevalue, Spell spell = null)
{ {
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
if (spellInfo == null)
return;
float totalmul = 1.0f; float totalmul = 1.0f;
int totalflat = 0; int totalflat = 0;
@@ -2781,12 +2777,8 @@ namespace Game.Entities
basevalue = (int)((float)(basevalue + totalflat) * totalmul); basevalue = (int)((float)(basevalue + totalflat) * totalmul);
} }
public void ApplySpellMod(uint spellId, SpellModOp op, ref uint basevalue, Spell spell = null) public void ApplySpellMod(SpellInfo spellInfo, SpellModOp op, ref uint basevalue, Spell spell = null)
{ {
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
if (spellInfo == null)
return;
float totalmul = 1.0f; float totalmul = 1.0f;
int totalflat = 0; int totalflat = 0;
@@ -2880,12 +2872,8 @@ namespace Game.Entities
basevalue = (uint)((float)(basevalue + totalflat) * totalmul); basevalue = (uint)((float)(basevalue + totalflat) * totalmul);
} }
public void ApplySpellMod(uint spellId, SpellModOp op, ref float basevalue, Spell spell = null) public void ApplySpellMod(SpellInfo spellInfo, SpellModOp op, ref float basevalue, Spell spell = null)
{ {
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellId, GetMap().GetDifficultyID());
if (spellInfo == null)
return;
float totalmul = 1.0f; float totalmul = 1.0f;
int totalflat = 0; int totalflat = 0;
@@ -2978,7 +2966,7 @@ namespace Game.Entities
basevalue = (basevalue + totalflat) * totalmul; basevalue = (basevalue + totalflat) * totalmul;
} }
bool IsAffectedBySpellmod(SpellInfo spellInfo, SpellModifier mod, Spell spell) bool IsAffectedBySpellmod(SpellInfo spellInfo, SpellModifier mod, Spell spell)
{ {
if (mod == null || spellInfo == null) if (mod == null || spellInfo == null)
@@ -3382,7 +3370,7 @@ namespace Game.Entities
} }
// Apply spell mods // Apply spell mods
ApplySpellMod(pEnchant.EffectArg[s], SpellModOp.ChanceOfSuccess, ref chance); ApplySpellMod(spellInfo, SpellModOp.ChanceOfSuccess, ref chance);
// Shiv has 100% chance to apply the poison // Shiv has 100% chance to apply the poison
if (FindCurrentSpellBySpellId(5938) != null && e_slot == (byte)EnchantmentSlot.Temp) if (FindCurrentSpellBySpellId(5938) != null && e_slot == (byte)EnchantmentSlot.Temp)
+4 -4
View File
@@ -717,22 +717,22 @@ namespace Game.Entities
public void SetRangedWeaponAttackPower(int attackPower) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.RangedWeaponAttackPower), attackPower); } public void SetRangedWeaponAttackPower(int attackPower) { SetUpdateFieldValue(m_values.ModifyValue(m_unitData).ModifyValue(m_unitData.RangedWeaponAttackPower), attackPower); }
//Chances //Chances
float MeleeSpellMissChance(Unit victim, WeaponAttackType attType, uint spellId) float MeleeSpellMissChance(Unit victim, WeaponAttackType attType, SpellInfo spellInfo)
{ {
//calculate miss chance //calculate miss chance
float missChance = victim.GetUnitMissChance(attType); float missChance = victim.GetUnitMissChance(attType);
// melee attacks while dual wielding have +19% chance to miss // melee attacks while dual wielding have +19% chance to miss
if (spellId == 0 && HaveOffhandWeapon() && !IsInFeralForm()) if (spellInfo == null && HaveOffhandWeapon() && !IsInFeralForm())
missChance += 19.0f; missChance += 19.0f;
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE // Spellmod from SPELLMOD_RESIST_MISS_CHANCE
float resistMissChance = 100.0f; float resistMissChance = 100.0f;
if (spellId != 0) if (spellInfo != null)
{ {
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellId, SpellModOp.ResistMissChance, ref resistMissChance); modOwner.ApplySpellMod(spellInfo, SpellModOp.ResistMissChance, ref resistMissChance);
} }
missChance += resistMissChance - 100.0f; missChance += resistMissChance - 100.0f;
+4 -4
View File
@@ -1772,7 +1772,7 @@ namespace Game.Entities
{ {
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.ProcPerMinute, ref PPM); modOwner.ApplySpellMod(spellProto, SpellModOp.ProcPerMinute, ref PPM);
} }
return (float)Math.Floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) return (float)Math.Floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60))
@@ -2049,7 +2049,7 @@ namespace Game.Entities
return MeleeHitOutcome.Evade; return MeleeHitOutcome.Evade;
// Miss chance based on melee // Miss chance based on melee
int miss_chance = (int)(MeleeSpellMissChance(victim, attType, 0) * 100.0f); int miss_chance = (int)(MeleeSpellMissChance(victim, attType, null) * 100.0f);
// Critical hit chance // Critical hit chance
int crit_chance = (int)(GetUnitCriticalChance(attType, victim) + GetTotalAuraModifier(AuraType.ModAutoAttackCritChance) * 100.0f); int crit_chance = (int)(GetUnitCriticalChance(attType, victim) + GetTotalAuraModifier(AuraType.ModAutoAttackCritChance) * 100.0f);
@@ -2737,7 +2737,7 @@ namespace Game.Entities
{ {
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellInfo.Id, SpellModOp.IgnoreArmor, ref armor); modOwner.ApplySpellMod(spellInfo, SpellModOp.IgnoreArmor, ref armor);
} }
var resIgnoreAuras = GetAuraEffectsByType(AuraType.ModIgnoreTargetResist); var resIgnoreAuras = GetAuraEffectsByType(AuraType.ModIgnoreTargetResist);
@@ -2874,7 +2874,7 @@ namespace Game.Entities
{ {
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Damage, ref tmpDamage); modOwner.ApplySpellMod(spellProto, SpellModOp.Damage, ref tmpDamage);
} }
// bonus result can be negative // bonus result can be negative
+22 -22
View File
@@ -121,7 +121,7 @@ namespace Game.Entities
if (modOwner) if (modOwner)
{ {
ApCoeffMod *= 100.0f; ApCoeffMod *= 100.0f;
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.BonusMultiplier, ref ApCoeffMod); modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref ApCoeffMod);
ApCoeffMod /= 100.0f; ApCoeffMod /= 100.0f;
} }
@@ -145,7 +145,7 @@ namespace Game.Entities
if (modOwner) if (modOwner)
{ {
coeff *= 100.0f; coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.BonusMultiplier, ref coeff); modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
coeff /= 100.0f; coeff /= 100.0f;
} }
DoneTotal += (int)(DoneAdvertisedBenefit * coeff * stack); DoneTotal += (int)(DoneAdvertisedBenefit * coeff * stack);
@@ -158,9 +158,9 @@ namespace Game.Entities
if (_modOwner) if (_modOwner)
{ {
if (damagetype == DamageEffectType.DOT) if (damagetype == DamageEffectType.DOT)
_modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Dot, ref tmpDamage); _modOwner.ApplySpellMod(spellProto, SpellModOp.Dot, ref tmpDamage);
else else
_modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Damage, ref tmpDamage); _modOwner.ApplySpellMod(spellProto, SpellModOp.Damage, ref tmpDamage);
} }
return (uint)Math.Max(tmpDamage, 0.0f); return (uint)Math.Max(tmpDamage, 0.0f);
@@ -321,7 +321,7 @@ namespace Game.Entities
if (modOwner) if (modOwner)
{ {
coeff *= 100.0f; coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.BonusMultiplier, ref coeff); modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
coeff /= 100.0f; coeff /= 100.0f;
} }
TakenTotal += (int)(TakenAdvertisedBenefit * coeff * stack); TakenTotal += (int)(TakenAdvertisedBenefit * coeff * stack);
@@ -462,7 +462,7 @@ namespace Game.Entities
if (modOwner) if (modOwner)
{ {
coeff *= 100.0f; coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.BonusMultiplier, ref coeff); modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
coeff /= 100.0f; coeff /= 100.0f;
} }
@@ -493,9 +493,9 @@ namespace Game.Entities
if (_modOwner) if (_modOwner)
{ {
if (damagetype == DamageEffectType.DOT) if (damagetype == DamageEffectType.DOT)
_modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Dot, ref heal); _modOwner.ApplySpellMod(spellProto, SpellModOp.Dot, ref heal);
else else
_modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Damage, ref heal); _modOwner.ApplySpellMod(spellProto, SpellModOp.Damage, ref heal);
} }
return (uint)Math.Max(heal, 0.0f); return (uint)Math.Max(heal, 0.0f);
@@ -594,7 +594,7 @@ namespace Game.Entities
if (modOwner) if (modOwner)
{ {
coeff *= 100.0f; coeff *= 100.0f;
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.BonusMultiplier, ref coeff); modOwner.ApplySpellMod(spellProto, SpellModOp.BonusMultiplier, ref coeff);
coeff /= 100.0f; coeff /= 100.0f;
} }
@@ -758,7 +758,7 @@ namespace Game.Entities
// only players use intelligence for critical chance computations // only players use intelligence for critical chance computations
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.CriticalChance, ref crit_chance); modOwner.ApplySpellMod(spellProto, SpellModOp.CriticalChance, ref crit_chance);
// for this types the bonus was already added in GetUnitCriticalChance, do not add twice // for this types the bonus was already added in GetUnitCriticalChance, do not add twice
if (spellProto.DmgClass != SpellDmgClass.Melee && spellProto.DmgClass != SpellDmgClass.Ranged) if (spellProto.DmgClass != SpellDmgClass.Melee && spellProto.DmgClass != SpellDmgClass.Ranged)
@@ -847,7 +847,7 @@ namespace Game.Entities
int roll = RandomHelper.IRand(0, 9999); int roll = RandomHelper.IRand(0, 9999);
int missChance = (int)(MeleeSpellMissChance(victim, attType, spellInfo.Id) * 100.0f); int missChance = (int)(MeleeSpellMissChance(victim, attType, spellInfo) * 100.0f);
// Roll miss // Roll miss
int tmp = missChance; int tmp = missChance;
if (roll < tmp) if (roll < tmp)
@@ -1010,7 +1010,7 @@ namespace Game.Entities
// Spellmod from SPELLMOD_RESIST_MISS_CHANCE // Spellmod from SPELLMOD_RESIST_MISS_CHANCE
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spell.Id, SpellModOp.ResistMissChance, ref modHitChance); modOwner.ApplySpellMod(spell, SpellModOp.ResistMissChance, ref modHitChance);
// Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects
if (!spell.HasAttribute(SpellAttr3.IgnoreHitResult)) if (!spell.HasAttribute(SpellAttr3.IgnoreHitResult))
@@ -2002,7 +2002,7 @@ namespace Game.Entities
// called from caster // called from caster
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellInfo.Id, SpellModOp.CastingTime, ref castTime, spell); modOwner.ApplySpellMod(spellInfo, SpellModOp.CastingTime, ref castTime, spell);
if (!(spellInfo.HasAttribute(SpellAttr0.Ability | SpellAttr0.Tradespell) || spellInfo.HasAttribute(SpellAttr3.NoDoneBonus)) if (!(spellInfo.HasAttribute(SpellAttr0.Ability | SpellAttr0.Tradespell) || spellInfo.HasAttribute(SpellAttr3.NoDoneBonus))
&& (IsTypeId(TypeId.Player) && spellInfo.SpellFamilyName != 0) || IsTypeId(TypeId.Unit)) && (IsTypeId(TypeId.Player) && spellInfo.SpellFamilyName != 0) || IsTypeId(TypeId.Unit))
@@ -2023,7 +2023,7 @@ namespace Game.Entities
// called from caster // called from caster
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner) if (modOwner)
modOwner.ApplySpellMod(spellInfo.Id, SpellModOp.CastingTime, ref duration, spell); modOwner.ApplySpellMod(spellInfo, SpellModOp.CastingTime, ref duration, spell);
if (!(spellInfo.HasAttribute(SpellAttr0.Ability) || spellInfo.HasAttribute(SpellAttr0.Tradespell) || spellInfo.HasAttribute(SpellAttr3.NoDoneBonus)) && if (!(spellInfo.HasAttribute(SpellAttr0.Ability) || spellInfo.HasAttribute(SpellAttr0.Tradespell) || spellInfo.HasAttribute(SpellAttr3.NoDoneBonus)) &&
(IsTypeId(TypeId.Player) && spellInfo.SpellFamilyName != 0) || IsTypeId(TypeId.Unit)) (IsTypeId(TypeId.Player) && spellInfo.SpellFamilyName != 0) || IsTypeId(TypeId.Unit))
@@ -2036,23 +2036,23 @@ namespace Game.Entities
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
{ {
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.AllEffects, ref value); modOwner.ApplySpellMod(spellProto, SpellModOp.AllEffects, ref value);
switch (effect_index) switch (effect_index)
{ {
case 0: case 0:
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Effect1, ref value); modOwner.ApplySpellMod(spellProto, SpellModOp.Effect1, ref value);
break; break;
case 1: case 1:
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Effect2, ref value); modOwner.ApplySpellMod(spellProto, SpellModOp.Effect2, ref value);
break; break;
case 2: case 2:
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Effect3, ref value); modOwner.ApplySpellMod(spellProto, SpellModOp.Effect3, ref value);
break; break;
case 3: case 3:
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Effect4, ref value); modOwner.ApplySpellMod(spellProto, SpellModOp.Effect4, ref value);
break; break;
case 4: case 4:
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.Effect5, ref value); modOwner.ApplySpellMod(spellProto, SpellModOp.Effect5, ref value);
break; break;
} }
} }
@@ -2211,7 +2211,7 @@ namespace Game.Entities
// adds additional damage to critBonus (from talents) // adds additional damage to critBonus (from talents)
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellProto.Id, SpellModOp.CritDamageBonus, ref crit_bonus); modOwner.ApplySpellMod(spellProto, SpellModOp.CritDamageBonus, ref crit_bonus);
crit_bonus += (int)damage; crit_bonus += (int)damage;
@@ -2425,7 +2425,7 @@ namespace Game.Entities
// Apply crit_damage bonus for melee spells // Apply crit_damage bonus for melee spells
Player modOwner = GetSpellModOwner(); Player modOwner = GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(spellInfo.Id, SpellModOp.CritDamageBonus, ref crit_bonus); modOwner.ApplySpellMod(spellInfo, SpellModOp.CritDamageBonus, ref crit_bonus);
damage += (int)crit_bonus; damage += (int)crit_bonus;
// Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS
+6 -6
View File
@@ -703,7 +703,7 @@ namespace Game.Spells
// IsPermanent() checks max duration (which we are supposed to calculate here) // IsPermanent() checks max duration (which we are supposed to calculate here)
if (maxDuration != -1 && modOwner != null) if (maxDuration != -1 && modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.Duration, ref maxDuration); modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.Duration, ref maxDuration);
return maxDuration; return maxDuration;
} }
@@ -716,7 +716,7 @@ namespace Game.Spells
{ {
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner) 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(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.MaxStackAmount, ref maxStackAmount); modOwner.ApplySpellMod(m_spellInfo, SpellModOp.MaxStackAmount, ref maxStackAmount);
} }
return maxStackAmount; return maxStackAmount;
} }
@@ -1054,7 +1054,7 @@ namespace Game.Spells
{ {
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.ResistDispelChance, ref resistChance); modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.ResistDispelChance, ref resistChance);
} }
resistChance = resistChance < 0 ? 0 : 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) // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell)
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) 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 // proc chance is reduced by an additional 3.333% per level past 60
@@ -2350,7 +2350,7 @@ namespace Game.Spells
{ {
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.Charges, ref maxProcCharges); modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.Charges, ref maxProcCharges);
} }
return (byte)maxProcCharges; return (byte)maxProcCharges;
} }
+1 -1
View File
@@ -168,7 +168,7 @@ namespace Game.Spells
{ {
// Apply periodic time mod // Apply periodic time mod
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(GetId(), SpellModOp.ActivationTime, ref m_period); modOwner.ApplySpellMod(GetSpellInfo(), SpellModOp.ActivationTime, ref m_period);
if (caster != null) if (caster != null)
{ {
+10 -10
View File
@@ -68,7 +68,7 @@ namespace Game.Spells
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) 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()) if (!originalCasterGUID.IsEmpty())
m_originalCasterGUID = originalCasterGUID; m_originalCasterGUID = originalCasterGUID;
@@ -1089,7 +1089,7 @@ namespace Game.Spells
int maxTargets = effect.ChainTargets; int maxTargets = effect.ChainTargets;
Player modOwner = m_caster.GetSpellModOwner(); Player modOwner = m_caster.GetSpellModOwner();
if (modOwner) if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.JumpTargets, ref maxTargets, this); modOwner.ApplySpellMod(m_spellInfo, SpellModOp.JumpTargets, ref maxTargets, this);
if (maxTargets > 1) if (maxTargets > 1)
{ {
@@ -1411,7 +1411,7 @@ namespace Game.Spells
Player modOwner = m_caster.GetSpellModOwner(); Player modOwner = m_caster.GetSpellModOwner();
if (modOwner) 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 // chain lightning/heal spells and similar - allow to jump at larger distance and go out of los
bool isBouncingFar = (m_spellInfo.HasAttribute(SpellAttr4.AreaTargetChain) bool isBouncingFar = (m_spellInfo.HasAttribute(SpellAttr4.AreaTargetChain)
@@ -2367,7 +2367,7 @@ namespace Game.Spells
range = m_spellInfo.GetMaxRange(m_spellInfo.IsPositive()); range = m_spellInfo.GetMaxRange(m_spellInfo.IsPositive());
Player modOwner = m_caster.GetSpellModOwner(); Player modOwner = m_caster.GetSpellModOwner();
if (modOwner != null) 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 // add little tolerance level
range += Math.Min(3.0f, range * 0.1f); // 10% but no more than 3.0f 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 // Apply duration mod
Player modOwner = m_caster.GetSpellModOwner(); Player modOwner = m_caster.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.Duration, ref duration); modOwner.ApplySpellMod(m_spellInfo, SpellModOp.Duration, ref duration);
// Apply haste mods // Apply haste mods
m_caster.ModSpellDurationTime(m_spellInfo, ref duration, this); m_caster.ModSpellDurationTime(m_spellInfo, ref duration, this);
@@ -4213,7 +4213,7 @@ namespace Game.Spells
//lower spell cost on fail (by talent aura) //lower spell cost on fail (by talent aura)
Player modOwner = m_caster.ToPlayer().GetSpellModOwner(); Player modOwner = m_caster.ToPlayer().GetSpellModOwner();
if (modOwner) if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.SpellCostRefundOnFail, ref cost.Amount); modOwner.ApplySpellMod(m_spellInfo, SpellModOp.SpellCostRefundOnFail, ref cost.Amount);
} }
break; break;
} }
@@ -5862,7 +5862,7 @@ namespace Game.Spells
Player modOwner = m_caster.GetSpellModOwner(); Player modOwner = m_caster.GetSpellModOwner();
if (modOwner) if (modOwner)
modOwner.ApplySpellMod(m_spellInfo.Id, SpellModOp.Range, ref maxRange, this); modOwner.ApplySpellMod(m_spellInfo, SpellModOp.Range, ref maxRange, this);
maxRange += rangeMod; maxRange += rangeMod;
@@ -6437,7 +6437,7 @@ namespace Game.Spells
//check pushback reduce //check pushback reduce
int delaytime = 500; // spellcasting delay is normally 500ms int delaytime = 500; // spellcasting delay is normally 500ms
int delayReduce = 100; // must be initialized to 100 for percent modifiers 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; delayReduce += m_caster.GetTotalAuraModifier(AuraType.ReducePushback) - 100;
if (delayReduce >= 100) if (delayReduce >= 100)
return; return;
@@ -6472,7 +6472,7 @@ namespace Game.Spells
//check pushback reduce //check pushback reduce
int delaytime = MathFunctions.CalculatePct(m_spellInfo.GetDuration(), 25); // channeling delay is normally 25% of its time per hit 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 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; delayReduce += m_caster.GetTotalAuraModifier(AuraType.ReducePushback) - 100;
if (delayReduce >= 100) if (delayReduce >= 100)
return; return;
@@ -7229,7 +7229,7 @@ namespace Game.Spells
// gcd modifier auras are applied only to own spells and only players have such mods // gcd modifier auras are applied only to own spells and only players have such mods
Player modOwner = m_caster.GetSpellModOwner(); Player modOwner = m_caster.GetSpellModOwner();
if (modOwner) 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 || bool isMeleeOrRangedSpell = m_spellInfo.DmgClass == SpellDmgClass.Melee || m_spellInfo.DmgClass == SpellDmgClass.Ranged ||
m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellAttr0.Ability); m_spellInfo.HasAttribute(SpellAttr0.ReqAmmo) || m_spellInfo.HasAttribute(SpellAttr0.Ability);
+2 -2
View File
@@ -361,10 +361,10 @@ namespace Game.Spells
if (modOwner) if (modOwner)
{ {
if (cooldown >= 0) 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)) 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)) if (_owner.HasAuraTypeWithAffectMask(AuraType.ModSpellCooldownByHaste, spellInfo))
+8 -8
View File
@@ -2583,7 +2583,7 @@ namespace Game.Spells
{ {
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(Id, SpellModOp.Range, ref range, spell); modOwner.ApplySpellMod(this, SpellModOp.Range, ref range, spell);
} }
return range; return range;
} }
@@ -2596,7 +2596,7 @@ namespace Game.Spells
{ {
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner) if (modOwner)
modOwner.ApplySpellMod(Id, SpellModOp.Duration, ref duration); modOwner.ApplySpellMod(this, SpellModOp.Duration, ref duration);
} }
return duration; return duration;
@@ -2803,13 +2803,13 @@ namespace Game.Spells
switch (power.OrderIndex) switch (power.OrderIndex)
{ {
case 0: case 0:
modOwner.ApplySpellMod(Id, SpellModOp.Cost, ref powerCost, spell); modOwner.ApplySpellMod(this, SpellModOp.Cost, ref powerCost, spell);
break; break;
case 1: case 1:
modOwner.ApplySpellMod(Id, SpellModOp.SpellCost2, ref powerCost, spell); modOwner.ApplySpellMod(this, SpellModOp.SpellCost2, ref powerCost, spell);
break; break;
case 2: case 2:
modOwner.ApplySpellMod(Id, SpellModOp.SpellCost3, ref powerCost, spell); modOwner.ApplySpellMod(this, SpellModOp.SpellCost3, ref powerCost, spell);
break; break;
default: default:
break; break;
@@ -3917,7 +3917,7 @@ namespace Game.Spells
float multiplier = Amplitude; float multiplier = Amplitude;
Player modOwner = (caster != null ? caster.GetSpellModOwner() : null); Player modOwner = (caster != null ? caster.GetSpellModOwner() : null);
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(_spellInfo.Id, SpellModOp.ValueMultiplier, ref multiplier, spell); modOwner.ApplySpellMod(_spellInfo, SpellModOp.ValueMultiplier, ref multiplier, spell);
return multiplier; return multiplier;
} }
@@ -3926,7 +3926,7 @@ namespace Game.Spells
float multiplierPercent = ChainAmplitude * 100.0f; float multiplierPercent = ChainAmplitude * 100.0f;
Player modOwner = (caster != null ? caster.GetSpellModOwner() : null); Player modOwner = (caster != null ? caster.GetSpellModOwner() : null);
if (modOwner != 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; return multiplierPercent / 100.0f;
} }
@@ -3961,7 +3961,7 @@ namespace Game.Spells
radius = Math.Min(radius, entry.RadiusMax); radius = Math.Min(radius, entry.RadiusMax);
Player modOwner = caster.GetSpellModOwner(); Player modOwner = caster.GetSpellModOwner();
if (modOwner != null) if (modOwner != null)
modOwner.ApplySpellMod(_spellInfo.Id, SpellModOp.Radius, ref radius, spell); modOwner.ApplySpellMod(_spellInfo, SpellModOp.Radius, ref radius, spell);
} }
return radius; return radius;
+2 -2
View File
@@ -105,14 +105,14 @@ namespace Scripts.World.DuelReset
uint totalCooldown = spellInfo.RecoveryTime; uint totalCooldown = spellInfo.RecoveryTime;
uint categoryCooldown = spellInfo.CategoryRecoveryTime; uint categoryCooldown = spellInfo.CategoryRecoveryTime;
player.ApplySpellMod(spellInfo.Id, SpellModOp.Cooldown, ref totalCooldown, null); player.ApplySpellMod(spellInfo, SpellModOp.Cooldown, ref totalCooldown, null);
int cooldownMod = player.GetTotalAuraModifier(AuraType.ModCooldown); int cooldownMod = player.GetTotalAuraModifier(AuraType.ModCooldown);
if (cooldownMod != 0) if (cooldownMod != 0)
totalCooldown += (uint)(cooldownMod * Time.InMilliseconds); totalCooldown += (uint)(cooldownMod * Time.InMilliseconds);
if (!spellInfo.HasAttribute(SpellAttr6.IgnoreCategoryCooldownMods)) if (!spellInfo.HasAttribute(SpellAttr6.IgnoreCategoryCooldownMods))
player.ApplySpellMod(spellInfo.Id, SpellModOp.Cooldown, ref categoryCooldown, null); player.ApplySpellMod(spellInfo, SpellModOp.Cooldown, ref categoryCooldown, null);
return remainingCooldown > 0 return remainingCooldown > 0
&& !pair.Value.OnHold && !pair.Value.OnHold