Core/Spells: Allow spells with SPELL_DAMAGE_CLASS_NONE to crit

Port From (https://github.com/TrinityCore/TrinityCore/commit/b4064d38c83bc26efa20a248426a9b8cfea6793f)
This commit is contained in:
hondacrx
2024-02-21 17:41:12 -05:00
parent e81d2d4f1f
commit 1806eb52a3
5 changed files with 27 additions and 27 deletions
+1 -1
View File
@@ -53,7 +53,7 @@ namespace Game.Entities
public float ModRangedHitChance { get; set; } public float ModRangedHitChance { get; set; }
public float ModSpellHitChance { get; set; } public float ModSpellHitChance { get; set; }
public bool m_canDualWield; public bool m_canDualWield;
public int BaseSpellCritChance { get; set; } public float BaseSpellCritChance { get; set; }
public uint RegenTimer { get; set; } public uint RegenTimer { get; set; }
uint _lastExtraAttackSpell; uint _lastExtraAttackSpell;
+22 -9
View File
@@ -615,23 +615,36 @@ namespace Game.Entities
float crit_chance = 0.0f; float crit_chance = 0.0f;
switch (spellInfo.DmgClass) switch (spellInfo.DmgClass)
{ {
case SpellDmgClass.None:
case SpellDmgClass.Magic: case SpellDmgClass.Magic:
{ {
if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal)) var getMagicCritChance = float () =>
crit_chance = 0.0f; {
// For other schools Player thisPlayer = ToPlayer();
else if (IsTypeId(TypeId.Player)) if (thisPlayer != null)
crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage; return thisPlayer.m_activePlayerData.SpellCritPercentage;
else
crit_chance = BaseSpellCritChance; 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; break;
} }
case SpellDmgClass.Melee: case SpellDmgClass.Melee:
case SpellDmgClass.Ranged: case SpellDmgClass.Ranged:
crit_chance += GetUnitCriticalChanceDone(attackType); crit_chance += GetUnitCriticalChanceDone(attackType);
break; break;
case SpellDmgClass.None:
default: default:
return 0f; return 0f;
} }
+1 -1
View File
@@ -63,7 +63,7 @@ namespace Game.Entities
ModMeleeHitChance = 0.0f; ModMeleeHitChance = 0.0f;
ModRangedHitChance = 0.0f; ModRangedHitChance = 0.0f;
ModSpellHitChance = 0.0f; ModSpellHitChance = 0.0f;
BaseSpellCritChance = 5; BaseSpellCritChance = 5.0f;
for (byte i = 0; i < (int)UnitMoveType.Max; ++i) for (byte i = 0; i < (int)UnitMoveType.Max; ++i)
m_speed_rate[i] = 1.0f; m_speed_rate[i] = 1.0f;
+3 -3
View File
@@ -3829,7 +3829,7 @@ namespace Game.Spells
if (target.IsTypeId(TypeId.Player)) if (target.IsTypeId(TypeId.Player))
target.ToPlayer().UpdateSpellHitChances(); target.ToPlayer().UpdateSpellHitChances();
else else
target.ModSpellHitChance += (apply) ? GetAmount() : (-GetAmount()); target.ModSpellHitChance += apply ? GetAmount() : (-GetAmount());
} }
[AuraEffectHandler(AuraType.ModSpellCritChance)] [AuraEffectHandler(AuraType.ModSpellCritChance)]
@@ -3843,7 +3843,7 @@ namespace Game.Spells
if (target.IsTypeId(TypeId.Player)) if (target.IsTypeId(TypeId.Player))
target.ToPlayer().UpdateSpellCritChance(); target.ToPlayer().UpdateSpellCritChance();
else else
target.BaseSpellCritChance += (apply) ? GetAmount() : -GetAmount(); target.BaseSpellCritChance += apply ? GetAmount() : -GetAmount();
} }
[AuraEffectHandler(AuraType.ModCritPct)] [AuraEffectHandler(AuraType.ModCritPct)]
@@ -3856,7 +3856,7 @@ namespace Game.Spells
if (!target.IsTypeId(TypeId.Player)) if (!target.IsTypeId(TypeId.Player))
{ {
target.BaseSpellCritChance += (apply) ? GetAmount() : -GetAmount(); target.BaseSpellCritChance += apply ? GetAmount() : -GetAmount();
return; return;
} }
-13
View File
@@ -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[] { ApplySpellFix(new[] {
63026, // Summon Aspirant Test NPC (HACK: Target shouldn't be changed) 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) 63137 // Summon Valiant Test (HACK: Target shouldn't be changed; summon position should be untied from spell destination)