diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 1baba6b0c5..81e54584ea 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -1518,27 +1518,13 @@ void Unit::HandleEmoteCommand(uint32 anim_id) SendMessageToSet(&data, true); } -/*static*/ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* spellInfo /*= nullptr*/, int8 effIndex /*= -1*/) +/*static*/ bool Unit::IsDamageReducedByArmor(SpellSchoolMask schoolMask, SpellInfo const* spellInfo /*= nullptr*/) { // only physical spells damage gets reduced by armor if ((schoolMask & SPELL_SCHOOL_MASK_NORMAL) == 0) return false; - if (spellInfo) - { - // there are spells with no specific attribute but they have "ignores armor" in tooltip - if (spellInfo->HasAttribute(SPELL_ATTR0_CU_IGNORE_ARMOR)) - return false; - // bleeding effects are not reduced by armor - if (effIndex != -1) - { - if (spellInfo->Effects[effIndex].ApplyAuraName == SPELL_AURA_PERIODIC_DAMAGE || - spellInfo->Effects[effIndex].Effect == SPELL_EFFECT_SCHOOL_DAMAGE) - if (spellInfo->GetEffectMechanicMask(effIndex) & (1<HasAttribute(SPELL_ATTR0_CU_IGNORE_ARMOR); } // Calculation taken from Paperdollframe.lua (15595) diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h index 4be1913f9b..65a1c57437 100644 --- a/src/server/game/Entities/Unit/Unit.h +++ b/src/server/game/Entities/Unit/Unit.h @@ -1626,7 +1626,7 @@ class TC_GAME_API Unit : public WorldObject bool IsImmunedToDamage(SpellInfo const* spellInfo) const; virtual bool IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index, WorldObject const* caster) const; // redefined in Creature - static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr, int8 effIndex = -1); + static bool IsDamageReducedByArmor(SpellSchoolMask damageSchoolMask, SpellInfo const* spellInfo = nullptr); static uint32 CalcArmorReducedDamage(Unit const* attacker, Unit* victim, const uint32 damage, SpellInfo const* spellInfo, WeaponAttackType attackType = MAX_ATTACK, uint8 attackerLevel = 0); static uint32 CalcSpellResistedDamage(Unit const* attacker, Unit* victim, uint32 damage, SpellSchoolMask schoolMask, SpellInfo const* spellInfo); static void CalcAbsorbResist(DamageInfo& damageInfo); diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp index 73a8d9650d..d958dcce1c 100644 --- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp +++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp @@ -5783,7 +5783,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage); // Calculate armor mitigation - if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex())) + if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo())) { uint32 damageReducedArmor = Unit::CalcArmorReducedDamage(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetAttackType(), GetBase()->GetCasterLevel()); cleanDamage.mitigated_damage += damage - damageReducedArmor; @@ -5873,7 +5873,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage); // Calculate armor mitigation - if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo(), GetEffIndex())) + if (Unit::IsDamageReducedByArmor(GetSpellInfo()->GetSchoolMask(), GetSpellInfo())) { uint32 damageReducedArmor = Unit::CalcArmorReducedDamage(caster, target, damage, GetSpellInfo(), GetSpellInfo()->GetAttackType(), GetBase()->GetCasterLevel()); cleanDamage.mitigated_damage += damage - damageReducedArmor; diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 7048f9c7e7..a73b5faf18 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -2626,7 +2626,6 @@ void SpellMgr::LoadSpellInfoCustomAttributes() { uint32 oldMSTime = getMSTime(); uint32 oldMSTime2 = oldMSTime; - SpellInfo* spellInfo = nullptr; QueryResult result = WorldDatabase.Query("SELECT entry, attributes FROM spell_custom_attr"); @@ -2642,7 +2641,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes() uint32 spellId = fields[0].GetUInt32(); uint32 attributes = fields[1].GetUInt32(); - spellInfo = _GetSpellInfo(spellId); + SpellInfo* spellInfo = _GetSpellInfo(spellId); if (!spellInfo) { TC_LOG_ERROR("sql.sql", "Table `spell_custom_attr` has wrong spell (entry: %u), ignored.", spellId); @@ -2671,14 +2670,17 @@ void SpellMgr::LoadSpellInfoCustomAttributes() TC_LOG_INFO("server.loading", ">> Loaded %u spell custom attributes from DB in %u ms", count, GetMSTimeDiffToNow(oldMSTime2)); } - for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i) + for (SpellInfo* spellInfo : mSpellInfoMap) { - spellInfo = mSpellInfoMap[i]; if (!spellInfo) continue; for (uint8 j = 0; j < MAX_SPELL_EFFECTS; ++j) { + // all bleed effects and spells ignore armor + if (spellInfo->GetEffectMechanicMask(j) & (1 << MECHANIC_BLEED)) + spellInfo->AttributesCu |= SPELL_ATTR0_CU_IGNORE_ARMOR; + switch (spellInfo->Effects[j].ApplyAuraName) { case SPELL_AURA_MOD_POSSESS: @@ -2755,7 +2757,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes() case SPELL_EFFECT_ENCHANT_HELD_ITEM: { // only enchanting profession enchantments procs can stack - if (IsPartOfSkillLine(SKILL_ENCHANTING, i)) + if (IsPartOfSkillLine(SKILL_ENCHANTING, spellInfo->Id)) { uint32 enchantId = spellInfo->Effects[j].MiscValue; SpellItemEnchantmentEntry const* enchant = sSpellItemEnchantmentStore.LookupEntry(enchantId); @@ -2888,10 +2890,9 @@ void SpellMgr::LoadSpellInfoCustomAttributes() spellInfo->_InitializeExplicitTargetMask(); } - // addition for binary spells, ommit spells triggering other spells - for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i) + // addition for binary spells, omit spells triggering other spells + for (SpellInfo* spellInfo : mSpellInfoMap) { - spellInfo = mSpellInfoMap[i]; if (!spellInfo) continue; @@ -2926,9 +2927,8 @@ void SpellMgr::LoadSpellInfoCustomAttributes() } // remove attribute from spells that can't crit - for (uint32 i = 0; i < GetSpellInfoStoreSize(); ++i) + for (SpellInfo* spellInfo : mSpellInfoMap) { - spellInfo = mSpellInfoMap[i]; if (!spellInfo) continue; @@ -2944,9 +2944,9 @@ void SpellMgr::LoadSpellInfoCustomAttributes() { if (liquid->SpellID) { - spellInfo = _GetSpellInfo(liquid->SpellID); - if (spellInfo) - spellInfo->AttributesCu |= SPELL_ATTR0_CU_LIQUID_AURA; + if (uint32 spellId = liquid->SpellID) + if (SpellInfo* spellInfo = _GetSpellInfo(spellId)) + spellInfo->AttributesCu |= SPELL_ATTR0_CU_LIQUID_AURA; } }