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 ModSpellHitChance { get; set; }
public bool m_canDualWield;
public int BaseSpellCritChance { get; set; }
public float BaseSpellCritChance { get; set; }
public uint RegenTimer { get; set; }
uint _lastExtraAttackSpell;
+22 -9
View File
@@ -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;
}
+1 -1
View File
@@ -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;
+3 -3
View File
@@ -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;
}
-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[] {
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)