Skip to content

Commit b008096

Browse files
committed
Core/Units: only grant 50% crit damage bonus for magical periodic effects originating from ranged attacks
supercedes #463
1 parent db7998a commit b008096

3 files changed

Lines changed: 16 additions & 8 deletions

File tree

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7003,21 +7003,29 @@ float Unit::SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo,
70037003
return std::max(crit_chance, 0.0f);
70047004
}
70057005

7006-
/*static*/ uint32 Unit::SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage)
7006+
/*static*/ uint32 Unit::SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage, bool periodicDamage /*= false*/)
70077007
{
70087008
// Calculate critical bonus
70097009
int32 crit_bonus = damage;
70107010
float crit_mod = 0.0f;
70117011

70127012
switch (spellProto->DmgClass)
70137013
{
7014-
case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100%
7015-
case SPELL_DAMAGE_CLASS_RANGED:
7016-
/// @todo write here full calculation for melee/ranged spells
7014+
// Spells which are either marked as ranged or melee damage, will deal 100% additional damage
7015+
case SPELL_DAMAGE_CLASS_MELEE:
70177016
crit_bonus += damage;
70187017
break;
7018+
case SPELL_DAMAGE_CLASS_RANGED:
7019+
// Ranged spells which have magic periodic damage effect on the other hand, only deal 50% damage, just like spells
7020+
// This is a very specific case that is currently only known for Hunter spells, such as Serpent Sting and Black Arrow
7021+
if (periodicDamage && (spellProto->GetSchoolMask() & SPELL_SCHOOL_MASK_MAGIC) != 0)
7022+
crit_bonus += damage / 2;
7023+
else
7024+
crit_bonus += damage;
7025+
break;
70197026
default:
7020-
crit_bonus += damage / 2; // for spells is 50%
7027+
// Magic spells will simply deal 50% additional crit damage
7028+
crit_bonus += damage / 2;
70217029
break;
70227030
}
70237031

src/server/game/Entities/Unit/Unit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1458,7 +1458,7 @@ class TC_GAME_API Unit : public WorldObject
14581458
bool IsBlockCritical() const;
14591459
float SpellCritChanceDone(SpellInfo const* spellInfo, SpellSchoolMask schoolMask, WeaponAttackType attackType = BASE_ATTACK, bool isPeriodic = false) const;
14601460
float SpellCritChanceTaken(Unit const* caster, SpellInfo const* spellInfo, SpellSchoolMask schoolMask, float doneChance, WeaponAttackType attackType = BASE_ATTACK, bool isPeriodic = false) const;
1461-
static uint32 SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage);
1461+
static uint32 SpellCriticalDamageBonus(Unit const* caster, SpellInfo const* spellProto, uint32 damage, bool periodicDamage = false);
14621462
static uint32 SpellCriticalHealingBonus(Unit const* caster, uint32 damage);
14631463

14641464
uint32 GetCastingTimeForBonus(SpellInfo const* spellProto, DamageEffectType damagetype, uint32 CastingTime) const;

src/server/game/Spells/Auras/SpellAuraEffects.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5839,7 +5839,7 @@ void AuraEffect::HandlePeriodicDamageAurasTick(Unit* target, Unit* caster) const
58395839
crit = roll_chance_f(GetCritChanceFor(caster, target));
58405840

58415841
if (crit)
5842-
damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage);
5842+
damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage, true);
58435843

58445844
uint32 unmitigatedDamage = damage;
58455845

@@ -5928,7 +5928,7 @@ void AuraEffect::HandlePeriodicHealthLeechAuraTick(Unit* target, Unit* caster) c
59285928
crit = roll_chance_f(GetCritChanceFor(caster, target));
59295929

59305930
if (crit)
5931-
damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage);
5931+
damage = Unit::SpellCriticalDamageBonus(caster, m_spellInfo, damage, true);
59325932

59335933
uint32 unmitigatedDamage = damage;
59345934

0 commit comments

Comments
 (0)