aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrazom62 <none@none>2010-04-25 21:31:55 +0200
committerTrazom62 <none@none>2010-04-25 21:31:55 +0200
commit9b83945c33cb4973ca277668a49bae827bf3d469 (patch)
tree3e77aa5f6a20b521a544a99eb57c2c3fb764f752
parentcf7170f69d394025e255376ab6b6bb8c684980d1 (diff)
Fix resilience update for 3.3.x. Thanks dr.tenma.
Fixes issue #198. --HG-- branch : trunk
-rw-r--r--src/game/SpellAuraEffects.cpp24
-rw-r--r--src/game/Unit.cpp102
-rw-r--r--src/game/Unit.h4
3 files changed, 94 insertions, 36 deletions
diff --git a/src/game/SpellAuraEffects.cpp b/src/game/SpellAuraEffects.cpp
index 51c707ea5a8..df9b1b02214 100644
--- a/src/game/SpellAuraEffects.cpp
+++ b/src/game/SpellAuraEffects.cpp
@@ -1295,9 +1295,15 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
damage -= target->GetSpellCritDamageReduction(damage);
}
- // only from players
- if (IS_PLAYER_GUID(GetCasterGUID()))
- damage -= target->GetSpellDamageReduction(damage);
+ // Reduce damage from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (caster->GetSpellModOwner())
+ if (Player* modOwner = target->GetSpellModOwner())
+ {
+ if (crit)
+ damage -= modOwner->GetSpellCritDamageReduction(damage);
+ damage -= modOwner->GetSpellDamageReduction(damage);
+ }
caster->CalcAbsorbResist(target, GetSpellSchoolMask(GetSpellProto()), DOT, damage, &absorb, &resist, m_spellProto);
@@ -1368,9 +1374,15 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
damage = damageReductedArmor;
}
- // Reduce dot damage from resilience for players.
- if (target->GetTypeId() == TYPEID_PLAYER)
- damage-=target->GetSpellDamageReduction(damage);
+ // Reduce damage from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (caster->GetSpellModOwner())
+ if (Player* modOwner = target->GetSpellModOwner())
+ {
+ if (crit)
+ damage -= modOwner->GetSpellCritDamageReduction(damage);
+ damage -= modOwner->GetSpellDamageReduction(damage);
+ }
caster->CalcAbsorbResist(target, GetSpellSchoolMask(GetSpellProto()), DOT, damage, &absorb, &resist, m_spellProto);
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index be231666d43..9baa91b7fbc 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -1083,13 +1083,8 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
if (critPctDamageMod != 0)
damage = int32(damage * float((100.0f + critPctDamageMod)/100.0f));
-
- // Resilience - reduce crit damage
- if (attackType != RANGED_ATTACK)
- damage -= pVictim->GetMeleeCritDamageReduction(damage);
- else
- damage -= pVictim->GetRangedCritDamageReduction(damage);
}
+
// Spell weapon based damage CAN BE crit & blocked at same time
if (blocked)
{
@@ -1101,6 +1096,24 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
damageInfo->blocked = damage;
damage -= damageInfo->blocked;
}
+
+ // Reduce damage from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ {
+ if (crit)
+ {
+ if (attackType != RANGED_ATTACK)
+ damage -= modOwner->GetMeleeCritDamageReduction(damage);
+ else
+ damage -= modOwner->GetRangedCritDamageReduction(damage);
+ }
+ if (attackType != RANGED_ATTACK)
+ damage -= modOwner->GetMeleeDamageReduction(damage);
+ else
+ damage -= modOwner->GetRangedDamageReduction(damage);
+ }
}
break;
// Magical Attacks
@@ -1110,19 +1123,23 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
// If crit add critical bonus
if (crit)
{
- damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT;
+ damageInfo->HitInfo |= SPELL_HIT_TYPE_CRIT;
damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim);
- // Resilience - reduce crit damage
- damage -= pVictim->GetSpellCritDamageReduction(damage);
}
+
+ // Reduce damage from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ {
+ if (crit)
+ damage -= modOwner->GetSpellCritDamageReduction(damage);
+ damage -= modOwner->GetSpellDamageReduction(damage);
+ }
}
break;
}
- // only from players
- if (GetTypeId() == TYPEID_PLAYER)
- damage -= pVictim->GetSpellDamageReduction(damage);
-
// Calculate absorb resist
if (damage > 0)
{
@@ -1295,10 +1312,20 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
if (mod != 0)
damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod)/100.0f));
- // Resilience - reduce crit damage
- uint32 resilienceReduction = pVictim->GetMeleeCritDamageReduction(damageInfo->damage);
- damageInfo->damage -= resilienceReduction;
- damageInfo->cleanDamage += resilienceReduction;
+ // Reduce damage from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ {
+ uint32 resilienceReduction;
+ if (attackType != RANGED_ATTACK)
+ resilienceReduction = modOwner->GetMeleeCritDamageReduction(damageInfo->damage);
+ else
+ resilienceReduction = modOwner->GetRangedCritDamageReduction(damageInfo->damage);
+
+ damageInfo->damage -= resilienceReduction;
+ damageInfo->cleanDamage += resilienceReduction;
+ }
break;
}
case MELEE_HIT_PARRY:
@@ -1360,9 +1387,20 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
break;
}
- // only from players
- if (GetTypeId() == TYPEID_PLAYER)
- damage -= pVictim->GetMeleeDamageReduction(damage);
+ // Reduce damage from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ {
+ uint32 resilienceReduction;
+ if (attackType != RANGED_ATTACK)
+ resilienceReduction = modOwner->GetMeleeDamageReduction(damageInfo->damage);
+ else
+ resilienceReduction = modOwner->GetRangedDamageReduction(damageInfo->damage);
+
+ damageInfo->damage -= resilienceReduction;
+ damageInfo->cleanDamage += resilienceReduction;
+ }
// Calculate absorb resist
if (int32(damageInfo->damage) > 0)
@@ -3101,13 +3139,18 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVict
// reduce crit chance from Rating for players
if (attackType != RANGED_ATTACK)
{
- crit -= pVictim->GetMeleeCritChanceReduction();
- // Glyph of barkskin
- if (pVictim->HasAura(63057) && pVictim->HasAura(22812))
- crit-=25.0f;
+ // Reduce crit chance from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ crit -= modOwner->GetMeleeCritChanceReduction();
+ // Glyph of barkskin
+ if (pVictim->HasAura(63057) && pVictim->HasAura(22812))
+ crit -= 25.0f;
}
- else
- crit -= pVictim->GetRangedCritChanceReduction();
+ else if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ crit -= modOwner->GetRangedCritChanceReduction();
// Apply crit chance from defence skill
crit += (int32(GetMaxSkillValueForLevel(pVictim)) - int32(pVictim->GetDefenseSkillValue(this))) * 0.04f;
@@ -10216,8 +10259,11 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
crit_chance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE, schoolMask);
// Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE
crit_chance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE);
- // Modify by player victim resilience
- crit_chance -= pVictim->GetSpellCritChanceReduction();
+ // Reduce crit chance from resilience for players and pets only.
+ // As of patch 3.3 pets inherit 100% of master resilience.
+ if (GetSpellModOwner())
+ if (Player* modOwner = pVictim->GetSpellModOwner())
+ crit_chance -= modOwner->GetSpellCritChanceReduction();
}
// scripted (increase crit chance ... against ... target by x%
AuraEffectList const& mOverrideClassScript = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
diff --git a/src/game/Unit.h b/src/game/Unit.h
index 1aef0002db8..a9ff929f910 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -1309,8 +1309,8 @@ class Unit : public WorldObject
// player or player's pet resilience (-1%), cap 100%
uint32 GetMeleeDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.0f, 100.0f, damage); }
- uint32 GetRangedDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.0f, 100.0f, damage); }
- uint32 GetSpellDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.0f, 100.0f, damage); }
+ uint32 GetRangedDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_RANGED, 2.0f, 100.0f, damage); }
+ uint32 GetSpellDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_SPELL, 2.0f, 100.0f, damage); }
float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const;
SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);