Core/Spells: Fixed incorrect switch logic in Unit::SpellCritChanceDone

This commit is contained in:
Shauren
2024-02-21 13:16:55 +01:00
parent 305cb9a81a
commit c8bd6f5da3

View File

@@ -6917,6 +6917,11 @@ float Unit::SpellCritChanceDone(Spell* spell, AuraEffect const* aurEff, SpellSch
case SPELL_DAMAGE_CLASS_NONE:
case SPELL_DAMAGE_CLASS_MAGIC:
{
auto getPhysicalCritChance = [&]
{
return GetUnitCriticalChanceDone(attackType);
};
auto getMagicCritChance = [&]
{
if (Player const* thisPlayer = ToPlayer())
@@ -6925,18 +6930,11 @@ float Unit::SpellCritChanceDone(Spell* spell, AuraEffect const* aurEff, SpellSch
return m_baseSpellCritChance;
};
switch (schoolMask & SPELL_SCHOOL_MASK_NORMAL)
{
case SPELL_SCHOOL_MASK_NORMAL: // physical only
crit_chance = GetUnitCriticalChanceDone(attackType);
break;
case 0: // spell only
crit_chance = getMagicCritChance();
break;
default: // mix of physical and magic
crit_chance = std::max(getMagicCritChance(), GetUnitCriticalChanceDone(attackType));
break;
}
if (schoolMask & SPELL_SCHOOL_MASK_NORMAL)
crit_chance = std::max(crit_chance, getPhysicalCritChance());
if (schoolMask & ~SPELL_SCHOOL_MASK_NORMAL)
crit_chance = std::max(crit_chance, getMagicCritChance());
break;
}
case SPELL_DAMAGE_CLASS_MELEE: