Core/Unit: Make sure pets respect unit damage resilience and the other way around (patch by Dr. Tenma)
Fixes issue #3918 --HG-- branch : trunk
This commit is contained in:
@@ -1081,23 +1081,10 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
|||||||
damage -= damageInfo->blocked;
|
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)
|
if (attackType != RANGED_ATTACK)
|
||||||
damage -= modOwner->GetMeleeCritDamageReduction(damage);
|
ApplyResilience(pVictim, NULL, &damage, crit, CR_CRIT_TAKEN_MELEE);
|
||||||
else
|
else
|
||||||
damage -= modOwner->GetRangedCritDamageReduction(damage);
|
ApplyResilience(pVictim, NULL, &damage, crit, CR_CRIT_TAKEN_RANGED);
|
||||||
}
|
|
||||||
if (attackType != RANGED_ATTACK)
|
|
||||||
damage -= modOwner->GetMeleeDamageReduction(damage);
|
|
||||||
else
|
|
||||||
damage -= modOwner->GetRangedDamageReduction(damage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
// Magical Attacks
|
// Magical Attacks
|
||||||
@@ -1111,15 +1098,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
|||||||
damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim);
|
damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce damage from resilience for players and pets only.
|
ApplyResilience(pVictim, NULL, &damage, crit, CR_CRIT_TAKEN_SPELL);
|
||||||
// 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;
|
break;
|
||||||
}
|
}
|
||||||
@@ -1295,21 +1274,6 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
|
|||||||
mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, crTypeMask);
|
mod += GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_CRIT_PERCENT_VERSUS, crTypeMask);
|
||||||
if (mod != 0)
|
if (mod != 0)
|
||||||
damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod)/100.0f));
|
damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod)/100.0f));
|
||||||
|
|
||||||
// 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;
|
break;
|
||||||
}
|
}
|
||||||
case MELEE_HIT_PARRY:
|
case MELEE_HIT_PARRY:
|
||||||
@@ -1371,20 +1335,14 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce damage from resilience for players and pets only.
|
int32 resilienceReduction = damageInfo->damage;
|
||||||
// As of patch 3.3 pets inherit 100% of master resilience.
|
|
||||||
if (GetSpellModOwner())
|
|
||||||
if (Player* modOwner = pVictim->GetSpellModOwner())
|
|
||||||
{
|
|
||||||
uint32 resilienceReduction;
|
|
||||||
if (attackType != RANGED_ATTACK)
|
if (attackType != RANGED_ATTACK)
|
||||||
resilienceReduction = modOwner->GetMeleeDamageReduction(damageInfo->damage);
|
ApplyResilience(pVictim, NULL, &resilienceReduction, (damageInfo->hitOutCome == MELEE_HIT_CRIT), CR_CRIT_TAKEN_MELEE);
|
||||||
else
|
else
|
||||||
resilienceReduction = modOwner->GetRangedDamageReduction(damageInfo->damage);
|
ApplyResilience(pVictim, NULL, &resilienceReduction, (damageInfo->hitOutCome == MELEE_HIT_CRIT), CR_CRIT_TAKEN_RANGED);
|
||||||
|
resilienceReduction = damageInfo->damage - resilienceReduction;
|
||||||
damageInfo->damage -= resilienceReduction;
|
damageInfo->damage -= resilienceReduction;
|
||||||
damageInfo->cleanDamage += resilienceReduction;
|
damageInfo->cleanDamage += resilienceReduction;
|
||||||
}
|
|
||||||
|
|
||||||
// Calculate absorb resist
|
// Calculate absorb resist
|
||||||
if (int32(damageInfo->damage) > 0)
|
if (int32(damageInfo->damage) > 0)
|
||||||
@@ -3248,18 +3206,13 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVict
|
|||||||
// reduce crit chance from Rating for players
|
// reduce crit chance from Rating for players
|
||||||
if (attackType != RANGED_ATTACK)
|
if (attackType != RANGED_ATTACK)
|
||||||
{
|
{
|
||||||
// Reduce crit chance from resilience for players and pets only.
|
ApplyResilience(pVictim, &crit, NULL, false, CR_CRIT_TAKEN_MELEE);
|
||||||
// As of patch 3.3 pets inherit 100% of master resilience.
|
|
||||||
if (GetSpellModOwner())
|
|
||||||
if (Player* modOwner = pVictim->GetSpellModOwner())
|
|
||||||
crit -= modOwner->GetMeleeCritChanceReduction();
|
|
||||||
// Glyph of barkskin
|
// Glyph of barkskin
|
||||||
if (pVictim->HasAura(63057) && pVictim->HasAura(22812))
|
if (pVictim->HasAura(63057) && pVictim->HasAura(22812))
|
||||||
crit -= 25.0f;
|
crit -= 25.0f;
|
||||||
}
|
}
|
||||||
else if (GetSpellModOwner())
|
else
|
||||||
if (Player* modOwner = pVictim->GetSpellModOwner())
|
ApplyResilience(pVictim, &crit, NULL, false, CR_CRIT_TAKEN_RANGED);
|
||||||
crit -= modOwner->GetRangedCritChanceReduction();
|
|
||||||
|
|
||||||
// Apply crit chance from defence skill
|
// Apply crit chance from defence skill
|
||||||
crit += (int32(GetMaxSkillValueForLevel(pVictim)) - int32(pVictim->GetDefenseSkillValue(this))) * 0.04f;
|
crit += (int32(GetMaxSkillValueForLevel(pVictim)) - int32(pVictim->GetDefenseSkillValue(this))) * 0.04f;
|
||||||
@@ -10892,11 +10845,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
|
|||||||
crit_chance += pVictim->GetTotalAuraModifierByMiscMask(SPELL_AURA_MOD_ATTACKER_SPELL_CRIT_CHANCE, schoolMask);
|
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
|
// 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);
|
crit_chance += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE);
|
||||||
// Reduce crit chance from resilience for players and pets only.
|
ApplyResilience(pVictim, &crit_chance, NULL, false, CR_CRIT_TAKEN_SPELL);
|
||||||
// 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%
|
// scripted (increase crit chance ... against ... target by x%
|
||||||
AuraEffectList const& mOverrideClassScript = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
AuraEffectList const& mOverrideClassScript = GetAuraEffectsByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||||
@@ -16168,6 +16117,71 @@ void Unit::SetAuraStack(uint32 spellId, Unit *target, uint32 stack)
|
|||||||
aura->SetStackAmount(stack);
|
aura->SetStackAmount(stack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Unit::ApplyResilience(const Unit * pVictim, float * crit, int32 * damage, bool isCrit, CombatRating type) const
|
||||||
|
{
|
||||||
|
if (IsVehicle() || pVictim->IsVehicle())
|
||||||
|
return;
|
||||||
|
|
||||||
|
const Unit * source = ToPlayer();
|
||||||
|
if (!source)
|
||||||
|
{
|
||||||
|
source = ToCreature();
|
||||||
|
if (source)
|
||||||
|
{
|
||||||
|
source = source->ToCreature()->GetOwner();
|
||||||
|
if (source)
|
||||||
|
source = source->ToPlayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const Unit * target = pVictim->ToPlayer();
|
||||||
|
if (!target)
|
||||||
|
{
|
||||||
|
target = pVictim->ToCreature();
|
||||||
|
if (target)
|
||||||
|
{
|
||||||
|
target = target->ToCreature()->GetOwner();
|
||||||
|
if (target)
|
||||||
|
target = target->ToPlayer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!target)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (type)
|
||||||
|
{
|
||||||
|
case CR_CRIT_TAKEN_MELEE:
|
||||||
|
// Crit chance reduction works against nonpets
|
||||||
|
if (crit) (*crit) -= target->ToPlayer()->GetMeleeCritChanceReduction();
|
||||||
|
if (source && damage)
|
||||||
|
{
|
||||||
|
if (isCrit) (*damage) -= target->ToPlayer()->GetMeleeCritDamageReduction((*damage));
|
||||||
|
(*damage) -= target->ToPlayer()->GetMeleeDamageReduction((*damage));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CR_CRIT_TAKEN_RANGED:
|
||||||
|
// Crit chance reduction works against nonpets
|
||||||
|
if (crit) (*crit) -= target->ToPlayer()->GetRangedCritChanceReduction();
|
||||||
|
if (source && damage)
|
||||||
|
{
|
||||||
|
if (isCrit) (*damage) -= target->ToPlayer()->GetRangedCritDamageReduction((*damage));
|
||||||
|
(*damage) -= target->ToPlayer()->GetRangedDamageReduction((*damage));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case CR_CRIT_TAKEN_SPELL:
|
||||||
|
// Crit chance reduction works against nonpets
|
||||||
|
if (crit) (*crit) -= target->ToPlayer()->GetSpellCritChanceReduction();
|
||||||
|
if (source && damage)
|
||||||
|
{
|
||||||
|
if (isCrit) (*damage) -= target->ToPlayer()->GetSpellCritDamageReduction((*damage));
|
||||||
|
(*damage) -= target->ToPlayer()->GetSpellDamageReduction((*damage));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Melee based spells can be miss, parry or dodge on this step
|
// Melee based spells can be miss, parry or dodge on this step
|
||||||
// Crit or block - determined on damage calculation phase! (and can be both in some time)
|
// Crit or block - determined on damage calculation phase! (and can be both in some time)
|
||||||
float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
|
float Unit::MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const
|
||||||
|
|||||||
@@ -1332,6 +1332,8 @@ class Unit : public WorldObject
|
|||||||
uint32 GetRangedDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_RANGED, 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); }
|
uint32 GetSpellDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_SPELL, 2.0f, 100.0f, damage); }
|
||||||
|
|
||||||
|
void ApplyResilience(const Unit * pVictim, float * crit, int32 * damage, bool isCrit, CombatRating type) const;
|
||||||
|
|
||||||
float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const;
|
float MeleeSpellMissChance(const Unit *pVictim, WeaponAttackType attType, int32 skillDiff, uint32 spellId) const;
|
||||||
SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
||||||
SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
||||||
|
|||||||
@@ -1360,15 +1360,9 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
|
|||||||
if (crit)
|
if (crit)
|
||||||
damage = caster->SpellCriticalDamageBonus(m_spellProto, damage, target);
|
damage = caster->SpellCriticalDamageBonus(m_spellProto, damage, target);
|
||||||
|
|
||||||
// Reduce damage from resilience for players and pets only.
|
int32 dmg = damage;
|
||||||
// As of patch 3.3 pets inherit 100% of master resilience.
|
caster->ApplyResilience(target, NULL, &dmg, crit, CR_CRIT_TAKEN_SPELL);
|
||||||
if (caster->GetSpellModOwner())
|
damage = dmg;
|
||||||
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);
|
caster->CalcAbsorbResist(target, GetSpellSchoolMask(GetSpellProto()), DOT, damage, &absorb, &resist, m_spellProto);
|
||||||
|
|
||||||
@@ -1445,15 +1439,9 @@ void AuraEffect::PeriodicTick(Unit * target, Unit * caster) const
|
|||||||
damage = damageReductedArmor;
|
damage = damageReductedArmor;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reduce damage from resilience for players and pets only.
|
int32 dmg = damage;
|
||||||
// As of patch 3.3 pets inherit 100% of master resilience.
|
caster->ApplyResilience(target, NULL, &dmg, crit, CR_CRIT_TAKEN_SPELL);
|
||||||
if (caster->GetSpellModOwner())
|
damage = dmg;
|
||||||
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);
|
caster->CalcAbsorbResist(target, GetSpellSchoolMask(GetSpellProto()), DOT, damage, &absorb, &resist, m_spellProto);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user