diff --git a/Source/Game/Entities/Unit/Unit.Fields.cs b/Source/Game/Entities/Unit/Unit.Fields.cs index 0914fad81..077bd2952 100644 --- a/Source/Game/Entities/Unit/Unit.Fields.cs +++ b/Source/Game/Entities/Unit/Unit.Fields.cs @@ -53,7 +53,7 @@ namespace Game.Entities public float ModRangedHitChance { get; set; } public float ModSpellHitChance { get; set; } public bool m_canDualWield; - public int BaseSpellCritChance { get; set; } + public float BaseSpellCritChance { get; set; } public uint RegenTimer { get; set; } uint _lastExtraAttackSpell; diff --git a/Source/Game/Entities/Unit/Unit.Spells.cs b/Source/Game/Entities/Unit/Unit.Spells.cs index 039628985..0fa68e088 100644 --- a/Source/Game/Entities/Unit/Unit.Spells.cs +++ b/Source/Game/Entities/Unit/Unit.Spells.cs @@ -615,23 +615,36 @@ namespace Game.Entities float crit_chance = 0.0f; switch (spellInfo.DmgClass) { + case SpellDmgClass.None: case SpellDmgClass.Magic: { - if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal)) - crit_chance = 0.0f; - // For other schools - else if (IsTypeId(TypeId.Player)) - crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage; - else - crit_chance = BaseSpellCritChance; + var getMagicCritChance = float () => + { + Player thisPlayer = ToPlayer(); + if (thisPlayer != null) + return thisPlayer.m_activePlayerData.SpellCritPercentage; + + 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; + } break; } case SpellDmgClass.Melee: case SpellDmgClass.Ranged: crit_chance += GetUnitCriticalChanceDone(attackType); break; - - case SpellDmgClass.None: default: return 0f; } diff --git a/Source/Game/Entities/Unit/Unit.cs b/Source/Game/Entities/Unit/Unit.cs index 76ba3823b..3b6f5d2d5 100644 --- a/Source/Game/Entities/Unit/Unit.cs +++ b/Source/Game/Entities/Unit/Unit.cs @@ -63,7 +63,7 @@ namespace Game.Entities ModMeleeHitChance = 0.0f; ModRangedHitChance = 0.0f; ModSpellHitChance = 0.0f; - BaseSpellCritChance = 5; + BaseSpellCritChance = 5.0f; for (byte i = 0; i < (int)UnitMoveType.Max; ++i) m_speed_rate[i] = 1.0f; diff --git a/Source/Game/Spells/Auras/AuraEffect.cs b/Source/Game/Spells/Auras/AuraEffect.cs index 326f9c210..737031a6e 100644 --- a/Source/Game/Spells/Auras/AuraEffect.cs +++ b/Source/Game/Spells/Auras/AuraEffect.cs @@ -3829,7 +3829,7 @@ namespace Game.Spells if (target.IsTypeId(TypeId.Player)) target.ToPlayer().UpdateSpellHitChances(); else - target.ModSpellHitChance += (apply) ? GetAmount() : (-GetAmount()); + target.ModSpellHitChance += apply ? GetAmount() : (-GetAmount()); } [AuraEffectHandler(AuraType.ModSpellCritChance)] @@ -3843,7 +3843,7 @@ namespace Game.Spells if (target.IsTypeId(TypeId.Player)) target.ToPlayer().UpdateSpellCritChance(); else - target.BaseSpellCritChance += (apply) ? GetAmount() : -GetAmount(); + target.BaseSpellCritChance += apply ? GetAmount() : -GetAmount(); } [AuraEffectHandler(AuraType.ModCritPct)] @@ -3856,7 +3856,7 @@ namespace Game.Spells if (!target.IsTypeId(TypeId.Player)) { - target.BaseSpellCritChance += (apply) ? GetAmount() : -GetAmount(); + target.BaseSpellCritChance += apply ? GetAmount() : -GetAmount(); return; } diff --git a/Source/Game/Spells/SpellManager.cs b/Source/Game/Spells/SpellManager.cs index fcb1ff613..eb6e41978 100644 --- a/Source/Game/Spells/SpellManager.cs +++ b/Source/Game/Spells/SpellManager.cs @@ -3155,19 +3155,6 @@ namespace Game.Entities }); } - // Allows those to crit - ApplySpellFix(new[] { - 379, // Earth Shield - 71607, // Item - Bauble of True Blood 10m - 71646, // Item - Bauble of True Blood 25m - 71610, // Item - Althor's Abacus trigger 10m - 71641 // Item - Althor's Abacus trigger 25m - }, spellInfo => - { - // We need more spells to find a general way (if there is any) - spellInfo.DmgClass = SpellDmgClass.Magic; - }); - ApplySpellFix(new[] { 63026, // Summon Aspirant Test NPC (HACK: Target shouldn't be changed) 63137 // Summon Valiant Test (HACK: Target shouldn't be changed; summon position should be untied from spell destination)