aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-02-21 13:16:55 +0100
committerShauren <shauren.trinity@gmail.com>2024-02-21 13:16:55 +0100
commitc8bd6f5da3d03007a9be9bda30aadddb5573ec9d (patch)
tree4672b4d9405fb7716f66ebb243daf0e7a1163790
parent305cb9a81a1567759e4e3b3adcc4c6ba0b128df7 (diff)
Core/Spells: Fixed incorrect switch logic in Unit::SpellCritChanceDone
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp22
1 files changed, 10 insertions, 12 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 74297bc5fb4..468e8e8bb3e 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -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: