diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-03-02 21:32:48 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-03-02 21:32:48 +0100 |
commit | 624881bef5c90a91e4c59e5bf404d8775c2ca55d (patch) | |
tree | 168fae708e082ffceb296747ef1b282e73bc4d35 | |
parent | 49532eda5f247c4c3c2c1f899ee63c0a8d01e76e (diff) |
Core/Spells: Refactor Player::ApplySpellMod to take SpellInfo argument instead of just spell id
-rw-r--r-- | src/server/game/Combat/ThreatManager.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.cpp | 14 | ||||
-rw-r--r-- | src/server/game/Entities/Player/Player.h | 2 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.cpp | 60 | ||||
-rw-r--r-- | src/server/game/Entities/Unit/Unit.h | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuraEffects.cpp | 2 | ||||
-rw-r--r-- | src/server/game/Spells/Auras/SpellAuras.cpp | 12 | ||||
-rw-r--r-- | src/server/game/Spells/Spell.cpp | 20 | ||||
-rw-r--r-- | src/server/game/Spells/SpellHistory.cpp | 4 | ||||
-rw-r--r-- | src/server/game/Spells/SpellInfo.cpp | 16 | ||||
-rw-r--r-- | src/server/scripts/Spells/spell_warlock.cpp | 2 | ||||
-rw-r--r-- | src/server/scripts/World/duel_reset.cpp | 4 |
12 files changed, 68 insertions, 72 deletions
diff --git a/src/server/game/Combat/ThreatManager.cpp b/src/server/game/Combat/ThreatManager.cpp index 652c5cffb5c..320b1f62e63 100644 --- a/src/server/game/Combat/ThreatManager.cpp +++ b/src/server/game/Combat/ThreatManager.cpp @@ -45,7 +45,7 @@ float ThreatCalcHelper::calcThreat(Unit* hatedUnit, Unit* /*hatingUnit*/, float return threat; if (Player* modOwner = hatedUnit->GetSpellModOwner()) - modOwner->ApplySpellMod(threatSpell->Id, SPELLMOD_THREAT, threat); + modOwner->ApplySpellMod(threatSpell, SPELLMOD_THREAT, threat); } return hatedUnit->ApplyTotalThreatModifier(threat, schoolMask); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index cf5250f4def..599c69d0ec3 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -8341,7 +8341,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT } // Apply spell mods - ApplySpellMod(pEnchant->EffectArg[s], SPELLMOD_CHANCE_OF_SUCCESS, chance); + ApplySpellMod(spellInfo, SPELLMOD_CHANCE_OF_SUCCESS, chance); // Shiv has 100% chance to apply the poison if (FindCurrentSpellBySpellId(5938) && e_slot == TEMP_ENCHANTMENT_SLOT) @@ -22524,12 +22524,8 @@ template TC_GAME_API void Player::GetSpellModValues(SpellInfo const* spellInfo, template TC_GAME_API void Player::GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, float base, int32* flat, float* pct) const; template <class T> -void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* spell /*= nullptr*/) const +void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, T& basevalue, Spell* spell /*= nullptr*/) const { - SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellId, GetMap()->GetDifficultyID()); - if (!spellInfo) - return; - float totalmul = 1.0f; int32 totalflat = 0; @@ -22538,9 +22534,9 @@ void Player::ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* s basevalue = T(float(basevalue + totalflat) * totalmul); } -template TC_GAME_API void Player::ApplySpellMod(uint32 spellId, SpellModOp op, int32& basevalue, Spell* spell) const; -template TC_GAME_API void Player::ApplySpellMod(uint32 spellId, SpellModOp op, uint32& basevalue, Spell* spell) const; -template TC_GAME_API void Player::ApplySpellMod(uint32 spellId, SpellModOp op, float& basevalue, Spell* spell) const; +template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, int32& basevalue, Spell* spell) const; +template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, uint32& basevalue, Spell* spell) const; +template TC_GAME_API void Player::ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, float& basevalue, Spell* spell) const; void Player::AddSpellMod(SpellModifier* mod, bool apply) { diff --git a/src/server/game/Entities/Player/Player.h b/src/server/game/Entities/Player/Player.h index 8c1d1ff833c..c50a103ef65 100644 --- a/src/server/game/Entities/Player/Player.h +++ b/src/server/game/Entities/Player/Player.h @@ -1683,7 +1683,7 @@ class TC_GAME_API Player : public Unit, public GridObject<Player> template <class T> void GetSpellModValues(SpellInfo const* spellInfo, SpellModOp op, Spell* spell, T base, int32* flat, float* pct) const; template <class T> - void ApplySpellMod(uint32 spellId, SpellModOp op, T& basevalue, Spell* spell = nullptr) const; + void ApplySpellMod(SpellInfo const* spellInfo, SpellModOp op, T& basevalue, Spell* spell = nullptr) const; static void ApplyModToSpell(SpellModifier* mod, Spell* spell); void SetSpellModTakingSpell(Spell* spell, bool apply); void SendSpellModifiers() const; diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 09dae9598e4..051708144ca 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1138,7 +1138,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage* damageInfo, int32 dama uint32 crit_bonus = damage; // Apply crit_damage bonus for melee spells if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); damage += crit_bonus; // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS @@ -1609,7 +1609,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit* attacker, Unit* victim, const uint32 d if (spellInfo) if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_IGNORE_ARMOR, armor); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_IGNORE_ARMOR, armor); AuraEffectList const& resIgnoreAuras = GetAuraEffectsByType(SPELL_AURA_MOD_IGNORE_TARGET_RESIST); for (AuraEffectList::const_iterator j = resIgnoreAuras.begin(); j != resIgnoreAuras.end(); ++j) @@ -2140,7 +2140,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy return MELEE_HIT_EVADE; // Miss chance based on melee - int32 miss_chance = int32(MeleeSpellMissChance(victim, attType, 0) * 100.0f); + int32 miss_chance = int32(MeleeSpellMissChance(victim, attType, nullptr) * 100.0f); // Critical hit chance int32 crit_chance = int32(GetUnitCriticalChance(attType, victim) + GetTotalAuraModifier(SPELL_AURA_MOD_AUTOATTACK_CRIT_CHANCE) * 100.0f); @@ -2396,7 +2396,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo uint32 roll = urand(0, 9999); - uint32 missChance = uint32(MeleeSpellMissChance(victim, attType, spellInfo->Id) * 100.0f); + uint32 missChance = uint32(MeleeSpellMissChance(victim, attType, spellInfo) * 100.0f); // Roll miss uint32 tmp = missChance; @@ -2559,7 +2559,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo // Spellmod from SPELLMOD_RESIST_MISS_CHANCE if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_RESIST_MISS_CHANCE, modHitChance); // Spells with SPELL_ATTR3_IGNORE_HIT_RESULT will ignore target's avoidance effects if (!spellInfo->HasAttribute(SPELL_ATTR3_IGNORE_HIT_RESULT)) @@ -6694,7 +6694,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (Player* modOwner = GetSpellModOwner()) { ApCoeffMod *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, ApCoeffMod); + modOwner->ApplySpellMod(spellProto, SPELLMOD_BONUS_MULTIPLIER, ApCoeffMod); ApCoeffMod /= 100.0f; } @@ -6720,7 +6720,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); + modOwner->ApplySpellMod(spellProto, SPELLMOD_BONUS_MULTIPLIER, coeff); coeff /= 100.0f; } DoneTotal += int32(DoneAdvertisedBenefit * coeff * stack); @@ -6732,9 +6732,9 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellInfo const* spellProto, uin if (Player* modOwner = GetSpellModOwner()) { if (damagetype == DOT) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DOT, tmpDamage); + modOwner->ApplySpellMod(spellProto, SPELLMOD_DOT, tmpDamage); else - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage); + modOwner->ApplySpellMod(spellProto, SPELLMOD_DAMAGE, tmpDamage); } return uint32(std::max(tmpDamage, 0.0f)); @@ -6889,7 +6889,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellInfo const* spellProto, ui if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); + modOwner->ApplySpellMod(spellProto, SPELLMOD_BONUS_MULTIPLIER, coeff); coeff /= 100.0f; } TakenTotal += int32(TakenAdvertisedBenefit * coeff * stack); @@ -7073,7 +7073,7 @@ float Unit::GetUnitSpellCriticalChance(Unit* victim, SpellInfo const* spellProto // percent done // only players use intelligence for critical chance computations if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRITICAL_CHANCE, crit_chance); + modOwner->ApplySpellMod(spellProto, SPELLMOD_CRITICAL_CHANCE, crit_chance); // for this types the bonus was already added in GetUnitCriticalChance, do not add twice if (spellProto->DmgClass != SPELL_DAMAGE_CLASS_MELEE && spellProto->DmgClass != SPELL_DAMAGE_CLASS_RANGED) @@ -7122,7 +7122,7 @@ uint32 Unit::SpellCriticalDamageBonus(SpellInfo const* spellProto, uint32 damage // adds additional damage to critBonus (from talents) if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); + modOwner->ApplySpellMod(spellProto, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus); crit_bonus += damage; @@ -7194,7 +7194,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); + modOwner->ApplySpellMod(spellProto, SPELLMOD_BONUS_MULTIPLIER, coeff); coeff /= 100.0f; } @@ -7223,9 +7223,9 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellInfo const* spellProto, ui if (Player* modOwner = GetSpellModOwner()) { if (damagetype == DOT) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DOT, heal); + modOwner->ApplySpellMod(spellProto, SPELLMOD_DOT, heal); else - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, heal); + modOwner->ApplySpellMod(spellProto, SPELLMOD_DAMAGE, heal); } return uint32(std::max(heal, 0.0f)); @@ -7323,7 +7323,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellInfo const* spellProto, u if (Player* modOwner = GetSpellModOwner()) { coeff *= 100.0f; - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_BONUS_MULTIPLIER, coeff); + modOwner->ApplySpellMod(spellProto, SPELLMOD_BONUS_MULTIPLIER, coeff); coeff /= 100.0f; } @@ -7697,7 +7697,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType // apply spellmod to Done damage if (spellProto) if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_DAMAGE, tmpDamage); + modOwner->ApplySpellMod(spellProto, SPELLMOD_DAMAGE, tmpDamage); // bonus result can be negative return uint32(std::max(tmpDamage, 0.0f)); @@ -7843,7 +7843,7 @@ float Unit::GetPPMProcChance(uint32 WeaponSpeed, float PPM, SpellInfo const* spe // Apply chance modifer aura if (spellProto) if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_PROC_PER_MINUTE, PPM); + modOwner->ApplySpellMod(spellProto, SPELLMOD_PROC_PER_MINUTE, PPM); return std::floor((WeaponSpeed * PPM) / 600.0f); // result is chance in percents (probability = Speed_in_sec * (PPM / 60)) } @@ -9113,23 +9113,23 @@ float Unit::ApplyEffectModifiers(SpellInfo const* spellProto, uint8 effect_index { if (Player* modOwner = GetSpellModOwner()) { - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_ALL_EFFECTS, value); + modOwner->ApplySpellMod(spellProto, SPELLMOD_ALL_EFFECTS, value); switch (effect_index) { case EFFECT_0: - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT1, value); + modOwner->ApplySpellMod(spellProto, SPELLMOD_EFFECT1, value); break; case EFFECT_1: - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT2, value); + modOwner->ApplySpellMod(spellProto, SPELLMOD_EFFECT2, value); break; case EFFECT_2: - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT3, value); + modOwner->ApplySpellMod(spellProto, SPELLMOD_EFFECT3, value); break; case EFFECT_3: - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT4, value); + modOwner->ApplySpellMod(spellProto, SPELLMOD_EFFECT4, value); break; case EFFECT_4: - modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_EFFECT5, value); + modOwner->ApplySpellMod(spellProto, SPELLMOD_EFFECT5, value); break; } } @@ -9248,7 +9248,7 @@ void Unit::ModSpellCastTime(SpellInfo const* spellInfo, int32 & castTime, Spell* // called from caster if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, castTime, spell); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_CASTING_TIME, castTime, spell); if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) @@ -9269,7 +9269,7 @@ void Unit::ModSpellDurationTime(SpellInfo const* spellInfo, int32 & duration, Sp // called from caster if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_CASTING_TIME, duration, spell); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_CASTING_TIME, duration, spell); if (!(spellInfo->HasAttribute(SPELL_ATTR0_ABILITY) || spellInfo->HasAttribute(SPELL_ATTR0_TRADESPELL) || spellInfo->HasAttribute(SPELL_ATTR3_NO_DONE_BONUS)) && ((GetTypeId() == TYPEID_PLAYER && spellInfo->SpellFamilyName) || GetTypeId() == TYPEID_UNIT)) @@ -12543,21 +12543,21 @@ void Unit::ApplyResilience(Unit const* victim, int32* damage) const // Melee based spells can be miss, parry or dodge on this step // Crit or block - determined on damage calculation phase! (and can be both in some time) -float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, uint32 spellId) const +float Unit::MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, SpellInfo const* spellInfo) const { //calculate miss chance float missChance = victim->GetUnitMissChance(attType); // melee attacks while dual wielding have +19% chance to miss - if (!spellId && haveOffhandWeapon() && !IsInFeralForm()) + if (!spellInfo && haveOffhandWeapon() && !IsInFeralForm()) missChance += 19.0f; // Spellmod from SPELLMOD_RESIST_MISS_CHANCE float resistMissChance = 100.0f; - if (spellId) + if (spellInfo) { if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellId, SPELLMOD_RESIST_MISS_CHANCE, resistMissChance); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_RESIST_MISS_CHANCE, resistMissChance); } missChance -= resistMissChance - 100.0f; diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index def55ca8f7c..04a6c82efbc 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1221,7 +1221,7 @@ class TC_GAME_API Unit : public WorldObject void ApplyResilience(Unit const* victim, int32* damage) const; - float MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, uint32 spellId) const; + float MeleeSpellMissChance(Unit const* victim, WeaponAttackType attType, SpellInfo const* spellInfo) const; SpellMissInfo MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const; SpellMissInfo MagicSpellHitResult(Unit* victim, SpellInfo const* spellInfo) const; SpellMissInfo SpellHitResult(Unit* victim, SpellInfo const* spellInfo, bool canReflect = false); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 7a6ab9710b1..06c7a88540a 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -715,7 +715,7 @@ void AuraEffect::CalculatePeriodic(Unit* caster, bool resetPeriodicTimer /*= tru { // Apply periodic time mod if (modOwner) - modOwner->ApplySpellMod(GetId(), SPELLMOD_ACTIVATION_TIME, m_period); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_ACTIVATION_TIME, m_period); if (caster) { diff --git a/src/server/game/Spells/Auras/SpellAuras.cpp b/src/server/game/Spells/Auras/SpellAuras.cpp index 517dbd4f8f7..571be21ac53 100644 --- a/src/server/game/Spells/Auras/SpellAuras.cpp +++ b/src/server/game/Spells/Auras/SpellAuras.cpp @@ -767,7 +767,7 @@ int32 Aura::CalcMaxDuration(Unit* caster) const // IsPermanent() checks max duration (which we are supposed to calculate here) if (maxDuration != -1 && modOwner) - modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, maxDuration); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_DURATION, maxDuration); return maxDuration; } @@ -777,7 +777,7 @@ void Aura::SetDuration(int32 duration, bool withMods) if (withMods) if (Unit* caster = GetCaster()) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetId(), SPELLMOD_DURATION, duration); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_DURATION, duration); m_duration = duration; SetNeedClientUpdateForTargets(); @@ -848,7 +848,7 @@ uint8 Aura::CalcMaxCharges(Unit* caster) const if (caster) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetId(), SPELLMOD_CHARGES, maxProcCharges); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_CHARGES, maxProcCharges); return uint8(maxProcCharges); } @@ -934,7 +934,7 @@ uint32 Aura::CalcMaxStackAmount() const int32 maxStackAmount = m_spellInfo->StackAmount; if (Unit* caster = GetCaster()) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_MAX_STACK_AMOUNT, maxStackAmount); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_MAX_STACK_AMOUNT, maxStackAmount); return maxStackAmount; } @@ -1113,7 +1113,7 @@ int32 Aura::CalcDispelChance(Unit const* /*auraTarget*/, bool /*offensive*/) con // Apply dispel mod from aura caster if (Unit* caster = GetCaster()) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetId(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_RESIST_DISPEL_CHANCE, resistChance); RoundToInterval(resistChance, 0, 100); return 100 - resistChance; @@ -1835,7 +1835,7 @@ float Aura::CalcProcChance(SpellProcEntry const& procEntry, ProcEventInfo& event // apply chance modifer aura, applies also to ppm chance (see improved judgement of light spell) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetId(), SPELLMOD_CHANCE_OF_SUCCESS, chance); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_CHANCE_OF_SUCCESS, chance); } // proc chance is reduced by an additional 3.333% per level past 60 diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index e493170ac7d..457b734b600 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -550,7 +550,7 @@ m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr) m_spellSchoolMask = SpellSchoolMask(1 << pItem->GetTemplate()->GetDamageType()); if (Player const* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(info->Id, SPELLMOD_STACK_AMOUNT, m_spellValue->AuraStackAmount, this); + modOwner->ApplySpellMod(info, SPELLMOD_STACK_AMOUNT, m_spellValue->AuraStackAmount, this); if (!originalCasterGUID.IsEmpty()) m_originalCasterGUID = originalCasterGUID; @@ -1583,7 +1583,7 @@ void Spell::SelectImplicitChainTargets(SpellEffIndex effIndex, SpellImplicitTarg uint32 maxTargets = effect->ChainTargets; if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_TARGETS, maxTargets, this); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_JUMP_TARGETS, maxTargets, this); if (maxTargets > 1) { @@ -1901,7 +1901,7 @@ void Spell::SearchChainTargets(std::list<WorldObject*>& targets, uint32 chainTar } if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_JUMP_DISTANCE, jumpRadius, this); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_JUMP_DISTANCE, jumpRadius, this); // chain lightning/heal spells and similar - allow to jump at larger distance and go out of los bool isBouncingFar = (m_spellInfo->HasAttribute(SPELL_ATTR4_AREA_TARGET_CHAIN) @@ -2870,7 +2870,7 @@ bool Spell::UpdateChanneledTargetList() { range = m_spellInfo->GetMaxRange(m_spellInfo->IsPositive()); if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, range, this); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_RANGE, range, this); // add little tolerance level range += std::min(MAX_SPELL_RANGE_TOLERANCE, range*0.1f); // 10% but no more than MAX_SPELL_RANGE_TOLERANCE @@ -3406,7 +3406,7 @@ void Spell::handle_immediate() // First mod_duration then haste - see Missile Barrage // Apply duration mod if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_DURATION, duration); // Apply haste mods m_caster->ModSpellDurationTime(m_spellInfo, duration, this); @@ -4656,7 +4656,7 @@ void Spell::TakePower() hit = false; //lower spell cost on fail (by talent aura) if (Player* modOwner = m_caster->ToPlayer()->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_SPELL_COST_REFUND_ON_FAIL, cost.Amount); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_SPELL_COST_REFUND_ON_FAIL, cost.Amount); } break; } @@ -6290,7 +6290,7 @@ std::pair<float, float> Spell::GetMinMaxRange(bool strict) const maxRange *= ranged->GetTemplate()->GetRangedModRange() * 0.01f; if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_RANGE, maxRange, const_cast<Spell*>(this)); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_RANGE, maxRange, const_cast<Spell*>(this)); maxRange += rangeMod; @@ -6891,7 +6891,7 @@ void Spell::Delayed() // only called in DealDamage() //check pushback reduce int32 delaytime = 500; // spellcasting delay is normally 500ms int32 delayReduce = 100; // must be initialized to 100 for percent modifiers - m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); + m_caster->ToPlayer()->ApplySpellMod(m_spellInfo, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if (delayReduce >= 100) return; @@ -6929,7 +6929,7 @@ void Spell::DelayedChannel() int32 delaytime = CalculatePct(duration, 25); // channeling delay is normally 25% of its time per hit int32 delayReduce = 100; // must be initialized to 100 for percent modifiers - m_caster->ToPlayer()->ApplySpellMod(m_spellInfo->Id, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); + m_caster->ToPlayer()->ApplySpellMod(m_spellInfo, SPELLMOD_NOT_LOSE_CASTING_TIME, delayReduce, this); delayReduce += m_caster->GetTotalAuraModifier(SPELL_AURA_REDUCE_PUSHBACK) - 100; if (delayReduce >= 100) return; @@ -7836,7 +7836,7 @@ void Spell::TriggerGlobalCooldown() { // gcd modifier auras are applied only to own spells and only players have such mods if (Player* modOwner = m_caster->GetSpellModOwner()) - modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_GLOBAL_COOLDOWN, gcd, this); + modOwner->ApplySpellMod(m_spellInfo, SPELLMOD_GLOBAL_COOLDOWN, gcd, this); bool isMeleeOrRangedSpell = m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_MELEE || m_spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED || diff --git a/src/server/game/Spells/SpellHistory.cpp b/src/server/game/Spells/SpellHistory.cpp index dd6ccf991f2..3e374d9c0e8 100644 --- a/src/server/game/Spells/SpellHistory.cpp +++ b/src/server/game/Spells/SpellHistory.cpp @@ -425,10 +425,10 @@ void SpellHistory::StartCooldown(SpellInfo const* spellInfo, uint32 itemId, Spel if (Player* modOwner = _owner->GetSpellModOwner()) { if (cooldown >= 0) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, cooldown, spell); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_COOLDOWN, cooldown, spell); if (categoryCooldown >= 0 && !spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_CATEGORY_COOLDOWN_MODS)) - modOwner->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, categoryCooldown, spell); + modOwner->ApplySpellMod(spellInfo, SPELLMOD_COOLDOWN, categoryCooldown, spell); } if (_owner->HasAuraTypeWithAffectMask(SPELL_AURA_MOD_SPELL_COOLDOWN_BY_HASTE, spellInfo)) diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index 75dd8da4ae0..b569df6b710 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -615,7 +615,7 @@ float SpellEffectInfo::CalcValueMultiplier(Unit* caster, Spell* spell) const { float multiplier = Amplitude; if (Player* modOwner = (caster ? caster->GetSpellModOwner() : nullptr)) - modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_VALUE_MULTIPLIER, multiplier, spell); + modOwner->ApplySpellMod(_spellInfo, SPELLMOD_VALUE_MULTIPLIER, multiplier, spell); return multiplier; } @@ -623,7 +623,7 @@ float SpellEffectInfo::CalcDamageMultiplier(Unit* caster, Spell* spell) const { float multiplierPercent = ChainAmplitude * 100.0f; if (Player* modOwner = (caster ? caster->GetSpellModOwner() : nullptr)) - modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_DAMAGE_MULTIPLIER, multiplierPercent, spell); + modOwner->ApplySpellMod(_spellInfo, SPELLMOD_DAMAGE_MULTIPLIER, multiplierPercent, spell); return multiplierPercent / 100.0f; } @@ -657,7 +657,7 @@ float SpellEffectInfo::CalcRadius(Unit* caster, Spell* spell) const radius += entry->RadiusPerLevel * caster->getLevel(); radius = std::min(radius, entry->RadiusMax); if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(_spellInfo->Id, SPELLMOD_RADIUS, radius, spell); + modOwner->ApplySpellMod(_spellInfo, SPELLMOD_RADIUS, radius, spell); } return radius; @@ -3650,7 +3650,7 @@ float SpellInfo::GetMaxRange(bool positive, Unit* caster, Spell* spell) const float range = RangeEntry->RangeMax[positive ? 1 : 0]; if (caster) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(Id, SPELLMOD_RANGE, range, spell); + modOwner->ApplySpellMod(this, SPELLMOD_RANGE, range, spell); return range; } @@ -3661,7 +3661,7 @@ int32 SpellInfo::CalcDuration(Unit* caster /*= nullptr*/) const if (caster) if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(Id, SPELLMOD_DURATION, duration); + modOwner->ApplySpellMod(this, SPELLMOD_DURATION, duration); return duration; } @@ -3863,13 +3863,13 @@ std::vector<SpellPowerCost> SpellInfo::CalcPowerCost(Unit const* caster, SpellSc switch (power->OrderIndex) { case 0: - modOwner->ApplySpellMod(Id, SPELLMOD_COST, powerCost, spell); + modOwner->ApplySpellMod(this, SPELLMOD_COST, powerCost, spell); break; case 1: - modOwner->ApplySpellMod(Id, SPELLMOD_SPELL_COST2, powerCost, spell); + modOwner->ApplySpellMod(this, SPELLMOD_SPELL_COST2, powerCost, spell); break; case 2: - modOwner->ApplySpellMod(Id, SPELLMOD_SPELL_COST3, powerCost, spell); + modOwner->ApplySpellMod(this, SPELLMOD_SPELL_COST3, powerCost, spell); break; default: break; diff --git a/src/server/scripts/Spells/spell_warlock.cpp b/src/server/scripts/Spells/spell_warlock.cpp index c8ef3fdf238..4f401a5823b 100644 --- a/src/server/scripts/Spells/spell_warlock.cpp +++ b/src/server/scripts/Spells/spell_warlock.cpp @@ -373,7 +373,7 @@ class spell_warl_health_funnel : public SpellScriptLoader uint32 damage = caster->CountPctFromMaxHealth(aurEff->GetBaseAmount()); if (Player* modOwner = caster->GetSpellModOwner()) - modOwner->ApplySpellMod(GetId(), SPELLMOD_COST, damage); + modOwner->ApplySpellMod(GetSpellInfo(), SPELLMOD_COST, damage); SpellNonMeleeDamage damageInfo(caster, caster, GetSpellInfo(), GetAura()->GetSpellVisual(), GetSpellInfo()->SchoolMask, GetAura()->GetCastGUID()); damageInfo.periodicLog = true; diff --git a/src/server/scripts/World/duel_reset.cpp b/src/server/scripts/World/duel_reset.cpp index 58946c4475d..5ddd5f7a081 100644 --- a/src/server/scripts/World/duel_reset.cpp +++ b/src/server/scripts/World/duel_reset.cpp @@ -98,13 +98,13 @@ class DuelResetScript : public PlayerScript int32 totalCooldown = spellInfo->RecoveryTime; int32 categoryCooldown = spellInfo->CategoryRecoveryTime; - player->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, totalCooldown, nullptr); + player->ApplySpellMod(spellInfo, SPELLMOD_COOLDOWN, totalCooldown, nullptr); if (int32 cooldownMod = player->GetTotalAuraModifier(SPELL_AURA_MOD_COOLDOWN)) totalCooldown += cooldownMod * IN_MILLISECONDS; if (!spellInfo->HasAttribute(SPELL_ATTR6_IGNORE_CATEGORY_COOLDOWN_MODS)) - player->ApplySpellMod(spellInfo->Id, SPELLMOD_COOLDOWN, categoryCooldown, nullptr); + player->ApplySpellMod(spellInfo, SPELLMOD_COOLDOWN, categoryCooldown, nullptr); return remainingCooldown > 0 && !itr->second.OnHold |