Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Core/Spells

* refactored the calculations of critical strike amount for damaging spells
* renamed and reimplemented SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE

Closes #2354
  • Loading branch information...
commit 57c042e280146377da4a5508ef36af84f3d738fa 1 parent bd45e59
@Sarjuuk Sarjuuk authored tobmaps committed
View
42 src/server/game/Entities/Unit/Unit.cpp
@@ -1073,10 +1073,11 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
if (attackType == RANGED_ATTACK)
critPctDamageMod += victim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE);
else
- {
critPctDamageMod += victim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE);
- critPctDamageMod += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE);
- }
+
+ // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS
+ critPctDamageMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, GetSpellSchoolMask(spellInfo));
+
// Increase crit damage from SPELL_AURA_MOD_CRIT_PERCENT_VERSUS
critPctDamageMod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, crTypeMask);
@@ -1259,10 +1260,10 @@ void Unit::CalculateMeleeDamage(Unit* victim, uint32 damage, CalcDamageInfo *dam
if (damageInfo->attackType == RANGED_ATTACK)
mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_RANGED_CRIT_DAMAGE);
else
- {
mod += damageInfo->target->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_MELEE_CRIT_DAMAGE);
- mod += GetTotalAuraModifier(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE);
- }
+
+ // Increase crit damage from SPELL_AURA_MOD_CRIT_DAMAGE_BONUS
+ mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, damageInfo->damageSchoolMask);
uint32 crTypeMask = damageInfo->target->GetCreatureTypeMask();
@@ -11201,33 +11202,38 @@ bool Unit::isSpellCrit(Unit* victim, SpellEntry const* spellProto, SpellSchoolMa
uint32 Unit::SpellCriticalDamageBonus(SpellEntry const* spellProto, uint32 damage, Unit* victim)
{
// Calculate critical bonus
- int32 crit_bonus;
+ int32 crit_bonus = damage;
+ int32 crit_mod = 0;
+
switch(spellProto->DmgClass)
{
case SPELL_DAMAGE_CLASS_MELEE: // for melee based spells is 100%
case SPELL_DAMAGE_CLASS_RANGED:
// TODO: write here full calculation for melee/ranged spells
- crit_bonus = damage;
+ crit_bonus += damage;
break;
default:
- crit_bonus = damage / 2; // for spells is 50%
+ crit_bonus += damage / 2; // for spells is 50%
break;
}
+ crit_mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_DAMAGE_BONUS, GetSpellSchoolMask(spellProto));
+
+ if (victim)
+ crit_mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, victim->GetCreatureTypeMask());
+
+ if (crit_bonus != 0)
+ AddPctN(crit_bonus, crit_mod);
+
+ crit_bonus -= damage;
+
// adds additional damage to crit_bonus (from talents)
if (Player* modOwner = GetSpellModOwner())
modOwner->ApplySpellMod(spellProto->Id, SPELLMOD_CRIT_DAMAGE_BONUS, crit_bonus);
- if (victim)
- {
- uint32 creatureTypeMask = victim->GetCreatureTypeMask();
- crit_bonus = int32(crit_bonus * GetTotalAuraMultiplierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, creatureTypeMask));
- }
-
- if (crit_bonus > 0)
- damage += crit_bonus;
+ crit_bonus += damage;
- return damage;
+ return crit_bonus;
}
uint32 Unit::SpellCriticalHealingBonus(SpellEntry const* spellProto, uint32 damage, Unit* victim)
View
2  src/server/game/Spells/Auras/SpellAuraDefines.h
@@ -222,7 +222,7 @@ enum AuraType
SPELL_AURA_MOD_AOE_AVOIDANCE = 160,
SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT = 161,
SPELL_AURA_POWER_BURN_MANA = 162,
- SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE = 163,
+ SPELL_AURA_MOD_CRIT_DAMAGE_BONUS = 163,
SPELL_AURA_164 = 164,
SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS = 165,
SPELL_AURA_MOD_ATTACK_POWER_PCT = 166,
View
2  src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -215,7 +215,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
&AuraEffect::HandleNoImmediateEffect, //160 SPELL_AURA_MOD_AOE_AVOIDANCE implemented in Unit::MagicSpellHitResult
&AuraEffect::HandleNoImmediateEffect, //161 SPELL_AURA_MOD_HEALTH_REGEN_IN_COMBAT
&AuraEffect::HandleNoImmediateEffect, //162 SPELL_AURA_POWER_BURN_MANA implemented in AuraEffect::PeriodicTick
- &AuraEffect::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS_MELEE
+ &AuraEffect::HandleNoImmediateEffect, //163 SPELL_AURA_MOD_CRIT_DAMAGE_BONUS
&AuraEffect::HandleUnused, //164 unused (3.2.0), only one test spell
&AuraEffect::HandleNoImmediateEffect, //165 SPELL_AURA_MELEE_ATTACK_POWER_ATTACKER_BONUS implemented in Unit::MeleeDamageBonus
&AuraEffect::HandleAuraModAttackPowerPercent, //166 SPELL_AURA_MOD_ATTACK_POWER_PCT

1 comment on commit 57c042e

@tobmaps

Also closes #1342

Please sign in to comment.
Something went wrong with that request. Please try again.