mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-22 18:15:31 +01:00
Implement player's pet resilience, also fix DoT case. by VladimirMangos and thx tali
--HG-- branch : trunk
This commit is contained in:
@@ -1205,8 +1205,10 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
||||
damage = int32(damage * float((100.0f + critPctDamageMod)/100.0f));
|
||||
|
||||
// Resilience - reduce crit damage
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
damage -= ((Player*)pVictim)->GetMeleeCritDamageReduction(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)
|
||||
@@ -1231,8 +1233,7 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
||||
damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT;
|
||||
damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim);
|
||||
// Resilience - reduce crit damage
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
damage -= ((Player*)pVictim)->GetSpellCritDamageReduction(damage);
|
||||
damage -= pVictim->GetSpellCritDamageReduction(damage);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1241,8 +1242,9 @@ void Unit::CalculateSpellDamageTaken(SpellNonMeleeDamage *damageInfo, int32 dama
|
||||
if (damageSchoolMask & SPELL_SCHOOL_MASK_NORMAL)
|
||||
damage = CalcArmorReducedDamage(pVictim, damage, spellInfo, attackType);
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
damage -= ((Player*)pVictim)->GetSpellDamageReduction(damage);
|
||||
// only from players
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
damage -= pVictim->GetSpellDamageReduction(damage);
|
||||
|
||||
// Calculate absorb resist
|
||||
if (damage > 0)
|
||||
@@ -1425,12 +1427,14 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
|
||||
damageInfo->damage = int32((damageInfo->damage) * float((100.0f + mod)/100.0f));
|
||||
|
||||
// Resilience - reduce crit damage
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
uint32 resilienceReduction = ((Player*)pVictim)->GetMeleeCritDamageReduction(damageInfo->damage);
|
||||
damageInfo->damage -= resilienceReduction;
|
||||
damageInfo->cleanDamage += resilienceReduction;
|
||||
}
|
||||
uint32 resilienceReduction;
|
||||
if (attackType != RANGED_ATTACK)
|
||||
resilienceReduction = pVictim->GetMeleeCritDamageReduction(damageInfo->damage);
|
||||
else
|
||||
resilienceReduction = pVictim->GetRangedCritDamageReduction(damageInfo->damage);
|
||||
|
||||
damageInfo->damage -= resilienceReduction;
|
||||
damageInfo->cleanDamage += resilienceReduction;
|
||||
break;
|
||||
}
|
||||
case MELEE_HIT_PARRY:
|
||||
@@ -1491,12 +1495,13 @@ void Unit::CalculateMeleeDamage(Unit *pVictim, uint32 damage, CalcDamageInfo *da
|
||||
break;
|
||||
}
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
// only from players
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (attackType != RANGED_ATTACK)
|
||||
damage-=((Player*)pVictim)->GetMeleeDamageReduction(damage);
|
||||
damage -= pVictim->GetMeleeDamageReduction(damage);
|
||||
else
|
||||
damage-=((Player*)pVictim)->GetRangedDamageReduction(damage);
|
||||
damage -= pVictim->GetRangedDamageReduction(damage);
|
||||
}
|
||||
|
||||
// Calculate absorb resist
|
||||
@@ -3186,13 +3191,10 @@ float Unit::GetUnitCriticalChance(WeaponAttackType attackType, const Unit *pVict
|
||||
crit += pVictim->GetTotalAuraModifier(SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE);
|
||||
|
||||
// reduce crit chance from Rating for players
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (attackType==RANGED_ATTACK)
|
||||
crit -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_RANGED);
|
||||
else
|
||||
crit -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_MELEE);
|
||||
}
|
||||
if (attackType != RANGED_ATTACK)
|
||||
crit -= pVictim->GetMeleeCritChanceReduction();
|
||||
else
|
||||
crit -= pVictim->GetRangedCritChanceReduction();
|
||||
|
||||
// Apply crit chance from defence skill
|
||||
crit += (int32(GetMaxSkillValueForLevel(pVictim)) - int32(pVictim->GetDefenseSkillValue(this))) * 0.04f;
|
||||
@@ -9850,8 +9852,7 @@ bool Unit::isSpellCrit(Unit *pVictim, SpellEntry const *spellProto, SpellSchoolM
|
||||
// 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
|
||||
if (pVictim->GetTypeId() == TYPEID_PLAYER)
|
||||
crit_chance -= ((Player*)pVictim)->GetRatingBonusValue(CR_CRIT_TAKEN_SPELL);
|
||||
crit_chance -= pVictim->GetSpellCritChanceReduction();
|
||||
}
|
||||
// scripted (increase crit chance ... against ... target by x%
|
||||
AuraEffectList const& mOverrideClassScript = GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS);
|
||||
@@ -15088,6 +15089,29 @@ void Unit::KnockbackFrom(float x, float y, float speedXY, float speedZ)
|
||||
}
|
||||
}
|
||||
|
||||
float Unit::GetCombatRatingReduction(CombatRating cr) const
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
return ((Player const*)this)->GetRatingBonusValue(cr);
|
||||
else if (((Creature const*)this)->isPet())
|
||||
{
|
||||
// Player's pet have 0.4 resilience from owner
|
||||
if (Unit* owner = GetOwner())
|
||||
if(owner->GetTypeId() == TYPEID_PLAYER)
|
||||
return ((Player*)owner)->GetRatingBonusValue(cr) * 0.4f;
|
||||
}
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
uint32 Unit::GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const
|
||||
{
|
||||
float percent = GetCombatRatingReduction(cr) * rate;
|
||||
if (percent > cap)
|
||||
percent = cap;
|
||||
return uint32 (percent * damage / 100.0f);
|
||||
}
|
||||
|
||||
uint32 Unit::GetModelForForm(ShapeshiftForm form)
|
||||
{
|
||||
switch(form)
|
||||
|
||||
Reference in New Issue
Block a user