aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2024-02-11 00:58:21 +0100
committerShauren <shauren.trinity@gmail.com>2024-02-11 00:58:21 +0100
commitb4064d38c83bc26efa20a248426a9b8cfea6793f (patch)
treefb433e67f1b2733ac4efb45321f6bf3572e2056f /src
parent9267ac27dd0e006b04b7dc70ca91b91e2f4d5476 (diff)
Core/Spells: Allow spells with SPELL_DAMAGE_CLASS_NONE to crit
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Unit/Unit.cpp31
-rw-r--r--src/server/game/Entities/Unit/Unit.h2
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp4
-rw-r--r--src/server/game/Spells/SpellMgr.cpp14
4 files changed, 25 insertions, 26 deletions
diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp
index 73bd1e4697c..7ca7718fe39 100644
--- a/src/server/game/Entities/Unit/Unit.cpp
+++ b/src/server/game/Entities/Unit/Unit.cpp
@@ -360,7 +360,7 @@ Unit::Unit(bool isWorldObject) :
m_modMeleeHitChance = 0.0f;
m_modRangedHitChance = 0.0f;
m_modSpellHitChance = 0.0f;
- m_baseSpellCritChance = 5;
+ m_baseSpellCritChance = 5.0f;
m_speed_rate.fill(1.0f);
@@ -6914,15 +6914,29 @@ float Unit::SpellCritChanceDone(Spell* spell, AuraEffect const* aurEff, SpellSch
float crit_chance = 0.0f;
switch (spellInfo->DmgClass)
{
+ case SPELL_DAMAGE_CLASS_NONE:
case SPELL_DAMAGE_CLASS_MAGIC:
{
- if (schoolMask & SPELL_SCHOOL_MASK_NORMAL)
- crit_chance = 0.0f;
- // For other schools
- else if (Player const* thisPlayer = ToPlayer())
- crit_chance = thisPlayer->m_activePlayerData->SpellCritPercentage;
- else
- crit_chance = (float)m_baseSpellCritChance;
+ auto getMagicCritChance = [&]
+ {
+ if (Player const* thisPlayer = ToPlayer())
+ return *thisPlayer->m_activePlayerData->SpellCritPercentage;
+
+ 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;
+ }
break;
}
case SPELL_DAMAGE_CLASS_MELEE:
@@ -6931,7 +6945,6 @@ float Unit::SpellCritChanceDone(Spell* spell, AuraEffect const* aurEff, SpellSch
crit_chance += GetUnitCriticalChanceDone(attackType);
break;
}
- case SPELL_DAMAGE_CLASS_NONE:
default:
return 0.0f;
}
diff --git a/src/server/game/Entities/Unit/Unit.h b/src/server/game/Entities/Unit/Unit.h
index 2bd5dad9b24..7e177193a9b 100644
--- a/src/server/game/Entities/Unit/Unit.h
+++ b/src/server/game/Entities/Unit/Unit.h
@@ -1456,7 +1456,7 @@ class TC_GAME_API Unit : public WorldObject
float m_modMeleeHitChance;
float m_modRangedHitChance;
float m_modSpellHitChance;
- int32 m_baseSpellCritChance;
+ float m_baseSpellCritChance;
std::array<uint32, MAX_ATTACK> m_baseAttackSpeed;
std::array<float, MAX_ATTACK> m_modAttackSpeedPct;
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index fad5900f433..e86637c6780 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -4226,7 +4226,7 @@ void AuraEffect::HandleModSpellCritChance(AuraApplication const* aurApp, uint8 m
if (target->GetTypeId() == TYPEID_PLAYER)
target->ToPlayer()->UpdateSpellCritChance();
else
- target->m_baseSpellCritChance += (apply) ? GetAmount() : -GetAmount();
+ target->m_baseSpellCritChance += apply ? GetAmount() : -GetAmount();
}
void AuraEffect::HandleAuraModCritPct(AuraApplication const* aurApp, uint8 mode, bool apply) const
@@ -4238,7 +4238,7 @@ void AuraEffect::HandleAuraModCritPct(AuraApplication const* aurApp, uint8 mode,
if (target->GetTypeId() != TYPEID_PLAYER)
{
- target->m_baseSpellCritChance += (apply) ? GetAmount() : -GetAmount();
+ target->m_baseSpellCritChance += apply ? GetAmount() : -GetAmount();
return;
}
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 621a13e8124..16b010ba2eb 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -3481,20 +3481,6 @@ void SpellMgr::LoadSpellInfoCorrections()
});
}
- // Allows those to crit
- ApplySpellFix({
- 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
- 373462 // Crystalline Reflection HEAL
- }, [](SpellInfo* spellInfo)
- {
- // We need more spells to find a general way (if there is any)
- spellInfo->DmgClass = SPELL_DAMAGE_CLASS_MAGIC;
- });
-
ApplySpellFix({
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)