mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 13:37:05 +00:00
[8747] Implement player's pet resilience, also fix DoT case.
This commit is contained in:
parent
012fac90c8
commit
1b6176396e
7 changed files with 82 additions and 99 deletions
|
|
@ -4816,56 +4816,6 @@ float Player::GetRatingBonusValue(CombatRating cr) const
|
|||
return float(GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr)) / GetRatingCoefficient(cr);
|
||||
}
|
||||
|
||||
uint32 Player::GetMeleeCritDamageReduction(uint32 damage) const
|
||||
{
|
||||
float melee = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE)*2.2f;
|
||||
if (melee>33.0f) melee = 33.0f;
|
||||
return uint32 (melee * damage /100.0f);
|
||||
}
|
||||
|
||||
uint32 Player::GetMeleeDamageReduction(uint32 damage) const
|
||||
{
|
||||
float rate = GetRatingBonusValue(CR_CRIT_TAKEN_MELEE);
|
||||
// Resilience not limited (limit it by 100%)
|
||||
if (rate > 100.0f)
|
||||
rate = 100.0f;
|
||||
return uint32 (rate * damage / 100.0f);
|
||||
}
|
||||
|
||||
uint32 Player::GetRangedCritDamageReduction(uint32 damage) const
|
||||
{
|
||||
float ranged = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED)*2.2f;
|
||||
if (ranged>33.0f) ranged=33.0f;
|
||||
return uint32 (ranged * damage /100.0f);
|
||||
}
|
||||
|
||||
uint32 Player::GetRangedDamageReduction(uint32 damage) const
|
||||
{
|
||||
float rate = GetRatingBonusValue(CR_CRIT_TAKEN_RANGED);
|
||||
// Resilience not limited (limit it by 100%)
|
||||
if (rate > 100.0f)
|
||||
rate = 100.0f;
|
||||
return uint32 (rate * damage / 100.0f);
|
||||
}
|
||||
|
||||
uint32 Player::GetSpellCritDamageReduction(uint32 damage) const
|
||||
{
|
||||
float spell = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL)*2.2f;
|
||||
// In wow script resilience limited to 33%
|
||||
if (spell>33.0f)
|
||||
spell = 33.0f;
|
||||
return uint32 (spell * damage / 100.0f);
|
||||
}
|
||||
|
||||
uint32 Player::GetSpellDamageReduction(uint32 damage) const
|
||||
{
|
||||
float rate = GetRatingBonusValue(CR_CRIT_TAKEN_SPELL);
|
||||
// Resilience not limited (limit it by 100%)
|
||||
if (rate > 100.0f)
|
||||
rate = 100.0f;
|
||||
return uint32 (rate * damage / 100.0f);
|
||||
}
|
||||
|
||||
float Player::GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const
|
||||
{
|
||||
switch (attType)
|
||||
|
|
|
|||
|
|
@ -1724,12 +1724,6 @@ class MANGOS_DLL_SPEC Player : public Unit
|
|||
float OCTRegenMPPerSpirit();
|
||||
float GetRatingCoefficient(CombatRating cr) const;
|
||||
float GetRatingBonusValue(CombatRating cr) const;
|
||||
uint32 GetMeleeCritDamageReduction(uint32 damage) const;
|
||||
uint32 GetMeleeDamageReduction(uint32 damage) const;
|
||||
uint32 GetRangedCritDamageReduction(uint32 damage) const;
|
||||
uint32 GetRangedDamageReduction(uint32 damage) const;
|
||||
uint32 GetSpellCritDamageReduction(uint32 damage) const;
|
||||
uint32 GetSpellDamageReduction(uint32 damage) const;
|
||||
uint32 GetBaseSpellPowerBonus() { return m_baseSpellPower; }
|
||||
|
||||
float GetExpertiseDodgeOrParryReduction(WeaponAttackType attType) const;
|
||||
|
|
|
|||
|
|
@ -6382,10 +6382,10 @@ void Aura::PeriodicTick()
|
|||
if (isCrit)
|
||||
cleanDamage.hitOutCome = MELEE_HIT_CRIT;
|
||||
|
||||
// Reduce dot damage from resilience for players.
|
||||
// only from players
|
||||
// FIXME: need use SpellDamageBonus instead?
|
||||
if (m_target->GetTypeId() == TYPEID_PLAYER)
|
||||
pdamage-=((Player*)m_target)->GetSpellDamageReduction(pdamage);
|
||||
if (IS_PLAYER_GUID(m_caster_guid))
|
||||
pdamage -= m_target->GetSpellDamageReduction(pdamage);
|
||||
|
||||
pCaster->CalcAbsorbResist(m_target, GetSpellSchoolMask(GetSpellProto()), DOT, pdamage, &absorb, &resist);
|
||||
|
||||
|
|
@ -6609,8 +6609,8 @@ void Aura::PeriodicTick()
|
|||
int32 drain_amount = m_target->GetPower(power) > pdamage ? pdamage : m_target->GetPower(power);
|
||||
|
||||
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
|
||||
if (power == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER)
|
||||
drain_amount -= ((Player*)m_target)->GetSpellCritDamageReduction(drain_amount);
|
||||
if (power == POWER_MANA)
|
||||
drain_amount -= m_target->GetSpellCritDamageReduction(drain_amount);
|
||||
|
||||
m_target->ModifyPower(power, -drain_amount);
|
||||
|
||||
|
|
@ -6701,8 +6701,8 @@ void Aura::PeriodicTick()
|
|||
return;
|
||||
|
||||
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
|
||||
if (powerType == POWER_MANA && m_target->GetTypeId() == TYPEID_PLAYER)
|
||||
pdamage -= ((Player*)m_target)->GetSpellCritDamageReduction(pdamage);
|
||||
if (powerType == POWER_MANA)
|
||||
pdamage -= m_target->GetSpellCritDamageReduction(pdamage);
|
||||
|
||||
uint32 gain = uint32(-m_target->ModifyPower(powerType, -pdamage));
|
||||
|
||||
|
|
|
|||
|
|
@ -2486,8 +2486,8 @@ void Spell::EffectPowerDrain(uint32 i)
|
|||
|
||||
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
|
||||
uint32 power = damage;
|
||||
if ( drain_power == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER )
|
||||
power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power);
|
||||
if (drain_power == POWER_MANA)
|
||||
power -= unitTarget->GetSpellCritDamageReduction(power);
|
||||
|
||||
int32 new_damage;
|
||||
if(curPower < power)
|
||||
|
|
@ -2550,8 +2550,8 @@ void Spell::EffectPowerBurn(uint32 i)
|
|||
|
||||
// resilience reduce mana draining effect at spell crit damage reduction (added in 2.4)
|
||||
uint32 power = damage;
|
||||
if (powertype == POWER_MANA && unitTarget->GetTypeId() == TYPEID_PLAYER)
|
||||
power -= ((Player*)unitTarget)->GetSpellCritDamageReduction(power);
|
||||
if (powertype == POWER_MANA)
|
||||
power -= unitTarget->GetSpellCritDamageReduction(power);
|
||||
|
||||
int32 new_damage = (curPower < power) ? curPower : power;
|
||||
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1034,6 +1034,21 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
void CalculateSpellDamage(SpellNonMeleeDamage *damageInfo, int32 damage, SpellEntry const *spellInfo, WeaponAttackType attackType = BASE_ATTACK);
|
||||
void DealSpellDamage(SpellNonMeleeDamage *damageInfo, bool durabilityLoss);
|
||||
|
||||
// player or player's pet resilience (-1%)
|
||||
float GetMeleeCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_MELEE); }
|
||||
float GetRangedCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_RANGED); }
|
||||
float GetSpellCritChanceReduction() const { return GetCombatRatingReduction(CR_CRIT_TAKEN_SPELL); }
|
||||
|
||||
// player or player's pet resilience (-1%)
|
||||
uint32 GetMeleeCritDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 2.2f, 33.0f, damage); }
|
||||
uint32 GetRangedCritDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_RANGED, 2.2f, 33.0f, damage); }
|
||||
uint32 GetSpellCritDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_SPELL, 2.2f, 33.0f, damage); }
|
||||
|
||||
// player or player's pet resilience (-1%), cap 100%
|
||||
uint32 GetMeleeDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 1.0f, 100.0f, damage); }
|
||||
uint32 GetRangedDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 1.0f, 100.0f, damage); }
|
||||
uint32 GetSpellDamageReduction(uint32 damage) const { return GetCombatRatingDamageReduction(CR_CRIT_TAKEN_MELEE, 1.0f, 100.0f, damage); }
|
||||
|
||||
float MeleeSpellMissChance(Unit *pVictim, WeaponAttackType attType, int32 skillDiff, SpellEntry const *spell);
|
||||
SpellMissInfo MeleeSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
||||
SpellMissInfo MagicSpellHitResult(Unit *pVictim, SpellEntry const *spell);
|
||||
|
|
@ -1583,6 +1598,10 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
bool HandleOverrideClassScriptAuraProc(Unit *pVictim, uint32 damage, Aura* triggredByAura, SpellEntry const *procSpell, uint32 cooldown);
|
||||
bool HandleMendingAuraProc(Aura* triggeredByAura);
|
||||
|
||||
// player or player's pet
|
||||
float GetCombatRatingReduction(CombatRating cr) const;
|
||||
uint32 GetCombatRatingDamageReduction(CombatRating cr, float rate, float cap, uint32 damage) const;
|
||||
|
||||
uint32 m_state; // Even derived shouldn't modify
|
||||
uint32 m_CombatTimer;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "8746"
|
||||
#define REVISION_NR "8747"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue