From c25ddd84fbe87c8437cc3f79e40235c7752eee3c Mon Sep 17 00:00:00 2001 From: killerwife Date: Thu, 28 Sep 2023 09:03:10 +0200 Subject: [PATCH] Unit: Rename SpellEntry usage to common spellInfo rather spellProto --- src/game/Entities/Unit.cpp | 330 ++++++++++++++++++------------------- 1 file changed, 165 insertions(+), 165 deletions(-) diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index d0152b431fc..8d98b64910e 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -791,7 +791,7 @@ void Unit::RemoveSpellsCausingAura(AuraType auraType, ObjectGuid casterGuid) } } -void Unit::DealDamageMods(Unit* dealer, Unit* victim, uint32& damage, uint32* absorb, DamageEffectType damagetype, SpellEntry const* spellProto) +void Unit::DealDamageMods(Unit* dealer, Unit* victim, uint32& damage, uint32* absorb, DamageEffectType damagetype, SpellEntry const* spellInfo) { if (!victim->IsAlive() || victim->IsTaxiFlying() || victim->GetCombatManager().IsInEvadeMode()) { @@ -815,11 +815,11 @@ void Unit::DealDamageMods(Unit* dealer, Unit* victim, uint32& damage, uint32* ab damage = 0; } if (UnitAI* ai = dealer->AI()) // Script Event damage Deal - ai->DamageDeal(victim, damage, damagetype, spellProto); + ai->DamageDeal(victim, damage, damagetype, spellInfo); } // Script Event damage taken if (victim->AI()) - victim->AI()->DamageTaken(dealer, damage, damagetype, spellProto); + victim->AI()->DamageTaken(dealer, damage, damagetype, spellInfo); if (absorb && originalDamage > damage) *absorb += (originalDamage - damage); @@ -836,7 +836,7 @@ void Unit::FallSuicide() DealDamage(this, this, this->GetHealth(), nullptr, SELF_DAMAGE, SPELL_SCHOOL_MASK_NORMAL, nullptr, false); } -uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellProto, bool durabilityLoss, Spell* spell) +uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo, bool durabilityLoss, Spell* spell) { // remove affects from attacker at any non-DoT damage (including 0 damage) if (damagetype != DOT && damagetype != INSTAKILL) @@ -886,7 +886,7 @@ uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage c if ((cleanDamage && cleanDamage->takenOrAbsorbedDamage) && (damagetype == DIRECT_DAMAGE || damagetype == SPELL_DIRECT_DAMAGE || damagetype == DOT || damagetype == SELF_DAMAGE || damagetype == SPELL_DAMAGE_SHIELD || damagetype == SPLIT_DAMAGE) - && !(spellProto && spellProto->HasAttribute(SPELL_ATTR_EX4_REACTIVE_DAMAGE_PROC))) + && !(spellInfo && spellInfo->HasAttribute(SPELL_ATTR_EX4_REACTIVE_DAMAGE_PROC))) { int32 actionInterruptFlags = AURA_INTERRUPT_FLAG_DAMAGE; if (damagetype != DOT) @@ -897,7 +897,7 @@ uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage c for (auto& aura : vInterrupts) { - if (spellProto && spellProto->Id == aura.second->GetId()) // Not drop auras added by self + if (spellInfo && spellInfo->Id == aura.second->GetId()) // Not drop auras added by self continue; const SpellEntry* se = aura.second->GetSpellProto(); @@ -946,8 +946,8 @@ uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage c for (auto vShareDamageAura : vShareDamageAuras) { // if damage is done by another shared aura, then skip to avoid circular reference (aura 300 is only applied on effect_idx_0 - if (spellProto && spellProto->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_APPLY_AURA && - spellProto->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_SHARE_DAMAGE_PCT) + if (spellInfo && spellInfo->Effect[EFFECT_INDEX_0] == SPELL_EFFECT_APPLY_AURA && + spellInfo->EffectApplyAuraName[EFFECT_INDEX_0] == SPELL_AURA_SHARE_DAMAGE_PCT) break; if (Unit* shareTarget = vShareDamageAura->GetCaster()) @@ -977,7 +977,7 @@ uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage c Player* killer = static_cast(dealer); // in bg, count dmg if victim is also a player - if (victim->IsPlayer() && (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX7_DO_NOT_COUNT_FOR_PVP_SCOREBOARD))) + if (victim->IsPlayer() && (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR_EX7_DO_NOT_COUNT_FOR_PVP_SCOREBOARD))) { if (BattleGround* bg = killer->GetBattleGround()) { @@ -1020,16 +1020,16 @@ uint32 Unit::DealDamage(Unit* dealer, Unit* victim, uint32 damage, CleanDamage c damage = health - 1; if (health <= damage) - Kill(dealer, victim, damagetype, spellProto, durabilityLoss, duel_hasEnded); + Kill(dealer, victim, damagetype, spellInfo, durabilityLoss, duel_hasEnded); else // if (health <= damage) - HandleDamageDealt(dealer, victim, damage, cleanDamage, damagetype, damageSchoolMask, spellProto, duel_hasEnded); + HandleDamageDealt(dealer, victim, damage, cleanDamage, damagetype, damageSchoolMask, spellInfo, duel_hasEnded); DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageEnd returned %d damage", damage); return damage; } -void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEntry const* spellProto, bool durabilityLoss, bool duel_hasEnded) +void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEntry const* spellInfo, bool durabilityLoss, bool duel_hasEnded) { DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamage %s Killed %s", killer ? killer->GetGuidStr().c_str() : "", victim->GetGuidStr().c_str()); @@ -1177,7 +1177,7 @@ void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEn // only if not player and not controlled by player pet. And not at BG if (durabilityLoss && !responsiblePlayer && !playerVictim->InBattleGround()) { - if (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX3_NO_DURABILITY_LOSS)) + if (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_DURABILITY_LOSS)) { DEBUG_LOG("DealDamage: Killed %s, looing 10 percents durability", victim->GetGuidStr().c_str()); playerVictim->DurabilityLossAll(0.10f, false); @@ -1205,7 +1205,7 @@ void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEn playerVictim->DuelComplete(DUEL_INTERRUPTED); } - if (responsiblePlayer && (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX7_DO_NOT_LOG_PVP_KILL))) // PvP kill + if (responsiblePlayer && (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR_EX7_DO_NOT_LOG_PVP_KILL))) // PvP kill { if (BattleGround* bg = playerVictim->GetBattleGround()) { @@ -1231,7 +1231,7 @@ void Unit::Kill(Unit* killer, Unit* victim, DamageEffectType damagetype, SpellEn victim->CombatStop(); } -void Unit::HandleDamageDealt(Unit* dealer, Unit* victim, uint32& damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellProto, bool duel_hasEnded) +void Unit::HandleDamageDealt(Unit* dealer, Unit* victim, uint32& damage, CleanDamage const* cleanDamage, DamageEffectType damagetype, SpellSchoolMask damageSchoolMask, SpellEntry const* spellInfo, bool duel_hasEnded) { DEBUG_FILTER_LOG(LOG_FILTER_DAMAGE, "DealDamageAlive"); @@ -1239,10 +1239,10 @@ void Unit::HandleDamageDealt(Unit* dealer, Unit* victim, uint32& damage, CleanDa if (dealer) { - if (victim->CanAttack(dealer) && (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX_NO_THREAT)) && dealer->CanEnterCombat() && victim->CanEnterCombat()) + if (victim->CanAttack(dealer) && (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR_EX_NO_THREAT)) && dealer->CanEnterCombat() && victim->CanEnterCombat()) { - float threat = damage * sSpellMgr.GetSpellThreatMultiplier(spellProto); - victim->AddThreat(dealer, threat, (cleanDamage && cleanDamage->hitOutCome == MELEE_HIT_CRIT), damageSchoolMask, spellProto); + float threat = damage * sSpellMgr.GetSpellThreatMultiplier(spellInfo); + victim->AddThreat(dealer, threat, (cleanDamage && cleanDamage->hitOutCome == MELEE_HIT_CRIT), damageSchoolMask, spellInfo); if (damagetype != DOT && damagetype != SPELL_DAMAGE_SHIELD) // DOTs dont put in combat but still cause threat { dealer->SetInCombatWith(victim); @@ -1278,7 +1278,7 @@ void Unit::HandleDamageDealt(Unit* dealer, Unit* victim, uint32& damage, CleanDa } if (dealer) - dealer->InterruptOrDelaySpell(victim, damagetype, spellProto); + dealer->InterruptOrDelaySpell(victim, damagetype, spellInfo); // last damage from duel opponent if (duel_hasEnded) @@ -1298,10 +1298,10 @@ void Unit::HandleDamageDealt(Unit* dealer, Unit* victim, uint32& damage, CleanDa } } -void Unit::InterruptOrDelaySpell(Unit* pVictim, DamageEffectType damagetype, SpellEntry const* spellProto) +void Unit::InterruptOrDelaySpell(Unit* pVictim, DamageEffectType damagetype, SpellEntry const* spellInfo) { - bool dotDamage = (damagetype == DOT || spellProto && spellProto->HasAttribute(SPELL_ATTR_EX3_TREAT_AS_PERIODIC)); - if (damagetype == NODAMAGE || damagetype == SPELL_DAMAGE_SHIELD || damagetype == SPLIT_DAMAGE || (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX7_DONT_CAUSE_SPELL_PUSHBACK))) + bool dotDamage = (damagetype == DOT || spellInfo && spellInfo->HasAttribute(SPELL_ATTR_EX3_TREAT_AS_PERIODIC)); + if (damagetype == NODAMAGE || damagetype == SPELL_DAMAGE_SHIELD || damagetype == SPLIT_DAMAGE || (spellInfo && spellInfo->HasAttribute(SPELL_ATTR_EX7_DONT_CAUSE_SPELL_PUSHBACK))) return; for (uint32 i = CURRENT_FIRST_NON_MELEE_SPELL; i < CURRENT_MAX_SPELL; ++i) @@ -2369,7 +2369,7 @@ void Unit::DealMeleeDamage(CalcDamageInfo* calcDamageInfo, bool durabilityLoss) // Calculate absorb resist ??? no data in opcode for this possibly unable to absorb or resist? // uint32 absorb; // uint32 resist; - // CalcAbsorbResist(victim, SpellSchools(spellProto->School), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); + // CalcAbsorbResist(victim, SpellSchools(spellInfo->School), SPELL_DIRECT_DAMAGE, damage, &absorb, &resist); // damage-=absorb + resist; Unit::DealDamageMods(victim, this, damage, nullptr, SPELL_DIRECT_DAMAGE, spellProto); @@ -3045,9 +3045,9 @@ void Unit::CalculateDamageAbsorbAndResist(Unit* caster, SpellSchoolMask schoolMa *absorb = damage - RemainingDamage - *resist; } -void Unit::CalculateAbsorbResistBlock(Unit* caster, SpellNonMeleeDamage* spellDamageInfo, SpellEntry const* spellProto, WeaponAttackType attType) +void Unit::CalculateAbsorbResistBlock(Unit* caster, SpellNonMeleeDamage* spellDamageInfo, SpellEntry const* spellInfo, WeaponAttackType attType) { - if (RollAbilityPartialBlockOutcome(caster, attType, spellProto)) + if (RollAbilityPartialBlockOutcome(caster, attType, spellInfo)) { uint32 blockValue = GetShieldBlockValue(); if (IsBlockCritical()) @@ -3056,8 +3056,8 @@ void Unit::CalculateAbsorbResistBlock(Unit* caster, SpellNonMeleeDamage* spellDa spellDamageInfo->damage -= spellDamageInfo->blocked; } - uint32 absorb_affected_damage = caster ? caster->CalcNotIgnoreAbsorbDamage(spellDamageInfo->damage, GetSpellSchoolMask(spellProto), spellProto) : spellDamageInfo->damage; - CalculateDamageAbsorbAndResist(caster, spellDamageInfo->schoolMask, SPELL_DIRECT_DAMAGE, absorb_affected_damage, &spellDamageInfo->absorb, &spellDamageInfo->resist, IsReflectableSpell(spellProto), IsResistableSpell(spellProto) && !spellProto->HasAttribute(SPELL_ATTR_EX5_NO_PARTIAL_RESISTS), IsBinarySpell(*spellProto)); + uint32 absorb_affected_damage = caster ? caster->CalcNotIgnoreAbsorbDamage(spellDamageInfo->damage, GetSpellSchoolMask(spellInfo), spellInfo) : spellDamageInfo->damage; + CalculateDamageAbsorbAndResist(caster, spellDamageInfo->schoolMask, SPELL_DIRECT_DAMAGE, absorb_affected_damage, &spellDamageInfo->absorb, &spellDamageInfo->resist, IsReflectableSpell(spellInfo), IsResistableSpell(spellInfo) && !spellInfo->HasAttribute(SPELL_ATTR_EX5_NO_PARTIAL_RESISTS), IsBinarySpell(*spellInfo)); const uint32 bonus = (spellDamageInfo->resist < 0 ? uint32(std::abs(spellDamageInfo->resist)) : 0); spellDamageInfo->damage += bonus; @@ -3337,30 +3337,30 @@ void Unit::SendMeleeAttackStop(const Unit& victim) const DETAIL_FILTER_LOG(LOG_FILTER_COMBAT, "%s stopped attacking %s", GetGuidStr().c_str(), victim.GetGuidStr().c_str()); } -SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell, uint32* heartbeatResistChance/* = nullptr*/) +SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spellInfo, uint32* heartbeatResistChance/* = nullptr*/) { Die die; - if (!spell->HasAttribute(SPELL_ATTR_EX7_NO_ATTACK_MISS)) - die.set(UNIT_COMBAT_DIE_MISS, CalculateSpellMissChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spell)); - die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spell)); - if (pVictim->CanReactOnAbility(spell)) - { - const WeaponAttackType attackType = GetWeaponAttackType(spell); - if (pVictim->CanDodgeAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_DODGE, pVictim->CalculateEffectiveDodgeChance(this, attackType, spell)); - if (pVictim->CanParryAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_PARRY, pVictim->CalculateEffectiveParryChance(this, attackType, spell)); - if (pVictim->CanDeflectAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_DEFLECT, pVictim->CalculateAbilityDeflectChance(this, spell)); - if (pVictim->CanBlockAbility(this, spell, true)) - die.set(UNIT_COMBAT_DIE_BLOCK, pVictim->CalculateEffectiveBlockChance(this, attackType, spell)); - } - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MeleeSpellHitResult: New ability hit die: %u [MISS:%u, RESIST:%u, DODGE:%u, PARRY:%u, DEFLECT:%u, BLOCK:%u]", spell->Id, + if (!spellInfo->HasAttribute(SPELL_ATTR_EX7_NO_ATTACK_MISS)) + die.set(UNIT_COMBAT_DIE_MISS, CalculateSpellMissChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spellInfo)); + die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, SPELL_SCHOOL_MASK_NORMAL, spellInfo)); + if (pVictim->CanReactOnAbility(spellInfo)) + { + const WeaponAttackType attackType = GetWeaponAttackType(spellInfo); + if (pVictim->CanDodgeAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_DODGE, pVictim->CalculateEffectiveDodgeChance(this, attackType, spellInfo)); + if (pVictim->CanParryAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_PARRY, pVictim->CalculateEffectiveParryChance(this, attackType, spellInfo)); + if (pVictim->CanDeflectAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_DEFLECT, pVictim->CalculateAbilityDeflectChance(this, spellInfo)); + if (pVictim->CanBlockAbility(this, spellInfo, true)) + die.set(UNIT_COMBAT_DIE_BLOCK, pVictim->CalculateEffectiveBlockChance(this, attackType, spellInfo)); + } + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MeleeSpellHitResult: New ability hit die: %u [MISS:%u, RESIST:%u, DODGE:%u, PARRY:%u, DEFLECT:%u, BLOCK:%u]", spellInfo->Id, die.chance[UNIT_COMBAT_DIE_MISS], die.chance[UNIT_COMBAT_DIE_RESIST], die.chance[UNIT_COMBAT_DIE_DODGE], die.chance[UNIT_COMBAT_DIE_PARRY], die.chance[UNIT_COMBAT_DIE_DEFLECT], die.chance[UNIT_COMBAT_DIE_BLOCK]); // Memorize heartbeat resist chance if needed: - if (heartbeatResistChance && spell->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) + if (heartbeatResistChance && spellInfo->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) *heartbeatResistChance = (die.chance[UNIT_COMBAT_DIE_RESIST] + die.chance[UNIT_COMBAT_DIE_MISS]); const uint32 random = urand(1, 10000); @@ -3380,18 +3380,18 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* pVictim, SpellEntry const* spell, return SPELL_MISS_NONE; } -SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell, SpellSchoolMask schoolMask, uint32* heartbeatResistChance/* = nullptr*/) +SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spellInfo, SpellSchoolMask schoolMask, uint32* heartbeatResistChance/* = nullptr*/) { Die die; - die.set(UNIT_COMBAT_DIE_MISS, CalculateSpellMissChance(pVictim, schoolMask, spell)); - die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, schoolMask, spell)); - if (pVictim->CanDeflectAbility(this, spell)) - die.set(UNIT_COMBAT_DIE_DEFLECT, pVictim->CalculateAbilityDeflectChance(this, spell)); - DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MagicSpellHitResult: New spell hit die: %u [MISS:%u, RESIST:%u, DEFLECT:%u]", spell->Id, + die.set(UNIT_COMBAT_DIE_MISS, CalculateSpellMissChance(pVictim, schoolMask, spellInfo)); + die.set(UNIT_COMBAT_DIE_RESIST, CalculateSpellResistChance(pVictim, schoolMask, spellInfo)); + if (pVictim->CanDeflectAbility(this, spellInfo)) + die.set(UNIT_COMBAT_DIE_DEFLECT, pVictim->CalculateAbilityDeflectChance(this, spellInfo)); + DEBUG_FILTER_LOG(LOG_FILTER_COMBAT, "MagicSpellHitResult: New spell hit die: %u [MISS:%u, RESIST:%u, DEFLECT:%u]", spellInfo->Id, die.chance[UNIT_COMBAT_DIE_MISS], die.chance[UNIT_COMBAT_DIE_RESIST], die.chance[UNIT_COMBAT_DIE_DEFLECT]); // Memorize heartbeat resist chance if needed: - if (heartbeatResistChance && spell->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) + if (heartbeatResistChance && spellInfo->HasAttribute(SPELL_ATTR_HEARTBEAT_RESIST)) *heartbeatResistChance = (die.chance[UNIT_COMBAT_DIE_RESIST] + die.chance[UNIT_COMBAT_DIE_MISS]); const uint32 random = urand(1, 10000); @@ -3408,7 +3408,7 @@ SpellMissInfo Unit::MagicSpellHitResult(Unit* pVictim, SpellEntry const* spell, return SPELL_MISS_NONE; } -SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntry const* spell, uint8 effectMask, bool reflectable, bool reflected, uint32* heartbeatResistChance/* = nullptr*/) +SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntry const* spellInfo, uint8 effectMask, bool reflectable, bool reflected, uint32* heartbeatResistChance/* = nullptr*/) { // Dead units can't be missed, can't resist, reflect, etc if (!pVictim->IsAlive()) @@ -3419,33 +3419,33 @@ SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntr return SPELL_MISS_EVADE; // !!! - SpellSchoolMask schoolMask = GetSpellSchoolMask(spell); + SpellSchoolMask schoolMask = GetSpellSchoolMask(spellInfo); // All positive spells can`t miss // TODO: client not show miss log for this spells - so need find info for this in dbc and use it! - if (IsPositiveEffectMask(spell, effectMask, caster, pVictim)) + if (IsPositiveEffectMask(spellInfo, effectMask, caster, pVictim)) { - if (pVictim->IsImmuneToSpell(spell, reflected ? false : (caster == pVictim), effectMask, caster)) + if (pVictim->IsImmuneToSpell(spellInfo, reflected ? false : (caster == pVictim), effectMask, caster)) return SPELL_MISS_IMMUNE; // Check for immune to damage as hit result if spell hit composed entirely out of damage effects - if (IsSpellEffectsDamage(*spell, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) + if (IsSpellEffectsDamage(*spellInfo, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) return SPELL_MISS_IMMUNE; return SPELL_MISS_NONE; } // !!!UNHACKME: Self-resists suppression hack for channeled spells until spell execution is modernized with effectmasks: Drain Soul, Blizzard, RoF - if (pVictim == caster && IsChanneledSpell(spell)) + if (pVictim == caster && IsChanneledSpell(spellInfo)) { for (uint32 i = EFFECT_INDEX_0; i < MAX_EFFECT_INDEX; ++i) { - if (IsCasterSourceTarget(spell->EffectImplicitTargetA[i]) || IsCasterSourceTarget(spell->EffectImplicitTargetB[i])) + if (IsCasterSourceTarget(spellInfo->EffectImplicitTargetA[i]) || IsCasterSourceTarget(spellInfo->EffectImplicitTargetB[i])) return SPELL_MISS_NONE; } } // wand case - bool wand = spell->Id == 5019; + bool wand = spellInfo->Id == 5019; if (wand && caster->IsPlayer() && !!(static_cast(caster)->getClassMask() & CLASSMASK_WAND_USERS)) schoolMask = static_cast(caster)->GetRangedDamageSchoolMask(); @@ -3456,14 +3456,14 @@ SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntr if (roll_chance_combat(chance)) return SPELL_MISS_REFLECT; } - if (!spell->HasAttribute(SPELL_ATTR_NO_IMMUNITIES)) + if (!spellInfo->HasAttribute(SPELL_ATTR_NO_IMMUNITIES)) { // TODO: improve for partial application // Check for immune - if (!wand && pVictim->IsImmuneToSpell(spell, reflected ? false : (caster == pVictim), effectMask, caster)) + if (!wand && pVictim->IsImmuneToSpell(spellInfo, reflected ? false : (caster == pVictim), effectMask, caster)) return SPELL_MISS_IMMUNE; // Check for immune to damage as hit result if spell hit composed entirely out of damage effects - if (IsSpellEffectsDamage(*spell, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) + if (IsSpellEffectsDamage(*spellInfo, effectMask) && pVictim->IsImmuneToDamage(schoolMask)) return SPELL_MISS_IMMUNE; } @@ -3473,15 +3473,15 @@ SpellMissInfo Unit::SpellHitResult(WorldObject* caster, Unit* pVictim, SpellEntr else if (caster->IsGameObject()) hitCaster = static_cast(caster)->GetOwner(); - if (hitCaster && !spell->HasAttribute(SPELL_ATTR_EX3_NO_AVOIDANCE)) + if (hitCaster && !spellInfo->HasAttribute(SPELL_ATTR_EX3_NO_AVOIDANCE)) { - switch (spell->DmgClass) + switch (spellInfo->DmgClass) { case SPELL_DAMAGE_CLASS_MELEE: case SPELL_DAMAGE_CLASS_RANGED: - return hitCaster->MeleeSpellHitResult(pVictim, spell, heartbeatResistChance); + return hitCaster->MeleeSpellHitResult(pVictim, spellInfo, heartbeatResistChance); case SPELL_DAMAGE_CLASS_MAGIC: - return hitCaster->MagicSpellHitResult(pVictim, spell, schoolMask, heartbeatResistChance); + return hitCaster->MagicSpellHitResult(pVictim, spellInfo, schoolMask, heartbeatResistChance); case SPELL_DAMAGE_CLASS_NONE: // Usually never misses, but needs more research for some spells break; @@ -6689,13 +6689,13 @@ bool Unit::HasAuraTypeWithMiscvalue(AuraType auraType, int32 miscvalue) const return false; } -bool Unit::HasAffectedAura(AuraType auraType, SpellEntry const* spellProto) const +bool Unit::HasAffectedAura(AuraType auraType, SpellEntry const* spellInfo) const { Unit::AuraList const& auras = GetAurasByType(auraType); for (auto aura : auras) { - if (aura->isAffectedOnSpell(spellProto)) + if (aura->isAffectedOnSpell(spellInfo)) return true; } @@ -8139,7 +8139,7 @@ void Unit::UnsummonAllTotems() const totem->UnSummon(); } -int32 Unit::DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellProto, bool critical, uint32 absorb) +int32 Unit::DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellInfo, bool critical, uint32 absorb) { int32 gain = pVictim->ModifyHealth(int32(addhealth)); @@ -8149,7 +8149,7 @@ int32 Unit::DealHeal(Unit* pVictim, uint32 addhealth, SpellEntry const* spellPro unit = GetOwner(); // overheal = addhealth - gain - unit->SendHealSpellLog(pVictim, spellProto->Id, addhealth, addhealth - gain, critical, absorb); + unit->SendHealSpellLog(pVictim, spellInfo->Id, addhealth, addhealth - gain, critical, absorb); if (unit->GetTypeId() == TYPEID_PLAYER) { @@ -8277,7 +8277,7 @@ void Unit::EnergizeBySpell(Unit* victim, SpellEntry const* spellInfo, uint32 dam /** Calculate spell coefficents and level penalties for spell/melee damage or heal * * this is the caster of the spell/ melee attacker - * @param spellProto SpellEntry of the used spell + * @param spellInfo SpellEntry of the used spell * @param total current value onto which the Bonus and level penalty will be calculated * @param benefit additional benefit from ie spellpower-auras * @param ap_benefit additional melee attackpower benefit from auras @@ -8342,20 +8342,20 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int3 * Calculates caster part of spell damage bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { - if (!spellProto || !victim || damagetype == DIRECT_DAMAGE) + if (!spellInfo || !victim || damagetype == DIRECT_DAMAGE) return pdamage; // Some spells don't benefit from done mods - if (spellProto->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) + if (spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) return pdamage; // For totems get damage bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) { if (Unit* owner = GetOwner()) - return owner->SpellDamageBonusDone(victim, schoolMask, spellProto, pdamage, damagetype); + return owner->SpellDamageBonusDone(victim, schoolMask, spellInfo, pdamage, damagetype); } uint32 creatureTypeMask = victim->GetCreatureTypeMask(); @@ -8368,7 +8368,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel // Add flat bonus from spell damage creature DoneTotal += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_DAMAGE_DONE_CREATURE, creatureTypeMask); - if (spellProto->HasAttribute(SPELL_ATTR_EX6_IGNORE_CASTER_DAMAGE_MODIFIERS)) + if (spellInfo->HasAttribute(SPELL_ATTR_EX6_IGNORE_CASTER_DAMAGE_MODIFIERS)) { // Creature damage if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->IsPet()) @@ -8409,7 +8409,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel for (auto i : GetScriptedLocationAuras(SCRIPT_LOCATION_SPELL_DAMAGE_DONE)) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; i->OnDamageCalculate(victim, DoneAdvertisedBenefit, DoneTotalMod); } @@ -8417,7 +8417,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (auto i : mOverrideClassScript) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; switch (i->GetModifier()->m_miscvalue) { @@ -8529,14 +8529,14 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel } // Custom scripted damage - switch (spellProto->SpellFamilyName) + switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_MAGE: { // Ice Lance - if (spellProto->SpellIconID == 186) + if (spellInfo->SpellIconID == 186) { - if (victim->isFrozen() || IsIgnoreUnitState(spellProto, IGNORE_UNIT_TARGET_NON_FROZEN)) + if (victim->isFrozen() || IsIgnoreUnitState(spellInfo, IGNORE_UNIT_TARGET_NON_FROZEN)) { float multiplier = 3.0f; @@ -8550,7 +8550,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel } } // Torment the weak affected (Arcane Barrage, Arcane Blast, Frostfire Bolt, Arcane Missiles, Fireball) - if ((spellProto->SpellFamilyFlags & uint64(0x0000900020200021)) && + if ((spellInfo->SpellFamilyFlags & uint64(0x0000900020200021)) && (victim->HasAuraType(SPELL_AURA_MOD_DECREASE_SPEED) || victim->HasAuraType(SPELL_AURA_HASTE_ALL))) { // Search for Torment the weak dummy aura @@ -8569,7 +8569,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel case SPELLFAMILY_WARLOCK: { // Drain Soul - if (spellProto->SpellFamilyFlags & uint64(0x0000000000004000)) + if (spellInfo->SpellFamilyFlags & uint64(0x0000000000004000)) { if (victim->GetHealth() * 100 / victim->GetMaxHealth() <= 25) DoneTotalMod *= 4; @@ -8579,7 +8579,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel case SPELLFAMILY_PRIEST: { // Smite - if (spellProto->IsFitToFamilyMask(uint64(0x0000000000000080))) + if (spellInfo->IsFitToFamilyMask(uint64(0x0000000000000080))) { // Holy Fire if (victim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_PRIEST, uint64(0x00100000))) @@ -8588,7 +8588,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel DoneTotalMod *= (aur->GetModifier()->m_amount + 100.0f) / 100.0f; } // Shadow word: Death - else if (spellProto->IsFitToFamilyMask(uint64(0x0000000200000000))) + else if (spellInfo->IsFitToFamilyMask(uint64(0x0000000200000000))) { // Glyph of Shadow word: Death if (SpellAuraHolder const* glyph = GetSpellAuraHolder(55682)) @@ -8604,7 +8604,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel case SPELLFAMILY_DRUID: { // Improved Insect Swarm (Wrath part) - if (spellProto->SpellFamilyFlags & uint64(0x0000000000000001)) + if (spellInfo->SpellFamilyFlags & uint64(0x0000000000000001)) { // if Insect Swarm on target if (victim->GetAura(SPELL_AURA_PERIODIC_DAMAGE, SPELLFAMILY_DRUID, uint64(0x000000000200000), 0, GetObjectGuid())) @@ -8625,7 +8625,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel case SPELLFAMILY_DEATHKNIGHT: { // Icy Touch and Howling Blast - if (spellProto->SpellFamilyFlags & uint64(0x0000000200000002)) + if (spellInfo->SpellFamilyFlags & uint64(0x0000000200000002)) { // search disease bool found = false; @@ -8653,7 +8653,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel } } // Death Coil (bonus from Item - Death Knight T8 DPS Relic) - else if (spellProto->SpellFamilyFlags & uint64(0x00002000)) + else if (spellInfo->SpellFamilyFlags & uint64(0x00002000)) { if (Aura* sigil = GetDummyAura(64962)) DoneTotal += sigil->GetModifier()->m_amount; @@ -8665,15 +8665,15 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel } // apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties - DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true); + DoneTotal = SpellBonusWithCoeffs(spellInfo, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true); - if (spellProto->HasAttribute(SPELL_ATTR_EX6_IGNORE_CASTER_DAMAGE_MODIFIERS)) + if (spellInfo->HasAttribute(SPELL_ATTR_EX6_IGNORE_CASTER_DAMAGE_MODIFIERS)) DoneTotalMod = 1.f; // reset it float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod; // apply spellmod to Done damage (flat and pct) if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); + modOwner->ApplySpellMod(spellInfo->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); return tmpDamage > 0 ? uint32(tmpDamage) : 0; } @@ -8682,9 +8682,9 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel * Calculates target part of spell damage bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { - if (!spellProto || damagetype == DIRECT_DAMAGE || spellProto->HasAttribute(SPELL_ATTR_EX4_IGNORE_DAMAGE_TAKEN_MODIFIERS)) + if (!spellInfo || damagetype == DIRECT_DAMAGE || spellInfo->HasAttribute(SPELL_ATTR_EX4_IGNORE_DAMAGE_TAKEN_MODIFIERS)) return pdamage; // Taken total percent damage auras @@ -8721,7 +8721,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, Spe case 47581: // Pain and Suffering (Rank 2) case 47582: // Pain and Suffering (Rank 3) // Shadow Word: Death - if (spellProto->IsFitToFamilyMask(uint64(0x0000000200000000))) + if (spellInfo->IsFitToFamilyMask(uint64(0x0000000200000000))) TakenTotalMod *= (mDummyAura->GetModifier()->m_amount + 100.0f) / 100.0f; break; } @@ -8731,34 +8731,34 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, Spe AuraList const& mOwnerTaken = GetAurasByType(SPELL_AURA_MOD_DAMAGE_FROM_CASTER); for (auto i : mOwnerTaken) { - if (i->GetCasterGuid() == caster->GetObjectGuid() && i->isAffectedOnSpell(spellProto)) + if (i->GetCasterGuid() == caster->GetObjectGuid() && i->isAffectedOnSpell(spellInfo)) TakenTotalMod *= (i->GetModifier()->m_amount + 100.0f) / 100.0f; } // Mod damage from spell mechanic - TakenTotalMod *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT, GetAllSpellMechanicMask(spellProto)); + TakenTotalMod *= GetTotalAuraMultiplierByMiscValueForMask(SPELL_AURA_MOD_MECHANIC_DAMAGE_TAKEN_PERCENT, GetAllSpellMechanicMask(spellInfo)); // Mod damage taken from AoE spells - if (IsAreaOfEffectSpell(spellProto) || spellProto->HasAttribute(SPELL_ATTR_EX5_TREAT_AS_AREA_EFFECT)) + if (IsAreaOfEffectSpell(spellInfo) || spellInfo->HasAttribute(SPELL_ATTR_EX5_TREAT_AS_AREA_EFFECT)) { TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask); - if (caster && !caster->IsPlayerControlled() || spellProto->HasAttribute(SPELL_ATTR_EX7_TREAT_AS_NPC_AOE)) + if (caster && !caster->IsPlayerControlled() || spellInfo->HasAttribute(SPELL_ATTR_EX7_TREAT_AS_NPC_AOE)) TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, schoolMask); } // Taken fixed damage bonus auras - int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(GetSpellSchoolMask(spellProto)); + int32 TakenAdvertisedBenefit = SpellBaseDamageBonusTaken(GetSpellSchoolMask(spellInfo)); for (auto i : GetScriptedLocationAuras(SCRIPT_LOCATION_SPELL_DAMAGE_TAKEN)) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; i->OnDamageCalculate(this, TakenAdvertisedBenefit, TakenTotalMod); } // apply benefit affected by spell power implicit coeffs and spell level penalties if (caster) - TakenTotal = caster->SpellBonusWithCoeffs(spellProto, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false); + TakenTotal = caster->SpellBonusWithCoeffs(spellInfo, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false); float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod; @@ -8825,19 +8825,19 @@ int32 Unit::SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const * Calculates caster part of healing spell bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, int32 healamount, DamageEffectType damagetype, uint32 stack) { // Some spells don't benefit from done mods - if (spellProto->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS) || spellProto->HasAttribute(SPELL_ATTR_EX6_IGNORE_HEALING_MODIFIERS)) + if (spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS) || spellInfo->HasAttribute(SPELL_ATTR_EX6_IGNORE_HEALING_MODIFIERS)) return healamount; // For totems get healing bonus from owner (statue isn't totem in fact) if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) if (Unit* owner = GetOwner()) - return owner->SpellHealingBonusDone(victim, spellProto, healamount, damagetype, stack); + return owner->SpellHealingBonusDone(victim, spellInfo, healamount, damagetype, stack); // No heal amount for this class spells - if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE) + if (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE) return healamount < 0 ? 0 : healamount; // Healing Done @@ -8851,7 +8851,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, i DoneTotalMod *= (100.0f + i->GetModifier()->m_amount) / 100.0f; // Done fixed damage bonus auras - int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto)); + int32 DoneAdvertisedBenefit = SpellBaseHealingBonusDone(GetSpellSchoolMask(spellInfo)); // done scripted mod (take it from owner) Unit* owner = GetOwner(); @@ -8860,7 +8860,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, i AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (auto i : mOverrideClassScript) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; switch (i->GetModifier()->m_miscvalue) { @@ -8913,10 +8913,10 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, i } } - if (spellProto->SpellFamilyName == SPELLFAMILY_DRUID) + if (spellInfo->SpellFamilyName == SPELLFAMILY_DRUID) { // Nourish 20% of heal increase if target is affected by Druids HOTs - if (spellProto->SpellFamilyFlags & uint64(0x0200000000000000)) + if (spellInfo->SpellFamilyFlags & uint64(0x0200000000000000)) { int ownHotCount = 0; // counted HoT types amount, not stacks Unit::AuraList const& RejorRegr = victim->GetAurasByType(SPELL_AURA_PERIODIC_HEAL); @@ -8938,7 +8938,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, i AuraList const& auraDummy = owner->GetAurasByType(SPELL_AURA_DUMMY); for (auto i : auraDummy) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; switch (i->GetSpellProto()->Id) { @@ -8954,19 +8954,19 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, i for (auto i : GetScriptedLocationAuras(SCRIPT_LOCATION_SPELL_HEALING_DONE)) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; i->OnDamageCalculate(victim, DoneAdvertisedBenefit, DoneTotalMod); } // apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties - DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, SCALE_SPELLPOWER_HEALING); + DoneTotal = SpellBonusWithCoeffs(spellInfo, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true, SCALE_SPELLPOWER_HEALING); // use float as more appropriate for negative values and percent applying float heal = (healamount + DoneTotal * int32(stack)) * DoneTotalMod; // apply spellmod to Done amount if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); + modOwner->ApplySpellMod(spellInfo->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, heal); return heal < 0 ? 0 : uint32(heal); } @@ -8975,9 +8975,9 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, i * Calculates target part of healing spell bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellInfo, int32 healamount, DamageEffectType damagetype, uint32 stack) { - if (spellProto->HasAttribute(SPELL_ATTR_EX6_IGNORE_HEALING_MODIFIERS)) + if (spellInfo->HasAttribute(SPELL_ATTR_EX6_IGNORE_HEALING_MODIFIERS)) return healamount; float TakenTotalMod = 1.0f; @@ -8999,7 +8999,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, TakenTotalMod *= (100.0f + maxval) / 100.0f; // No heal amount for this class spells - if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE) + if (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE) { healamount = int32(healamount * TakenTotalMod); return healamount < 0 ? 0 : healamount; @@ -9010,18 +9010,18 @@ uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, int32 TakenTotal = 0; // Taken fixed damage bonus auras - int32 TakenAdvertisedBenefit = SpellBaseHealingBonusTaken(GetSpellSchoolMask(spellProto)); + int32 TakenAdvertisedBenefit = SpellBaseHealingBonusTaken(GetSpellSchoolMask(spellInfo)); // Blessing of Light dummy affects healing taken from Holy Light and Flash of Light - if (spellProto->SpellFamilyName == SPELLFAMILY_PALADIN && (spellProto->SpellFamilyFlags & uint64(0x00000000C0000000))) + if (spellInfo->SpellFamilyName == SPELLFAMILY_PALADIN && (spellInfo->SpellFamilyFlags & uint64(0x00000000C0000000))) { AuraList const& auraDummy = GetAurasByType(SPELL_AURA_DUMMY); for (auto i : auraDummy) { if (i->GetSpellProto()->SpellVisual[0] == 9180) { - if (((spellProto->SpellFamilyFlags & uint64(0x0000000040000000)) && i->GetEffIndex() == EFFECT_INDEX_1) || // Flash of Light - ((spellProto->SpellFamilyFlags & uint64(0x0000000080000000)) && i->GetEffIndex() == EFFECT_INDEX_0)) // Holy Light + if (((spellInfo->SpellFamilyFlags & uint64(0x0000000040000000)) && i->GetEffIndex() == EFFECT_INDEX_1) || // Flash of Light + ((spellInfo->SpellFamilyFlags & uint64(0x0000000080000000)) && i->GetEffIndex() == EFFECT_INDEX_0)) // Holy Light { TakenAdvertisedBenefit += (i->GetModifier()->m_amount); // BoL is penalized since 2.3.0 // Note: This forces the caster to keep libram equipped, but works regardless if the BOL is his or not @@ -9039,18 +9039,18 @@ uint32 Unit::SpellHealingBonusTaken(Unit* pCaster, SpellEntry const* spellProto, AuraList const& mHealingGet = GetAurasByType(SPELL_AURA_MOD_HEALING_RECEIVED); for (auto i : mHealingGet) - if (i->isAffectedOnSpell(spellProto)) + if (i->isAffectedOnSpell(spellInfo)) TakenTotalMod *= (i->GetModifier()->m_amount + 100.0f) / 100.0f; for (auto i : GetScriptedLocationAuras(SCRIPT_LOCATION_SPELL_HEALING_TAKEN)) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; i->OnDamageCalculate(this, TakenAdvertisedBenefit, TakenTotalMod); } // apply benefit affected by spell power implicit coeffs and spell level penalties - TakenTotal = pCaster->SpellBonusWithCoeffs(spellProto, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false, SCALE_SPELLPOWER_HEALING); + TakenTotal = pCaster->SpellBonusWithCoeffs(spellInfo, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false, SCALE_SPELLPOWER_HEALING); // use float as more appropriate for negative values and percent applying float heal = (healamount + TakenTotal * int32(stack)) * TakenTotalMod; @@ -9261,20 +9261,20 @@ uint32 Unit::GetMechanicImmunityMask() const * Calculates caster part of melee damage bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack, bool flat) +uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, DamageEffectType damagetype, uint32 stack, bool flat) { if (!victim || pdamage == 0) return pdamage; // Some spells don't benefit from done mods - if (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) + if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) return pdamage; // differentiate for weapon damage based spells - bool isWeaponDamageBasedSpell = !(spellProto && (damagetype == DOT || IsSpellHaveEffect(spellProto, SPELL_EFFECT_SCHOOL_DAMAGE))); + bool isWeaponDamageBasedSpell = !(spellInfo && (damagetype == DOT || IsSpellHaveEffect(spellInfo, SPELL_EFFECT_SCHOOL_DAMAGE))); Item* pWeapon = GetTypeId() == TYPEID_PLAYER ? ((Player*)this)->GetWeaponForAttack(attType, true, false) : nullptr; uint32 creatureTypeMask = victim->GetCreatureTypeMask(); - schoolMask = ((spellProto && schoolMask != spellProto->SchoolMask) ? SpellSchoolMask(spellProto->SchoolMask) : schoolMask); + schoolMask = ((spellInfo && schoolMask != spellInfo->SchoolMask) ? SpellSchoolMask(spellInfo->SchoolMask) : schoolMask); // FLAT damage bonus auras // ======================= @@ -9282,7 +9282,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType int32 APbonus = 0; // ..done flat, already included in weapon damage based spells - if (!isWeaponDamageBasedSpell || (spellProto && (schoolMask &~ SPELL_SCHOOL_MASK_NORMAL) != 0)) + if (!isWeaponDamageBasedSpell || (spellInfo && (schoolMask &~ SPELL_SCHOOL_MASK_NORMAL) != 0)) { AuraList const& mModDamageDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_DONE); for (auto i : mModDamageDone) @@ -9318,7 +9318,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType // ..done pct, already included in weapon damage based spells if (!isWeaponDamageBasedSpell) { - if (!spellProto || !spellProto->HasAttribute(SPELL_ATTR_EX6_IGNORE_CASTER_DAMAGE_MODIFIERS)) + if (!spellInfo || !spellInfo->HasAttribute(SPELL_ATTR_EX6_IGNORE_CASTER_DAMAGE_MODIFIERS)) { AuraList const& mModDamagePercentDone = GetAurasByType(SPELL_AURA_MOD_DAMAGE_PERCENT_DONE); for (auto i : mModDamagePercentDone) @@ -9354,13 +9354,13 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType DoneTotalMod *= (i->GetModifier()->m_amount + 100.0f) / 100.0f; } - if (spellProto) + if (spellInfo) { // dummies AuraList const& auraDummy = owner->GetAurasByType(SPELL_AURA_DUMMY); for (auto i : auraDummy) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; switch (i->GetSpellProto()->Id) { @@ -9382,7 +9382,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType AuraList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (auto i : mOverrideClassScript) { - if (!(i->isAffectedOnSpell(spellProto))) + if (!(i->isAffectedOnSpell(spellInfo))) continue; switch (i->GetMiscValue()) { @@ -9425,10 +9425,10 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType } } - if (spellProto) + if (spellInfo) { // Frost Strike - if (spellProto->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellProto->SpellFamilyFlags & uint64(0x0000000400000000)) + if (spellInfo->SpellFamilyName == SPELLFAMILY_DEATHKNIGHT && spellInfo->SpellFamilyFlags & uint64(0x0000000400000000)) { // search disease bool found = false; @@ -9457,7 +9457,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType } } // Glyph of Steady Shot (Steady Shot check) - else if (spellProto->SpellFamilyName == SPELLFAMILY_HUNTER && spellProto->SpellFamilyFlags & uint64(0x0000000100000000)) + else if (spellInfo->SpellFamilyName == SPELLFAMILY_HUNTER && spellInfo->SpellFamilyFlags & uint64(0x0000000100000000)) { // search for glyph dummy aura if (Aura* aur = GetDummyAura(56826)) @@ -9468,7 +9468,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType for (auto i : GetScriptedLocationAuras(SCRIPT_LOCATION_MELEE_DAMAGE_DONE)) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; i->OnDamageCalculate(victim, DoneFlat, DoneTotalMod); } @@ -9480,16 +9480,16 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType float DoneTotal = 0.0f; // scaling of non weapon based spells - if (!isWeaponDamageBasedSpell || (spellProto && (schoolMask &~ SPELL_SCHOOL_MASK_NORMAL) !=0)) + if (!isWeaponDamageBasedSpell || (spellInfo && (schoolMask &~ SPELL_SCHOOL_MASK_NORMAL) !=0)) { // apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties - DoneTotal = SpellBonusWithCoeffs(spellProto, DoneTotal, DoneFlat, APbonus, damagetype, true); + DoneTotal = SpellBonusWithCoeffs(spellInfo, DoneTotal, DoneFlat, APbonus, damagetype, true); } // weapon damage based spells else if (isWeaponDamageBasedSpell && (APbonus || DoneFlat)) { // have to add AP here to melee/spells because weapon damage is generic and this AP bonus is target specific - bool normalized = spellProto ? IsSpellHaveEffect(spellProto, SPELL_EFFECT_NORMALIZED_WEAPON_DMG) : false; + bool normalized = spellInfo ? IsSpellHaveEffect(spellInfo, SPELL_EFFECT_NORMALIZED_WEAPON_DMG) : false; float baseValue = int32(APbonus / 14.0f * GetAPMultiplier(attType, normalized)); // for weapon damage based spells we still have to apply damage done percent mods @@ -9514,10 +9514,10 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod; // apply spellmod to Done damage - if (spellProto) + if (spellInfo) { if (Player* modOwner = GetSpellModOwner()) - modOwner->ApplySpellMod(spellProto->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); + modOwner->ApplySpellMod(spellInfo->Id, damagetype == DOT ? SPELLMOD_DOT : SPELLMOD_DAMAGE, tmpDamage); } // bonus result can be negative @@ -9528,21 +9528,21 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType * Calculates target part of melee damage bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellProto, DamageEffectType damagetype, uint32 stack, bool flat) +uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, DamageEffectType damagetype, uint32 stack, bool flat) { if (pdamage == 0) return pdamage; - if (spellProto && spellProto->HasAttribute(SPELL_ATTR_EX4_IGNORE_DAMAGE_TAKEN_MODIFIERS)) + if (spellInfo && spellInfo->HasAttribute(SPELL_ATTR_EX4_IGNORE_DAMAGE_TAKEN_MODIFIERS)) return pdamage; // differentiate for weapon damage based spells - bool isWeaponDamageBasedSpell = !(spellProto && (damagetype == DOT || IsSpellHaveEffect(spellProto, SPELL_EFFECT_SCHOOL_DAMAGE))); - schoolMask = ((spellProto && schoolMask != spellProto->SchoolMask) ? SpellSchoolMask(spellProto->SchoolMask) : schoolMask); - uint32 mechanicMask = spellProto ? GetAllSpellMechanicMask(spellProto) : 0; + bool isWeaponDamageBasedSpell = !(spellInfo && (damagetype == DOT || IsSpellHaveEffect(spellInfo, SPELL_EFFECT_SCHOOL_DAMAGE))); + schoolMask = ((spellInfo && schoolMask != spellInfo->SchoolMask) ? SpellSchoolMask(spellInfo->SchoolMask) : schoolMask); + uint32 mechanicMask = spellInfo ? GetAllSpellMechanicMask(spellInfo) : 0; // Shred also have bonus as MECHANIC_BLEED damages - if (spellProto && spellProto->SpellFamilyName == SPELLFAMILY_DRUID && spellProto->SpellFamilyFlags & uint64(0x00008000)) + if (spellInfo && spellInfo->SpellFamilyName == SPELLFAMILY_DRUID && spellInfo->SpellFamilyFlags & uint64(0x00008000)) mechanicMask |= (1 << (MECHANIC_BLEED - 1)); // FLAT damage bonus auras @@ -9575,10 +9575,10 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackTyp TakenTotalMod *= GetTotalAuraMultiplier(SPELL_AURA_MOD_MELEE_DAMAGE_TAKEN_PCT); // ..taken pct (aoe avoidance) - if (spellProto && (IsAreaOfEffectSpell(spellProto) || spellProto->HasAttribute(SPELL_ATTR_EX5_TREAT_AS_AREA_EFFECT))) + if (spellInfo && (IsAreaOfEffectSpell(spellInfo) || spellInfo->HasAttribute(SPELL_ATTR_EX5_TREAT_AS_AREA_EFFECT))) { TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_AOE_DAMAGE_AVOIDANCE, schoolMask); - if (caster && !caster->IsPlayerControlled() || spellProto->HasAttribute(SPELL_ATTR_EX7_TREAT_AS_NPC_AOE)) + if (caster && !caster->IsPlayerControlled() || spellInfo->HasAttribute(SPELL_ATTR_EX7_TREAT_AS_NPC_AOE)) TakenTotalMod *= GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CREATURE_AOE_DAMAGE_AVOIDANCE, schoolMask); } @@ -9611,11 +9611,11 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackTyp } } - if (spellProto) + if (spellInfo) { for (auto i : GetScriptedLocationAuras(SCRIPT_LOCATION_MELEE_DAMAGE_TAKEN)) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->isAffectedOnSpell(spellInfo)) continue; i->OnDamageCalculate(this, TakenAdvertisedBenefit, TakenTotalMod); } @@ -9625,11 +9625,11 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackTyp // ================= // scaling of non weapon based spells - if (!isWeaponDamageBasedSpell || (spellProto && (schoolMask &~ SPELL_SCHOOL_MASK_NORMAL) != 0)) + if (!isWeaponDamageBasedSpell || (spellInfo && (schoolMask &~ SPELL_SCHOOL_MASK_NORMAL) != 0)) { // apply benefit affected by spell power implicit coeffs and spell level penalties if (caster) - TakenAdvertisedBenefit = caster->SpellBonusWithCoeffs(spellProto, 0, TakenAdvertisedBenefit, 0, damagetype, false); + TakenAdvertisedBenefit = caster->SpellBonusWithCoeffs(spellInfo, 0, TakenAdvertisedBenefit, 0, damagetype, false); } if (!flat) @@ -10810,13 +10810,13 @@ bool Unit::SelectHostileTarget() //====================================================================== //====================================================================== //====================================================================== -int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMask, int32 duration, Unit const* caster) +int32 Unit::CalculateAuraDuration(SpellEntry const* spellInfo, uint32 effectMask, int32 duration, Unit const* caster) { if (duration <= 0) return duration; int32 mechanicMod = 0; - uint32 mechanicMask = GetSpellMechanicMask(spellProto, effectMask); + uint32 mechanicMask = GetSpellMechanicMask(spellInfo, effectMask); for (int32 mechanic = FIRST_MECHANIC; mechanic < MAX_MECHANIC; ++mechanic) { @@ -10832,10 +10832,10 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas int32 dispelMod = 0; int32 dmgClassMod = 0; - if (!IsPositiveSpell(spellProto)) + if (!IsPositiveSpell(spellInfo)) { - dispelMod = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL, spellProto->Dispel); - dmgClassMod = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS, spellProto->DmgClass); + dispelMod = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_EFFECTS_BY_DISPEL, spellInfo->Dispel); + dmgClassMod = GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_DURATION_OF_MAGIC_EFFECTS, spellInfo->DmgClass); } int32 durationMod = std::min(mechanicMod, std::min(dispelMod, dmgClassMod)); @@ -10850,11 +10850,11 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas if (caster == this) { - switch (spellProto->SpellFamilyName) + switch (spellInfo->SpellFamilyName) { case SPELLFAMILY_DRUID: // Thorns - if (spellProto->SpellIconID == 53 && (spellProto->SpellFamilyFlags & uint64(0x0000000000000100))) + if (spellInfo->SpellIconID == 53 && (spellInfo->SpellFamilyFlags & uint64(0x0000000000000100))) { // Glyph of Thorns if (Aura* aur = GetAura(57862, EFFECT_INDEX_0)) @@ -10863,14 +10863,14 @@ int32 Unit::CalculateAuraDuration(SpellEntry const* spellProto, uint32 effectMas break; case SPELLFAMILY_PALADIN: // Blessing of Might - if (spellProto->SpellIconID == 298 && spellProto->SpellFamilyFlags & uint64(0x0000000000000002)) + if (spellInfo->SpellIconID == 298 && spellInfo->SpellFamilyFlags & uint64(0x0000000000000002)) { // Glyph of Blessing of Might if (Aura* aur = GetAura(57958, EFFECT_INDEX_0)) duration += aur->GetModifier()->m_amount * MINUTE * IN_MILLISECONDS; } // Blessing of Wisdom - else if (spellProto->SpellIconID == 306 && spellProto->SpellFamilyFlags & uint64(0x0000000000010000)) + else if (spellInfo->SpellIconID == 306 && spellInfo->SpellFamilyFlags & uint64(0x0000000000010000)) { // Glyph of Blessing of Wisdom if (Aura* aur = GetAura(57979, EFFECT_INDEX_0)) @@ -13084,7 +13084,7 @@ void Unit::StopAttackFaction(uint32 faction_id) CallForAllControlledUnits(StopAttackFactionHelper(faction_id), CONTROLLED_PET | CONTROLLED_GUARDIANS | CONTROLLED_CHARM); } -bool Unit::IsIgnoreUnitState(SpellEntry const* spell, IgnoreUnitState ignoreState) const +bool Unit::IsIgnoreUnitState(SpellEntry const* spellInfo, IgnoreUnitState ignoreState) const { Unit::AuraList const& stateAuras = GetAurasByType(SPELL_AURA_IGNORE_UNIT_STATE); for (auto stateAura : stateAuras) @@ -13095,7 +13095,7 @@ bool Unit::IsIgnoreUnitState(SpellEntry const* spell, IgnoreUnitState ignoreStat if (ignoreState == IGNORE_UNIT_TARGET_NON_FROZEN) return true; - if (stateAura->isAffectedOnSpell(spell)) + if (stateAura->isAffectedOnSpell(spellInfo)) return true; } }