From 5fce86ac3779cc7883755def05eb8723c720e80a Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 21 Feb 2024 21:10:45 -0500 Subject: [PATCH] Core/Spells: Fixed incorrect switch logic in Unit::SpellCritChanceDone Port From (https://github.com/TrinityCore/TrinityCore/commit/c8bd6f5da3d03007a9be9bda30aadddb5573ec9d) --- Source/Game/Entities/Unit/Unit.Spells.cs | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 037732aa0..2621e6b1c 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -618,6 +618,11 @@ namespace Game.Entities case SpellDmgClass.None: case SpellDmgClass.Magic: { + var getPhysicalCritChance = float () => + { + return GetUnitCriticalChanceDone(attackType); + }; + var getMagicCritChance = float () => { Player thisPlayer = ToPlayer(); @@ -627,18 +632,11 @@ namespace Game.Entities return BaseSpellCritChance; }; - switch (schoolMask & SpellSchoolMask.Normal) - { - case SpellSchoolMask.Normal: // physical only - crit_chance = GetUnitCriticalChanceDone(attackType); - break; - case 0: // spell only - crit_chance = getMagicCritChance(); - break; - default: // mix of physical and magic - crit_chance = Math.Max(getMagicCritChance(), GetUnitCriticalChanceDone(attackType)); - break; - } + if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal)) + crit_chance = Math.Max(crit_chance, getPhysicalCritChance()); + + if (schoolMask.HasAnyFlag(~SpellSchoolMask.Normal)) + crit_chance = Math.Max(crit_chance, getMagicCritChance()); break; } case SpellDmgClass.Melee: