[8747] Implement player's pet resilience, also fix DoT case.

This commit is contained in:
VladimirMangos 2009-10-29 04:32:16 +03:00
parent 012fac90c8
commit 1b6176396e
7 changed files with 82 additions and 99 deletions

View file

@ -1060,11 +1060,11 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S
damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT;
damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim);
// Resilience - reduce crit damage
if (pVictim->GetTypeId()==TYPEID_PLAYER)
{
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damage,damageSchoolMask);
damage -= ((Player*)pVictim)->GetMeleeCritDamageReduction(redunction_affected_damage);
}
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damage,damageSchoolMask);
if (attackType != RANGED_ATTACK)
damage -= pVictim->GetMeleeCritDamageReduction(redunction_affected_damage);
else
damage -= pVictim->GetRangedCritDamageReduction(redunction_affected_damage);
}
}
break;
@ -1080,20 +1080,18 @@ void Unit::CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, S
damageInfo->HitInfo|= SPELL_HIT_TYPE_CRIT;
damage = SpellCriticalDamageBonus(spellInfo, damage, pVictim);
// Resilience - reduce crit damage
if (pVictim->GetTypeId()==TYPEID_PLAYER)
{
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damage,damageSchoolMask);
damage -= ((Player*)pVictim)->GetSpellCritDamageReduction(redunction_affected_damage);
}
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damage,damageSchoolMask);
damage -= pVictim->GetSpellCritDamageReduction(redunction_affected_damage);
}
}
break;
}
if (GetTypeId() == TYPEID_PLAYER && pVictim->GetTypeId() == TYPEID_PLAYER)
// only from players
if (GetTypeId() == TYPEID_PLAYER)
{
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damage,damageSchoolMask);
damage -= ((Player*)pVictim)->GetSpellDamageReduction(redunction_affected_damage);
damage -= pVictim->GetSpellDamageReduction(redunction_affected_damage);
}
// damage mitigation
@ -1286,13 +1284,15 @@ 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 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damageInfo->damage,damageInfo->damageSchoolMask);
uint32 resilienceReduction = ((Player*)pVictim)->GetMeleeCritDamageReduction(redunction_affected_damage);
damageInfo->damage -= resilienceReduction;
damageInfo->cleanDamage += resilienceReduction;
}
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damageInfo->damage,damageInfo->damageSchoolMask);
uint32 resilienceReduction;
if (attackType != RANGED_ATTACK)
resilienceReduction = pVictim->GetMeleeCritDamageReduction(redunction_affected_damage);
else
resilienceReduction = pVictim->GetRangedCritDamageReduction(redunction_affected_damage);
damageInfo->damage -= resilienceReduction;
damageInfo->cleanDamage += resilienceReduction;
break;
}
case MELEE_HIT_PARRY:
@ -1391,13 +1391,14 @@ 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)
{
uint32 redunction_affected_damage = CalcNotIgnoreDamageRedunction(damage,damageInfo->damageSchoolMask);
if (attackType != RANGED_ATTACK)
damage-=((Player*)pVictim)->GetMeleeDamageReduction(redunction_affected_damage);
damage -= pVictim->GetMeleeDamageReduction(redunction_affected_damage);
else
damage-=((Player*)pVictim)->GetRangedDamageReduction(redunction_affected_damage);
damage -= pVictim->GetRangedDamageReduction(redunction_affected_damage);
}
// Calculate absorb resist
@ -2941,13 +2942,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;
@ -8622,8 +8620,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%)
@ -12631,3 +12628,26 @@ void Unit::KnockBackFrom(Unit* target, float horizintalSpeed, float verticalSpee
NearTeleportTo(fx, fy, fz, GetOrientation(), this == target);
}
}
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);
}