diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index e0e20e98a5c..a56df633d46 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -683,7 +683,6 @@ ChatCommand* ChatHandler::getCommandTable() { "spam_records", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadExpectedSpamRecords, "", nullptr }, { "spell_affect", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellAffectCommand, "", nullptr }, { "spell_area", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellAreaCommand, "", nullptr }, - { "spell_bonus_data", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellBonusesCommand, "", nullptr }, { "spell_chain", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellChainCommand, "", nullptr }, { "spell_elixir", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellElixirCommand, "", nullptr }, { "spell_learn_spell", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellLearnSpellCommand, "", nullptr }, diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h index 91ca3f56a8d..b5cf75386dd 100644 --- a/src/game/Chat/Chat.h +++ b/src/game/Chat/Chat.h @@ -602,7 +602,6 @@ class ChatHandler bool HandleReloadSkillFishingBaseLevelCommand(char* args); bool HandleReloadSpellAffectCommand(char* args); bool HandleReloadSpellAreaCommand(char* args); - bool HandleReloadSpellBonusesCommand(char* args); bool HandleReloadSpellChainCommand(char* args); bool HandleReloadSpellElixirCommand(char* args); bool HandleReloadSpellLearnSpellCommand(char* args); diff --git a/src/game/Chat/Level3.cpp b/src/game/Chat/Level3.cpp index ba1a17f743a..d87e5e8b363 100644 --- a/src/game/Chat/Level3.cpp +++ b/src/game/Chat/Level3.cpp @@ -276,7 +276,6 @@ bool ChatHandler::HandleReloadAllSpellCommand(char* /*args*/) HandleReloadSpellElixirCommand((char*)"a"); HandleReloadSpellLearnSpellCommand((char*)"a"); HandleReloadSpellProcEventCommand((char*)"a"); - HandleReloadSpellBonusesCommand((char*)"a"); HandleReloadSpellProcItemEnchantCommand((char*)"a"); HandleReloadSpellScriptTargetCommand((char*)"a"); HandleReloadSpellTargetPositionCommand((char*)"a"); @@ -678,14 +677,6 @@ bool ChatHandler::HandleReloadSpellAreaCommand(char* /*args*/) return true; } -bool ChatHandler::HandleReloadSpellBonusesCommand(char* /*args*/) -{ - sLog.outString("Re-Loading Spell Bonus Data..."); - sSpellMgr.LoadSpellBonuses(); - SendGlobalSysMessage("DB table `spell_bonus_data` (spell damage/healing coefficients) reloaded."); - return true; -} - bool ChatHandler::HandleReloadSpellChainCommand(char* /*args*/) { sLog.outString("Re-Loading Spell Chain Data... "); diff --git a/src/game/Chat/debugcmds.cpp b/src/game/Chat/debugcmds.cpp index f663311608a..1486abe9072 100644 --- a/src/game/Chat/debugcmds.cpp +++ b/src/game/Chat/debugcmds.cpp @@ -1293,8 +1293,6 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args) if (!spellEntry) return false; - SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellid); - float direct_calc = CalculateDefaultCoefficient(spellEntry, SPELL_DIRECT_DAMAGE); float dot_calc = CalculateDefaultCoefficient(spellEntry, DOT); @@ -1327,9 +1325,9 @@ bool ChatHandler::HandleDebugSpellCoefsCommand(char* args) char const* dotDamageStr = GetMangosString(LANG_DOT_DAMAGE); PSendSysMessage(LANG_SPELLCOEFS, spellid, isDirectHeal ? directHealStr : directDamageStr, - direct_calc, direct_calc * 1.88f, bonus ? bonus->direct_damage : 0.0f, bonus ? bonus->ap_bonus : 0.0f); + direct_calc, direct_calc * 1.88f, spellEntry->effectBonusCoefficient[0], 0.0f); PSendSysMessage(LANG_SPELLCOEFS, spellid, isDotHeal ? dotHealStr : dotDamageStr, - dot_calc, dot_calc * 1.88f, bonus ? bonus->dot_damage : 0.0f, bonus ? bonus->ap_dot_bonus : 0.0f); + dot_calc, dot_calc * 1.88f, spellEntry->effectBonusCoefficient[0], 0.0f); return true; } diff --git a/src/game/Entities/Unit.cpp b/src/game/Entities/Unit.cpp index b42ad5df643..fd833240898 100644 --- a/src/game/Entities/Unit.cpp +++ b/src/game/Entities/Unit.cpp @@ -1814,7 +1814,7 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage { SpellEntry const* spellInfo = sSpellTemplate.LookupEntry(spellID); SpellNonMeleeDamage spellDamageInfo(this, pVictim, spellInfo->Id, SpellSchoolMask(spellInfo->SchoolMask)); - CalculateSpellDamage(&spellDamageInfo, damage, spellInfo); + CalculateSpellDamage(&spellDamageInfo, damage, spellInfo, EFFECT_INDEX_0); spellDamageInfo.target->CalculateAbsorbResistBlock(this, &spellDamageInfo, spellInfo); Unit::DealDamageMods(this, spellDamageInfo.target, spellDamageInfo.damage, &spellDamageInfo.absorb, SPELL_DIRECT_DAMAGE); SendSpellNonMeleeDamageLog(&spellDamageInfo); @@ -1822,7 +1822,7 @@ uint32 Unit::SpellNonMeleeDamageLog(Unit* pVictim, uint32 spellID, uint32 damage return spellDamageInfo.damage; } -void Unit::CalculateSpellDamage(SpellNonMeleeDamage* spellDamageInfo, int32 damage, SpellEntry const* spellInfo, WeaponAttackType attackType) +void Unit::CalculateSpellDamage(SpellNonMeleeDamage* spellDamageInfo, int32 damage, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, WeaponAttackType attackType) { SpellSchoolMask damageSchoolMask = spellDamageInfo->schoolMask; Unit* pVictim = spellDamageInfo->target; @@ -1844,8 +1844,8 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* spellDamageInfo, int32 dama case SPELL_DAMAGE_CLASS_MELEE: { // Calculate damage bonus - damage = MeleeDamageBonusDone(pVictim, damage, attackType, damageSchoolMask, spellInfo, SPELL_DIRECT_DAMAGE); - damage = pVictim->MeleeDamageBonusTaken(this, damage, attackType, damageSchoolMask, spellInfo, SPELL_DIRECT_DAMAGE); + damage = MeleeDamageBonusDone(pVictim, damage, attackType, damageSchoolMask, spellInfo, effectIndex, SPELL_DIRECT_DAMAGE); + damage = pVictim->MeleeDamageBonusTaken(this, damage, attackType, damageSchoolMask, spellInfo, effectIndex, SPELL_DIRECT_DAMAGE); } break; // Magical Attacks @@ -1853,8 +1853,8 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage* spellDamageInfo, int32 dama case SPELL_DAMAGE_CLASS_MAGIC: { // Calculate damage bonus - damage = SpellDamageBonusDone(pVictim, damageSchoolMask, spellInfo, damage, SPELL_DIRECT_DAMAGE); - damage = pVictim->SpellDamageBonusTaken(this, damageSchoolMask, spellInfo, damage, SPELL_DIRECT_DAMAGE); + damage = SpellDamageBonusDone(pVictim, damageSchoolMask, spellInfo, effectIndex, damage, SPELL_DIRECT_DAMAGE); + damage = pVictim->SpellDamageBonusTaken(this, damageSchoolMask, spellInfo, effectIndex, damage, SPELL_DIRECT_DAMAGE); } break; } @@ -2003,8 +2003,8 @@ void Unit::CalculateMeleeDamage(Unit* pVictim, CalcDamageInfo* calcDamageInfo, W subDamage->damage = CalculateDamage(calcDamageInfo->attackType, false, i); // Add melee damage bonus - subDamage->damage = MeleeDamageBonusDone(calcDamageInfo->target, subDamage->damage, calcDamageInfo->attackType, subDamage->damageSchoolMask, nullptr, DIRECT_DAMAGE, 1, i == 0); - subDamage->damage = calcDamageInfo->target->MeleeDamageBonusTaken(this, subDamage->damage, calcDamageInfo->attackType, subDamage->damageSchoolMask, nullptr, DIRECT_DAMAGE, 1, i == 0); + subDamage->damage = MeleeDamageBonusDone(calcDamageInfo->target, subDamage->damage, calcDamageInfo->attackType, subDamage->damageSchoolMask, nullptr, EFFECT_INDEX_0, DIRECT_DAMAGE, 1, i == 0); + subDamage->damage = calcDamageInfo->target->MeleeDamageBonusTaken(this, subDamage->damage, calcDamageInfo->attackType, subDamage->damageSchoolMask, nullptr, EFFECT_INDEX_0, DIRECT_DAMAGE, 1, i == 0); // Calculate armor reduction if (subDamage->damageSchoolMask == SPELL_SCHOOL_MASK_NORMAL) @@ -7310,7 +7310,7 @@ void Unit::EnergizeBySpell(Unit* victim, SpellEntry const* spellInfo, uint32 dam * @param damagetype what kind of damage * @param donePart calculate for done or taken */ -int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellInfo, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart) +int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellInfo, SpellEffectIndex effectIndex, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart) { // Distribute Damage over multiple effects, reduce by AoE float coeff = 1.0f; @@ -7319,18 +7319,8 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellInfo, int32 total, int32 if (GetTypeId() == TYPEID_UNIT && !((Creature*)this)->IsPet()) coeff = 1.0f; // Check for table values - else if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellInfo->Id)) - { - coeff = damagetype == DOT ? bonus->dot_damage : bonus->direct_damage; - - // apply ap bonus at done part calculation only (it flat total mod so common with taken) - if (donePart && (bonus->ap_bonus || bonus->ap_dot_bonus)) - { - float ap_bonus = damagetype == DOT ? bonus->ap_dot_bonus : bonus->ap_bonus; - - total += int32(ap_bonus * (GetTotalAttackPowerValue(IsSpellRequiresRangedAP(spellInfo) ? RANGED_ATTACK : BASE_ATTACK) + ap_benefit)); - } - } + if (spellInfo->effectBonusCoefficient[effectIndex] > 0) + coeff = spellInfo->effectBonusCoefficient[effectIndex]; // Default calculation else if (benefit) coeff = CalculateDefaultCoefficient(spellInfo, damagetype); @@ -7360,7 +7350,7 @@ int32 Unit::SpellBonusWithCoeffs(SpellEntry const* spellInfo, int32 total, int32 * Calculates caster part of spell damage bonuses, * also includes different bonuses dependent from target auras */ -uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { if (!spellInfo || !victim || damagetype == DIRECT_DAMAGE) return pdamage; @@ -7373,7 +7363,7 @@ uint32 Unit::SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, Spel if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->IsTotem() && ((Totem*)this)->GetTotemType() != TOTEM_STATUE) { if (Unit* owner = GetOwner()) - return owner->SpellDamageBonusDone(victim, schoolMask, spellInfo, pdamage, damagetype); + return owner->SpellDamageBonusDone(victim, schoolMask, spellInfo, effectIndex, pdamage, damagetype); } uint32 creatureTypeMask = victim->GetCreatureTypeMask(); @@ -7427,7 +7417,7 @@ 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(spellInfo, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true); + DoneTotal = SpellBonusWithCoeffs(spellInfo, effectIndex, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true); float tmpDamage = (int32(pdamage) + DoneTotal * int32(stack)) * DoneTotalMod; // apply spellmod to Done damage (flat and pct) @@ -7441,7 +7431,7 @@ 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* spellInfo, uint32 pdamage, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, uint32 pdamage, DamageEffectType damagetype, uint32 stack) { if (!spellInfo || damagetype == DIRECT_DAMAGE || spellInfo->HasAttribute(SPELL_ATTR_EX4_IGNORE_DAMAGE_TAKEN_MODIFIERS)) return pdamage; @@ -7470,7 +7460,7 @@ uint32 Unit::SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, Spe // apply benefit affected by spell power implicit coeffs and spell level penalties if (caster) - TakenTotal = caster->SpellBonusWithCoeffs(spellInfo, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false); + TakenTotal = caster->SpellBonusWithCoeffs(spellInfo, effectIndex, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false); float tmpDamage = (int32(pdamage) + TakenTotal * int32(stack)) * TakenTotalMod; @@ -7534,7 +7524,7 @@ 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* spellInfo, int32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, int32 healamount, DamageEffectType damagetype, uint32 stack) { // Some spells don't benefit from done mods if (spellInfo->HasAttribute(SPELL_ATTR_EX3_IGNORE_CASTER_MODIFIERS)) @@ -7543,7 +7533,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, in // 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, spellInfo, healamount, damagetype, stack); + return owner->SpellHealingBonusDone(victim, spellInfo, effectIndex, healamount, damagetype, stack); // No heal amount for this class spells if (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_NONE) @@ -7574,7 +7564,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, in } // apply ap bonus and benefit affected by spell power implicit coeffs and spell level penalties - DoneTotal = SpellBonusWithCoeffs(spellInfo, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true); + DoneTotal = SpellBonusWithCoeffs(spellInfo, effectIndex, DoneTotal, DoneAdvertisedBenefit, 0, damagetype, true); // use float as more appropriate for negative values and percent applying float heal = (healamount + DoneTotal * int32(stack)) * DoneTotalMod; @@ -7589,7 +7579,7 @@ uint32 Unit::SpellHealingBonusDone(Unit* victim, SpellEntry const* spellInfo, in * Calculates target part of healing spell bonuses, * will be called on each tick for periodic damage over time auras */ -uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellEntry const* spellInfo, int32 healamount, DamageEffectType damagetype, uint32 stack) +uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, int32 healamount, DamageEffectType damagetype, uint32 stack) { float TakenTotalMod = 1.0f; @@ -7624,7 +7614,7 @@ uint32 Unit::SpellHealingBonusTaken(Unit* caster, SpellEntry const* spellInfo, i } // apply benefit affected by spell power implicit coeffs and spell level penalties - TakenTotal = caster->SpellBonusWithCoeffs(spellInfo, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false); + TakenTotal = caster->SpellBonusWithCoeffs(spellInfo, effectIndex, TakenTotal, TakenAdvertisedBenefit, 0, damagetype, false); // use float as more appropriate for negative values and percent applying float heal = (healamount + TakenTotal * int32(stack)) * TakenTotalMod; @@ -7788,7 +7778,7 @@ bool Unit::IsImmuneToSchool(SpellEntry const* spellInfo, uint8 effectMask) 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* spellInfo, DamageEffectType damagetype, uint32 stack, bool flat) +uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, DamageEffectType damagetype, uint32 stack, bool flat) { if (!victim || pdamage == 0) return pdamage; @@ -7886,7 +7876,7 @@ uint32 Unit::MeleeDamageBonusDone(Unit* victim, uint32 pdamage, WeaponAttackType 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(spellInfo, DoneTotal, DoneFlat, APbonus, damagetype, true); + DoneTotal = SpellBonusWithCoeffs(spellInfo, effectIndex, DoneTotal, DoneFlat, APbonus, damagetype, true); } // weapon damage based spells else if (isWeaponDamageBasedSpell && (APbonus || DoneFlat)) @@ -7931,7 +7921,7 @@ 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* spellInfo, DamageEffectType damagetype, uint32 stack, bool flat) +uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, DamageEffectType damagetype, uint32 stack, bool flat) { if (pdamage == 0) return pdamage; @@ -7991,7 +7981,7 @@ uint32 Unit::MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackTyp { // apply benefit affected by spell power implicit coeffs and spell level penalties if (caster) - TakenAdvertisedBenefit = caster->SpellBonusWithCoeffs(spellInfo, 0, TakenAdvertisedBenefit, 0, damagetype, false); + TakenAdvertisedBenefit = caster->SpellBonusWithCoeffs(spellInfo, effectIndex, 0, TakenAdvertisedBenefit, 0, damagetype, false); } if (!flat) diff --git a/src/game/Entities/Unit.h b/src/game/Entities/Unit.h index ef064ad1e67..39b0d45046f 100644 --- a/src/game/Entities/Unit.h +++ b/src/game/Entities/Unit.h @@ -1507,7 +1507,7 @@ class Unit : public WorldObject static bool IsAllowedDamageInArea(Unit* attacker, Unit* victim); - void CalculateSpellDamage(SpellNonMeleeDamage* spellDamageInfo, int32 damage, SpellEntry const* spellInfo, WeaponAttackType attackType = BASE_ATTACK); + void CalculateSpellDamage(SpellNonMeleeDamage* spellDamageInfo, int32 damage, SpellEntry const* spellInfo, SpellEffectIndex effectIndex, WeaponAttackType attackType = BASE_ATTACK); static void DealSpellDamage(Unit* affectiveCaster, SpellNonMeleeDamage* spellDamageInfo, bool durabilityLoss, bool resetLeash); uint32 GetResilienceRatingDamageReduction(uint32 damage, SpellDmgClass dmgClass, bool periodic = false, Powers pwrType = POWER_HEALTH) const; @@ -2192,17 +2192,17 @@ class Unit : public WorldObject void UnsummonAllTotems() const; Unit* SelectMagnetTarget(Unit* victim, Spell* spell = nullptr); - int32 SpellBonusWithCoeffs(SpellEntry const* spellProto, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart); + int32 SpellBonusWithCoeffs(SpellEntry const* spellProto, SpellEffectIndex effectIndex, int32 total, int32 benefit, int32 ap_benefit, DamageEffectType damagetype, bool donePart); int32 SpellBaseDamageBonusDone(SpellSchoolMask schoolMask); int32 SpellBaseDamageBonusTaken(SpellSchoolMask schoolMask) const; - uint32 SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); - uint32 SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, SpellEntry const* spellProto, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); + uint32 SpellDamageBonusDone(Unit* victim, SpellSchoolMask schoolMask, SpellEntry const* spellProto, SpellEffectIndex effectIndex, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); + uint32 SpellDamageBonusTaken(Unit* caster, SpellSchoolMask schoolMask, SpellEntry const* spellProto, SpellEffectIndex effectIndex, uint32 pdamage, DamageEffectType damagetype, uint32 stack = 1); int32 SpellBaseHealingBonusDone(SpellSchoolMask schoolMask); int32 SpellBaseHealingBonusTaken(SpellSchoolMask schoolMask) const; - uint32 SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); - uint32 SpellHealingBonusTaken(Unit* caster, SpellEntry const* spellProto, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); - uint32 MeleeDamageBonusDone(Unit* victim, uint32 damage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellProto = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1, bool flat = true); - uint32 MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellProto = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1, bool flat = true); + uint32 SpellHealingBonusDone(Unit* victim, SpellEntry const* spellProto, SpellEffectIndex effectIndex, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); + uint32 SpellHealingBonusTaken(Unit* caster, SpellEntry const* spellProto, SpellEffectIndex effectIndex, int32 healamount, DamageEffectType damagetype, uint32 stack = 1); + uint32 MeleeDamageBonusDone(Unit* victim, uint32 damage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellProto = nullptr, SpellEffectIndex effectIndex = EFFECT_INDEX_0, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1, bool flat = true); + uint32 MeleeDamageBonusTaken(Unit* caster, uint32 pdamage, WeaponAttackType attType, SpellSchoolMask schoolMask, SpellEntry const* spellProto = nullptr, SpellEffectIndex effectIndex = EFFECT_INDEX_0, DamageEffectType damagetype = DIRECT_DAMAGE, uint32 stack = 1, bool flat = true); enum class SpellProcEventTriggerCheck { diff --git a/src/game/Server/DBCStructure.h b/src/game/Server/DBCStructure.h index 5f1b7411c98..b7a8c37d770 100644 --- a/src/game/Server/DBCStructure.h +++ b/src/game/Server/DBCStructure.h @@ -983,10 +983,11 @@ struct SpellEntry uint32 TotemCategory[MAX_SPELL_TOTEM_CATEGORIES];// 212-213 m_requiredTotemCategoryID uint32 AreaId; // 214 uint32 SchoolMask; // 215 m_schoolMask + float effectBonusCoefficient[MAX_EFFECT_INDEX]; // 216-218 m_effectBonusCoefficient // custom - uint32 IsServerSide; // 216 - uint32 AttributesServerside; // 217 + uint32 IsServerSide; // 219 + uint32 AttributesServerside; // 220 // helpers int32 CalculateSimpleValue(SpellEffectIndex eff) const { return EffectBasePoints[eff] + int32(EffectBaseDice[eff]); } diff --git a/src/game/Server/SQLStorages.cpp b/src/game/Server/SQLStorages.cpp index 8c2189027d9..dfea7a85d98 100644 --- a/src/game/Server/SQLStorages.cpp +++ b/src/game/Server/SQLStorages.cpp @@ -38,7 +38,7 @@ const char WorldTemplatesrcfmt[] = "is"; const char WorldTemplatedstfmt[] = "ii"; const char ConditionsFmt[] = "iiiiiiix"; const char SpellScriptTargetFmt[] = "iiii"; -const char SpellEntryfmt[] = "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiissssssssssssssssssssssssssssssssiiiiiLiiiifffiiiiiiiii"; +const char SpellEntryfmt[] = "iiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiifiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiiffffffiiiiiiiiiiiiiiiiiiiiifffiiiiiiiiiiiiiiifffiiiissssssssssssssssssssssssssssssssiiiiiLiiiifffiiiiiiifffii"; const char SpellConefmt[] = "ii"; const char DungeonEncounterFmt[] = "iiiiiissssssssssssssssii"; const char FactionEntryfmt[] = "iiiiiiiiiiiiiiiiiiiffiissssssssssssssss"; diff --git a/src/game/Spells/Scripts/Scripting/ClassScripts/Priest.cpp b/src/game/Spells/Scripts/Scripting/ClassScripts/Priest.cpp index 09ce77a16f1..06d56e3131d 100644 --- a/src/game/Spells/Scripts/Scripting/ClassScripts/Priest.cpp +++ b/src/game/Spells/Scripts/Scripting/ClassScripts/Priest.cpp @@ -163,7 +163,7 @@ struct PrayerOfMending : public SpellScript { uint32 value = 0; value = spell->CalculateSpellEffectValue(EFFECT_INDEX_0, target, true, false); - value = spell->GetCaster()->SpellHealingBonusDone(target, sSpellTemplate.LookupEntry(41635), value, HEAL); + value = spell->GetCaster()->SpellHealingBonusDone(target, sSpellTemplate.LookupEntry(41635), EFFECT_INDEX_0, value, HEAL); if (aura->GetModifier()->m_amount > (int32)value) return SPELL_FAILED_AURA_BOUNCED; } @@ -176,7 +176,7 @@ struct PrayerOfMending : public SpellScript if (effIdx != EFFECT_INDEX_0) return; uint32 value = spell->GetDamage(); - value = spell->GetCaster()->SpellHealingBonusDone(spell->GetUnitTarget(), sSpellTemplate.LookupEntry(41635), value, HEAL); + value = spell->GetCaster()->SpellHealingBonusDone(spell->GetUnitTarget(), sSpellTemplate.LookupEntry(41635), effIdx, value, HEAL); spell->SetDamage(value); } }; diff --git a/src/game/Spells/Scripts/Scripting/ClassScripts/Shaman.cpp b/src/game/Spells/Scripts/Scripting/ClassScripts/Shaman.cpp index c737b1e9948..b4adbd33123 100644 --- a/src/game/Spells/Scripts/Scripting/ClassScripts/Shaman.cpp +++ b/src/game/Spells/Scripts/Scripting/ClassScripts/Shaman.cpp @@ -97,8 +97,8 @@ struct EarthShield : public AuraScript Unit* target = data.target; if (Unit* caster = data.caster) { - value = caster->SpellHealingBonusDone(target, data.spellProto, value, SPELL_DIRECT_DAMAGE); - value = target->SpellHealingBonusTaken(caster, data.spellProto, value, SPELL_DIRECT_DAMAGE); + value = caster->SpellHealingBonusDone(target, data.spellProto, EFFECT_INDEX_0, value, SPELL_DIRECT_DAMAGE); + value = target->SpellHealingBonusTaken(caster, data.spellProto, EFFECT_INDEX_0, value, SPELL_DIRECT_DAMAGE); } return value; } diff --git a/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp b/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp index d66b66e9632..8508a544e09 100644 --- a/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp +++ b/src/game/Spells/Scripts/Scripting/ClassScripts/Warlock.cpp @@ -105,8 +105,8 @@ struct LifeTap : public SpellScript if (Player* modOwner = caster->GetSpellModOwner()) modOwner->ApplySpellMod(spell->m_spellInfo->Id, SPELLMOD_COST, cost); - int32 dmg = caster->SpellDamageBonusDone(caster, SpellSchoolMask(spell->m_spellInfo->SchoolMask), spell->m_spellInfo, uint32(cost > 0 ? cost : 0), SPELL_DIRECT_DAMAGE); - dmg = caster->SpellDamageBonusTaken(caster, SpellSchoolMask(spell->m_spellInfo->SchoolMask), spell->m_spellInfo, dmg, SPELL_DIRECT_DAMAGE); + int32 dmg = caster->SpellDamageBonusDone(caster, SpellSchoolMask(spell->m_spellInfo->SchoolMask), spell->m_spellInfo, EFFECT_INDEX_0, uint32(cost > 0 ? cost : 0), SPELL_DIRECT_DAMAGE); + dmg = caster->SpellDamageBonusTaken(caster, SpellSchoolMask(spell->m_spellInfo->SchoolMask), spell->m_spellInfo, EFFECT_INDEX_0, dmg, SPELL_DIRECT_DAMAGE); spell->SetScriptValue(dmg); } diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 85fd9f26ae2..a62538063f8 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -6587,7 +6587,7 @@ SpellCastResult Spell::CheckRange(bool strict) return SPELL_CAST_OK; } -int32 Spell::CalculateSpellEffectDamage(Unit* unitTarget, int32 damage, float damageDoneMod) +int32 Spell::CalculateSpellEffectDamage(Unit* unitTarget, int32 damage, float damageDoneMod, SpellEffectIndex effectIndex) { // damage bonus (per damage class) switch (m_spellInfo->DmgClass) @@ -6598,9 +6598,9 @@ int32 Spell::CalculateSpellEffectDamage(Unit* unitTarget, int32 damage, float da { // Calculate damage bonus if (!m_trueCaster->IsGameObject()) - damage = m_caster->MeleeDamageBonusDone(unitTarget, damage, m_attackType, m_spellSchoolMask, m_spellInfo, SPELL_DIRECT_DAMAGE); + damage = m_caster->MeleeDamageBonusDone(unitTarget, damage, m_attackType, m_spellSchoolMask, m_spellInfo, effectIndex, SPELL_DIRECT_DAMAGE); damage *= damageDoneMod; - damage = unitTarget->MeleeDamageBonusTaken(m_trueCaster->IsGameObject() ? nullptr : m_caster, damage, m_attackType, m_spellSchoolMask, m_spellInfo, SPELL_DIRECT_DAMAGE); + damage = unitTarget->MeleeDamageBonusTaken(m_trueCaster->IsGameObject() ? nullptr : m_caster, damage, m_attackType, m_spellSchoolMask, m_spellInfo, effectIndex, SPELL_DIRECT_DAMAGE); } break; // Magical Attacks @@ -6609,9 +6609,9 @@ int32 Spell::CalculateSpellEffectDamage(Unit* unitTarget, int32 damage, float da { // Calculate damage bonus if (!m_trueCaster->IsGameObject()) - damage = m_caster->SpellDamageBonusDone(unitTarget, m_spellSchoolMask, m_spellInfo, damage, SPELL_DIRECT_DAMAGE); + damage = m_caster->SpellDamageBonusDone(unitTarget, m_spellSchoolMask, m_spellInfo, effectIndex, damage, SPELL_DIRECT_DAMAGE); damage *= damageDoneMod; - damage = unitTarget->SpellDamageBonusTaken(m_trueCaster->IsGameObject() ? nullptr : m_caster, m_spellSchoolMask, m_spellInfo, damage, SPELL_DIRECT_DAMAGE); + damage = unitTarget->SpellDamageBonusTaken(m_trueCaster->IsGameObject() ? nullptr : m_caster, m_spellSchoolMask, m_spellInfo, effectIndex, damage, SPELL_DIRECT_DAMAGE); } break; } diff --git a/src/game/Spells/Spell.h b/src/game/Spells/Spell.h index 3ae4e8129ad..711a5b86c1d 100644 --- a/src/game/Spells/Spell.h +++ b/src/game/Spells/Spell.h @@ -494,7 +494,7 @@ class Spell int32 CalculateSpellEffectValue(SpellEffectIndex i, Unit* target, bool maximum = false, bool finalUse = true) { return m_trueCaster->CalculateSpellEffectValue(target, m_spellInfo, i, &m_currentBasePoints[i], maximum, finalUse); } - int32 CalculateSpellEffectDamage(Unit* unitTarget, int32 damage, float damageDoneMod); + int32 CalculateSpellEffectDamage(Unit* unitTarget, int32 damage, float damageDoneMod, SpellEffectIndex effectIndex); static uint32 CalculatePowerCost(SpellEntry const* spellInfo, Unit* caster, Spell* spell = nullptr, Item* castItem = nullptr, bool finalUse = false); bool HaveTargetsForEffect(SpellEffectIndex effect) const; diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp old mode 100755 new mode 100644 index 37cd5c6281d..3c260cf2d71 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -2942,8 +2942,8 @@ void Aura::HandleAuraDummy(bool apply, bool Real) { // Lifebloom ignore stack amount m_modifier.m_amount /= GetStackAmount(); - m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); - m_modifier.m_amount = target->SpellHealingBonusTaken(caster, GetSpellProto(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); + m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), GetEffIndex(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); + m_modifier.m_amount = target->SpellHealingBonusTaken(caster, GetSpellProto(), GetEffIndex(), m_modifier.m_amount, SPELL_DIRECT_DAMAGE); } } } @@ -5027,7 +5027,7 @@ void Aura::HandlePeriodicHeal(bool apply, bool /*Real*/) switch (GetSpellProto()->Id) { case 12939: m_modifier.m_amount = target->GetMaxHealth() / 10; break; // Polymorph Heal Effect - default: m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); break; + default: m_modifier.m_amount = caster->SpellHealingBonusDone(target, GetSpellProto(), GetEffIndex(), m_modifier.m_amount, DOT, GetStackAmount()); break; } } else @@ -5125,12 +5125,12 @@ void Aura::HandlePeriodicDamage(bool apply, bool Real) { // SpellDamageBonusDone for magic spells if (spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE || spellProto->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) - m_modifier.m_amount = caster->SpellDamageBonusDone(target, SpellSchoolMask(GetSpellProto()->SchoolMask), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); + m_modifier.m_amount = caster->SpellDamageBonusDone(target, SpellSchoolMask(GetSpellProto()->SchoolMask), GetSpellProto(), GetEffIndex(), m_modifier.m_amount, DOT, GetStackAmount()); // MeleeDamagebonusDone for weapon based spells else { WeaponAttackType attackType = GetWeaponAttackType(GetSpellProto()); - m_modifier.m_amount = caster->MeleeDamageBonusDone(target, m_modifier.m_amount, attackType, SpellSchoolMask(spellProto->SchoolMask), spellProto, DOT, GetStackAmount()); + m_modifier.m_amount = caster->MeleeDamageBonusDone(target, m_modifier.m_amount, attackType, SpellSchoolMask(spellProto->SchoolMask), spellProto, GetEffIndex(), DOT, GetStackAmount()); } } } @@ -5182,7 +5182,7 @@ void Aura::HandlePeriodicLeech(bool apply, bool /*Real*/) if (!caster) return; - m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), SpellSchoolMask(GetSpellProto()->SchoolMask), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); + m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), SpellSchoolMask(GetSpellProto()->SchoolMask), GetSpellProto(), GetEffIndex(), m_modifier.m_amount, DOT, GetStackAmount()); } } @@ -5220,7 +5220,7 @@ void Aura::HandlePeriodicHealthFunnel(bool apply, bool /*Real*/) if (!caster) return; - m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), SpellSchoolMask(GetSpellProto()->SchoolMask), GetSpellProto(), m_modifier.m_amount, DOT, GetStackAmount()); + m_modifier.m_amount = caster->SpellDamageBonusDone(GetTarget(), SpellSchoolMask(GetSpellProto()->SchoolMask), GetSpellProto(), GetEffIndex(), m_modifier.m_amount, DOT, GetStackAmount()); } } @@ -6748,12 +6748,12 @@ void Aura::PeriodicTick() // SpellDamageBonus for magic spells if ((spellProto->DmgClass == SPELL_DAMAGE_CLASS_NONE && isNotBleed) || spellProto->DmgClass == SPELL_DAMAGE_CLASS_MAGIC) - pdamage = target->SpellDamageBonusTaken(caster, SpellSchoolMask(spellProto->SchoolMask), spellProto, pdamage, DOT, GetStackAmount()); + pdamage = target->SpellDamageBonusTaken(caster, SpellSchoolMask(spellProto->SchoolMask), spellProto, GetEffIndex(), pdamage, DOT, GetStackAmount()); // MeleeDamagebonus for weapon based spells else { WeaponAttackType attackType = GetWeaponAttackType(spellProto); - pdamage = target->MeleeDamageBonusTaken(caster, pdamage, attackType, SpellSchoolMask(spellProto->SchoolMask), spellProto, DOT, GetStackAmount()); + pdamage = target->MeleeDamageBonusTaken(caster, pdamage, attackType, SpellSchoolMask(spellProto->SchoolMask), spellProto, GetEffIndex(), DOT, GetStackAmount()); } pdamage -= target->GetResilienceRatingDamageReduction(pdamage, SpellDmgClass(spellProto->DmgClass), true); @@ -6823,7 +6823,7 @@ void Aura::PeriodicTick() uint32 absorb = 0; int32 resist = 0; - pdamage = target->SpellDamageBonusTaken(pCaster, SpellSchoolMask(spellProto->SchoolMask), spellProto, pdamage, DOT, GetStackAmount()); + pdamage = target->SpellDamageBonusTaken(pCaster, SpellSchoolMask(spellProto->SchoolMask), spellProto, GetEffIndex(), pdamage, DOT, GetStackAmount()); pdamage -= target->GetResilienceRatingDamageReduction(pdamage, SpellDmgClass(spellProto->DmgClass), true); @@ -6868,7 +6868,7 @@ void Aura::PeriodicTick() modOwner->ApplySpellMod(GetId(), SPELLMOD_MULTIPLE_VALUE, multiplier); } - uint32 heal = pCaster->SpellHealingBonusTaken(pCaster, spellProto, int32(new_damage * multiplier), DOT, GetStackAmount()); + uint32 heal = pCaster->SpellHealingBonusTaken(pCaster, spellProto, GetEffIndex(), int32(new_damage * multiplier), DOT, GetStackAmount()); int32 gain = pCaster->DealHeal(pCaster, heal, spellProto); // Health Leech effects do not generate healing aggro @@ -6911,7 +6911,7 @@ void Aura::PeriodicTick() break; } - pdamage = target->SpellHealingBonusTaken(pCaster, spellProto, pdamage, DOT, GetStackAmount()); + pdamage = target->SpellHealingBonusTaken(pCaster, spellProto, GetEffIndex(), pdamage, DOT, GetStackAmount()); DETAIL_FILTER_LOG(LOG_FILTER_PERIODIC_AFFECTS, "PeriodicTick: %s heal of %s for %u health inflicted by %u", GetCasterGuid().GetString().c_str(), target->GetGuidStr().c_str(), pdamage, GetId()); @@ -7136,7 +7136,7 @@ void Aura::PeriodicTick() SpellNonMeleeDamage spellDamageInfo(pCaster, target, spellProto->Id, SpellSchoolMask(spellProto->SchoolMask)); spellDamageInfo.periodicLog = true; - pCaster->CalculateSpellDamage(&spellDamageInfo, gain, spellProto); + pCaster->CalculateSpellDamage(&spellDamageInfo, gain, spellProto, GetEffIndex()); spellDamageInfo.target->CalculateAbsorbResistBlock(pCaster, &spellDamageInfo, spellProto); @@ -8799,9 +8799,9 @@ uint32 Aura::CalculateAuraEffectValue(Unit* caster, Unit* /*target*/, SpellEntry case SPELL_AURA_SCHOOL_ABSORB: { float DoneActualBenefit = 0.0f; - if (SpellBonusEntry const* bonus = sSpellMgr.GetSpellBonusData(spellProto->Id)) + if (spellProto->effectBonusCoefficient[effIdx] > 0) { - DoneActualBenefit = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto)) * bonus->direct_damage; + DoneActualBenefit = caster->SpellBaseHealingBonusDone(GetSpellSchoolMask(spellProto)) * spellProto->effectBonusCoefficient[effIdx]; DoneActualBenefit *= caster->CalculateLevelPenalty(spellProto); value += (int32)DoneActualBenefit; diff --git a/src/game/Spells/SpellEffects.cpp b/src/game/Spells/SpellEffects.cpp index c6061265cde..4c9c1153d2e 100644 --- a/src/game/Spells/SpellEffects.cpp +++ b/src/game/Spells/SpellEffects.cpp @@ -562,7 +562,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex eff_idx) } if (damage >= 0) - m_damagePerEffect[eff_idx] = CalculateSpellEffectDamage(unitTarget, damage, m_damageDoneMultiplier[eff_idx]); + m_damagePerEffect[eff_idx] = CalculateSpellEffectDamage(unitTarget, damage, m_damageDoneMultiplier[eff_idx], eff_idx); } } @@ -2896,7 +2896,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx) + unitTarget->SpellBaseDamageBonusTaken(GetSpellSchoolMask(m_spellInfo)); // Does Amplify Magic/Dampen Magic influence flametongue? If not, the above addition must be removed. float weaponSpeed = float(m_CastItem->GetProto()->Delay) / IN_MILLISECONDS; - bonusDamage = m_caster->SpellBonusWithCoeffs(m_spellInfo, 0, bonusDamage, 0, SPELL_DIRECT_DAMAGE, false); // apply spell coeff + bonusDamage = m_caster->SpellBonusWithCoeffs(m_spellInfo, eff_idx, 0, bonusDamage, 0, SPELL_DIRECT_DAMAGE, false); // apply spell coeff int32 totalDamage = (damage * 0.01 * weaponSpeed) + bonusDamage; m_caster->CastCustomSpell(unitTarget, 10444, &totalDamage, nullptr, nullptr, TRIGGERED_OLD_TRIGGERED, m_CastItem); @@ -3398,8 +3398,8 @@ void Spell::EffectPowerDrain(SpellEffectIndex eff_idx) uint32 curPower = unitTarget->GetPower(powerType); // add spell damage bonus - damage = m_caster->SpellDamageBonusDone(unitTarget, m_spellSchoolMask, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE); - damage = unitTarget->SpellDamageBonusTaken(m_caster, m_spellSchoolMask, m_spellInfo, uint32(damage), SPELL_DIRECT_DAMAGE); + damage = m_caster->SpellDamageBonusDone(unitTarget, m_spellSchoolMask, m_spellInfo, eff_idx, uint32(damage), SPELL_DIRECT_DAMAGE); + damage = unitTarget->SpellDamageBonusTaken(m_caster, m_spellSchoolMask, m_spellInfo, eff_idx, uint32(damage), SPELL_DIRECT_DAMAGE); uint32 power = damage; @@ -3469,7 +3469,7 @@ void Spell::EffectPowerBurn(SpellEffectIndex eff_idx) new_damage = int32(new_damage * multiplier); - m_damagePerEffect[eff_idx] = CalculateSpellEffectDamage(unitTarget, new_damage, m_damageDoneMultiplier[eff_idx]); + m_damagePerEffect[eff_idx] = CalculateSpellEffectDamage(unitTarget, new_damage, m_damageDoneMultiplier[eff_idx], eff_idx); // should use here effect POWER_DRAIN because POWER_BURN is not implemented on client m_spellLog.AddLog(uint32(SPELL_EFFECT_POWER_DRAIN), unitTarget->GetPackGUID(), new_damage, uint32(powertype), multiplier); @@ -3572,9 +3572,9 @@ void Spell::EffectHeal(SpellEffectIndex eff_idx) } } - addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL); + addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, eff_idx, addhealth, HEAL); addhealth *= m_damageDoneMultiplier[eff_idx]; - addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); + addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, eff_idx, addhealth, HEAL); m_healingPerEffect[eff_idx] = addhealth; } @@ -3591,8 +3591,8 @@ void Spell::EffectHealPct(SpellEffectIndex eff_idx) uint32 addhealth = unitTarget->GetMaxHealth() * damage / 100; - addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, addhealth, HEAL); - addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); + addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, eff_idx, addhealth, HEAL); + addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, eff_idx, addhealth, HEAL); m_healingPerEffect[eff_idx] = addhealth; } @@ -3608,8 +3608,8 @@ void Spell::EffectHealMechanical(SpellEffectIndex eff_idx) if (!caster) return; - uint32 addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, damage, HEAL); - addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, addhealth, HEAL); + uint32 addhealth = caster->SpellHealingBonusDone(unitTarget, m_spellInfo, eff_idx, damage, HEAL); + addhealth = unitTarget->SpellHealingBonusTaken(caster, m_spellInfo, eff_idx, addhealth, HEAL); m_healingPerEffect[eff_idx] = addhealth; } @@ -3640,7 +3640,7 @@ void Spell::EffectHealthLeech(SpellEffectIndex eff_idx) uint32 heal = uint32(damage * multiplier); if (m_caster->IsAlive()) { - heal = m_caster->SpellHealingBonusTaken(m_caster, m_spellInfo, heal, HEAL); + heal = m_caster->SpellHealingBonusTaken(m_caster, m_spellInfo, eff_idx, heal, HEAL); // TODO: at hit need to schedule a (delayed) heal effect execution on caster // order of packets for death coil - start, go, delay, dmg log, delay, heal log m_caster->DealHeal(m_caster, heal, m_spellInfo); @@ -5708,7 +5708,7 @@ void Spell::EffectWeaponDmg(SpellEffectIndex eff_idx) bonus = int32(bonus * totalDamagePercentMod); // prevent negative damage - m_damagePerEffect[eff_idx] = CalculateSpellEffectDamage(unitTarget, bonus, m_damageDoneMultiplier[eff_idx]); + m_damagePerEffect[eff_idx] = CalculateSpellEffectDamage(unitTarget, bonus, m_damageDoneMultiplier[eff_idx], eff_idx); // Hemorrhage if (m_spellInfo->IsFitToFamily(SPELLFAMILY_ROGUE, uint64(0x0000000002000000))) diff --git a/src/game/Spells/SpellMgr.cpp b/src/game/Spells/SpellMgr.cpp index 00090a5cde7..024dbaaa9ee 100644 --- a/src/game/Spells/SpellMgr.cpp +++ b/src/game/Spells/SpellMgr.cpp @@ -963,149 +963,6 @@ bool IsCastEndProcModifierAura(SpellEntry const* spellInfo, SpellEffectIndex eff } } -struct DoSpellBonuses -{ - DoSpellBonuses(SpellBonusMap& _spellBonusMap, SpellBonusEntry const& _spellBonus) : spellBonusMap(_spellBonusMap), spellBonus(_spellBonus) {} - void operator()(uint32 spell_id) { spellBonusMap[spell_id] = spellBonus; } - - SpellBonusMap& spellBonusMap; - SpellBonusEntry const& spellBonus; -}; - -void SpellMgr::LoadSpellBonuses() -{ - mSpellBonusMap.clear(); // need for reload case - uint32 count = 0; - // 0 1 2 3 - auto queryResult = WorldDatabase.Query("SELECT entry, direct_bonus, dot_bonus, ap_bonus, ap_dot_bonus FROM spell_bonus_data"); - if (!queryResult) - { - BarGoLink bar(1); - bar.step(); - sLog.outString(">> Loaded %u spell bonus data", count); - sLog.outString(); - return; - } - - BarGoLink bar(queryResult->GetRowCount()); - do - { - Field* fields = queryResult->Fetch(); - bar.step(); - uint32 entry = fields[0].GetUInt32(); - - SpellEntry const* spell = sSpellTemplate.LookupEntry(entry); - if (!spell) - { - sLog.outErrorDb("Spell %u listed in `spell_bonus_data` does not exist", entry); - continue; - } - - uint32 first_id = GetFirstSpellInChain(entry); - - if (first_id != entry) - { - sLog.outErrorDb("Spell %u listed in `spell_bonus_data` is not first rank (%u) in chain", entry, first_id); - // prevent loading since it won't have an effect anyway - continue; - } - - SpellBonusEntry sbe; - - sbe.direct_damage = fields[1].GetFloat(); - sbe.dot_damage = fields[2].GetFloat(); - sbe.ap_bonus = fields[3].GetFloat(); - sbe.ap_dot_bonus = fields[4].GetFloat(); - - bool need_dot = false; - bool need_direct = false; - uint32 x = 0; // count all, including empty, meaning: not all existing effect is DoTs/HoTs - for (int i = 0; i < MAX_EFFECT_INDEX; ++i) - { - if (!spell->Effect[i]) - { - ++x; - continue; - } - - // DoTs/HoTs - switch (spell->EffectApplyAuraName[i]) - { - case SPELL_AURA_PERIODIC_DAMAGE: - case SPELL_AURA_PERIODIC_DAMAGE_PERCENT: - case SPELL_AURA_PERIODIC_LEECH: - case SPELL_AURA_PERIODIC_HEAL: - case SPELL_AURA_OBS_MOD_HEALTH: - case SPELL_AURA_PERIODIC_MANA_LEECH: - case SPELL_AURA_OBS_MOD_MANA: - case SPELL_AURA_POWER_BURN_MANA: - need_dot = true; - ++x; - break; - default: - break; - } - } - - // TODO: maybe add explicit list possible direct damage spell effects... - if (x < MAX_EFFECT_INDEX) - need_direct = true; - - // Check if direct_bonus is needed in `spell_bonus_data` - float direct_calc = 0.0f; - float direct_diff = 1000.0f; // for have big diff if no DB field value - if (sbe.direct_damage) - { - direct_calc = CalculateDefaultCoefficient(spell, SPELL_DIRECT_DAMAGE); - direct_diff = std::abs(sbe.direct_damage - direct_calc); - } - - // Check if dot_bonus is needed in `spell_bonus_data` - float dot_calc = 0.0f; - float dot_diff = 1000.0f; // for have big diff if no DB field value - if (sbe.dot_damage) - { - dot_calc = CalculateDefaultCoefficient(spell, DOT); - dot_diff = std::abs(sbe.dot_damage - dot_calc); - } - - if (direct_diff < 0.02f && !need_dot && !sbe.ap_bonus && !sbe.ap_dot_bonus) - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `direct_bonus` not needed (data from table: %f, calculated %f, difference of %f) and `dot_bonus` also not used", - entry, sbe.direct_damage, direct_calc, direct_diff); - else if (direct_diff < 0.02f && dot_diff < 0.02f && !sbe.ap_bonus && !sbe.ap_dot_bonus) - { - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `direct_bonus` not needed (data from table: %f, calculated %f, difference of %f) and ", - entry, sbe.direct_damage, direct_calc, direct_diff); - sLog.outErrorDb(" ... `dot_bonus` not needed (data from table: %f, calculated %f, difference of %f)", - sbe.dot_damage, dot_calc, dot_diff); - } - else if (!need_direct && dot_diff < 0.02f && !sbe.ap_bonus && !sbe.ap_dot_bonus) - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `dot_bonus` not needed (data from table: %f, calculated %f, difference of %f) and direct also not used", - entry, sbe.dot_damage, dot_calc, dot_diff); - else if (!need_direct && sbe.direct_damage) - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `direct_bonus` not used (spell not have non-periodic affects)", entry); - else if (!need_dot && sbe.dot_damage) - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `dot_bonus` not used (spell not have periodic affects)", entry); - - if (!need_direct && sbe.ap_bonus) - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `ap_bonus` not used (spell not have non-periodic affects)", entry); - else if (!need_dot && sbe.ap_dot_bonus) - sLog.outErrorDb("`spell_bonus_data` entry for spell %u `ap_dot_bonus` not used (spell not have periodic affects)", entry); - - mSpellBonusMap[entry] = sbe; - - // also add to high ranks - DoSpellBonuses worker(mSpellBonusMap, sbe); - doForHighRanks(entry, worker); - - ++count; - } - while (queryResult->NextRow()); - - sLog.outString(">> Loaded %u extra spell bonus data", count); - sLog.outString(); -} - bool SpellMgr::IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellProcEvent, uint32 EventProcFlag, SpellEntry const* spellInfo, uint32 procFlags, uint32 procExtra) { // No extra req need diff --git a/src/game/Spells/SpellMgr.h b/src/game/Spells/SpellMgr.h index b92c9cfddbb..19c8e0ac2dc 100644 --- a/src/game/Spells/SpellMgr.h +++ b/src/game/Spells/SpellMgr.h @@ -2487,16 +2487,7 @@ struct SpellProcEventEntry uint32 cooldown; // hidden cooldown used for some spell proc events, applied to _triggered_spell_ }; -struct SpellBonusEntry -{ - float direct_damage; - float dot_damage; - float ap_bonus; - float ap_dot_bonus; -}; - typedef std::unordered_map SpellProcEventMap; -typedef std::unordered_map SpellBonusMap; #define ELIXIR_BATTLE_MASK 0x01 #define ELIXIR_GUARDIAN_MASK 0x02 @@ -2685,7 +2676,6 @@ inline bool IsProfessionOrRidingSkill(uint32 skill) class SpellMgr { - friend struct DoSpellBonuses; friend struct DoSpellProcEvent; friend struct DoSpellProcItemEnchant; @@ -2956,17 +2946,6 @@ class SpellMgr static bool IsSpellProcEventCanTriggeredBy(SpellProcEventEntry const* spellProcEvent, uint32 EventProcFlag, SpellEntry const* spellInfo, uint32 procFlags, uint32 procExtra); - // Spell bonus data - SpellBonusEntry const* GetSpellBonusData(uint32 spellId) const - { - // Lookup data - SpellBonusMap::const_iterator itr = mSpellBonusMap.find(spellId); - if (itr != mSpellBonusMap.end()) - return &itr->second; - - return nullptr; - } - // Spell target coordinates SpellTargetPosition const* GetSpellTargetPosition(uint32 spell_id) const { @@ -3260,7 +3239,6 @@ class SpellMgr void LoadSpellElixirs(); void LoadSpellProcEvents(); void LoadSpellProcItemEnchant(); - void LoadSpellBonuses(); void LoadSpellTargetPositions(); void LoadSpellThreats(); void LoadSkillLineAbilityMaps(); @@ -3279,7 +3257,6 @@ class SpellMgr SpellThreatMap mSpellThreatMap; SpellProcEventMap mSpellProcEventMap; SpellProcItemEnchantMap mSpellProcItemEnchantMap; - SpellBonusMap mSpellBonusMap; SkillLineAbilityMap mSkillLineAbilityMapBySpellId; SkillLineAbilityMap mSkillLineAbilityMapBySkillId; SkillRaceClassInfoMap mSkillRaceClassInfoMap; diff --git a/src/game/Spells/UnitAuraProcHandler.cpp b/src/game/Spells/UnitAuraProcHandler.cpp index 046016c7801..93db9830251 100644 --- a/src/game/Spells/UnitAuraProcHandler.cpp +++ b/src/game/Spells/UnitAuraProcHandler.cpp @@ -2543,7 +2543,7 @@ SpellAuraProcResult Unit::HandleProcTriggerDamageAuraProc(ProcExecutionData& dat triggeredByAura->GetHolder()->SetProcCooldown(std::chrono::seconds(cooldown), GetMap()->GetCurrentClockTime()); SpellNonMeleeDamage spellDamageInfo(this, victim, spellInfo->Id, SpellSchoolMask(spellInfo->SchoolMask)); - CalculateSpellDamage(&spellDamageInfo, triggeredByAura->GetModifier()->m_amount, spellInfo); + CalculateSpellDamage(&spellDamageInfo, triggeredByAura->GetModifier()->m_amount, spellInfo, triggeredByAura->GetEffIndex()); spellDamageInfo.target->CalculateAbsorbResistBlock(this, &spellDamageInfo, spellInfo); Unit::DealDamageMods(this, spellDamageInfo.target, spellDamageInfo.damage, &spellDamageInfo.absorb, SPELL_DIRECT_DAMAGE); SendSpellNonMeleeDamageLog(&spellDamageInfo); diff --git a/src/game/World/World.cpp b/src/game/World/World.cpp index 212c1b5e9f1..bcae4f6513b 100644 --- a/src/game/World/World.cpp +++ b/src/game/World/World.cpp @@ -985,9 +985,6 @@ void World::SetInitialWorldSettings() sLog.outString("Loading Spell Proc Event conditions..."); sSpellMgr.LoadSpellProcEvents(); - sLog.outString("Loading Spell Bonus Data..."); - sSpellMgr.LoadSpellBonuses(); - sLog.outString("Loading Spell Proc Item Enchant..."); sSpellMgr.LoadSpellProcItemEnchant(); // must be after LoadSpellChains