Core/Spells: Implemented SPELL_AURA_MOD_RATING_PCT
* Initial patch by @fatalaim Closes #16962
This commit is contained in:
@@ -4969,35 +4969,7 @@ float Player::OCTRegenMPPerSpirit() const
|
||||
|
||||
void Player::ApplyRatingMod(CombatRating combatRating, int32 value, bool apply)
|
||||
{
|
||||
float oldRating = m_baseRatingValue[combatRating];
|
||||
m_baseRatingValue[combatRating] += (apply ? value : -value);
|
||||
|
||||
// explicit affected values
|
||||
float const multiplier = GetRatingMultiplier(combatRating);
|
||||
float const oldVal = oldRating * multiplier;
|
||||
float const newVal = m_baseRatingValue[combatRating] * multiplier;
|
||||
switch (combatRating)
|
||||
{
|
||||
case CR_HASTE_MELEE:
|
||||
ApplyAttackTimePercentMod(BASE_ATTACK, oldVal, false);
|
||||
ApplyAttackTimePercentMod(OFF_ATTACK, oldVal, false);
|
||||
ApplyAttackTimePercentMod(BASE_ATTACK, newVal, true);
|
||||
ApplyAttackTimePercentMod(OFF_ATTACK, newVal, true);
|
||||
if (getClass() == CLASS_DEATH_KNIGHT)
|
||||
UpdateAllRunesRegen();
|
||||
break;
|
||||
case CR_HASTE_RANGED:
|
||||
ApplyAttackTimePercentMod(RANGED_ATTACK, oldVal, false);
|
||||
ApplyAttackTimePercentMod(RANGED_ATTACK, newVal, true);
|
||||
break;
|
||||
case CR_HASTE_SPELL:
|
||||
ApplyCastTimePercentMod(oldVal, false);
|
||||
ApplyCastTimePercentMod(newVal, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
UpdateRating(combatRating);
|
||||
}
|
||||
|
||||
@@ -5008,10 +4980,18 @@ void Player::UpdateRating(CombatRating cr)
|
||||
// stat used stored in miscValueB for this aura
|
||||
AuraEffectList const& modRatingFromStat = GetAuraEffectsByType(SPELL_AURA_MOD_RATING_FROM_STAT);
|
||||
for (AuraEffectList::const_iterator i = modRatingFromStat.begin(); i != modRatingFromStat.end(); ++i)
|
||||
if ((*i)->GetMiscValue() & (1<<cr))
|
||||
if ((*i)->GetMiscValue() & (1 << cr))
|
||||
amount += int32(CalculatePct(GetStat(Stats((*i)->GetMiscValueB())), (*i)->GetAmount()));
|
||||
|
||||
AuraEffectList const& modRatingPct = GetAuraEffectsByType(SPELL_AURA_MOD_RATING_PCT);
|
||||
for (AuraEffectList::const_iterator i = modRatingPct.begin(); i != modRatingPct.end(); ++i)
|
||||
if ((*i)->GetMiscValue() & (1 << cr))
|
||||
amount += int32(CalculatePct(amount, (*i)->GetAmount()));
|
||||
|
||||
if (amount < 0)
|
||||
amount = 0;
|
||||
|
||||
uint32 oldRating = GetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr);
|
||||
SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr, uint32(amount));
|
||||
|
||||
bool affectStats = CanModifyStats();
|
||||
@@ -5061,10 +5041,37 @@ void Player::UpdateRating(CombatRating cr)
|
||||
case CR_RESILIENCE_CRIT_TAKEN:
|
||||
case CR_LIFESTEAL:
|
||||
break;
|
||||
case CR_HASTE_MELEE: // Implemented in Player::ApplyRatingMod
|
||||
case CR_HASTE_MELEE:
|
||||
case CR_HASTE_RANGED:
|
||||
case CR_HASTE_SPELL:
|
||||
{
|
||||
// explicit affected values
|
||||
float const multiplier = GetRatingMultiplier(cr);
|
||||
float const oldVal = oldRating * multiplier;
|
||||
float const newVal = amount * multiplier;
|
||||
switch (cr)
|
||||
{
|
||||
case CR_HASTE_MELEE:
|
||||
ApplyAttackTimePercentMod(BASE_ATTACK, oldVal, false);
|
||||
ApplyAttackTimePercentMod(OFF_ATTACK, oldVal, false);
|
||||
ApplyAttackTimePercentMod(BASE_ATTACK, newVal, true);
|
||||
ApplyAttackTimePercentMod(OFF_ATTACK, newVal, true);
|
||||
if (getClass() == CLASS_DEATH_KNIGHT)
|
||||
UpdateAllRunesRegen();
|
||||
break;
|
||||
case CR_HASTE_RANGED:
|
||||
ApplyAttackTimePercentMod(RANGED_ATTACK, oldVal, false);
|
||||
ApplyAttackTimePercentMod(RANGED_ATTACK, newVal, true);
|
||||
break;
|
||||
case CR_HASTE_SPELL:
|
||||
ApplyCastTimePercentMod(oldVal, false);
|
||||
ApplyCastTimePercentMod(newVal, true);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CR_AVOIDANCE:
|
||||
case CR_UNUSED_2:
|
||||
case CR_WEAPON_SKILL_RANGED:
|
||||
|
||||
@@ -464,7 +464,7 @@ pAuraEffectHandler AuraEffectHandler[TOTAL_AURAS]=
|
||||
&AuraEffect::HandleModPowerDisplay, //402 SPELL_AURA_MOD_POWER_DISPLAY
|
||||
&AuraEffect::HandleNoImmediateEffect, //403 SPELL_AURA_OVERRIDE_SPELL_VISUAL implemented in Unit::GetCastSpellXSpellVisualId
|
||||
&AuraEffect::HandleOverrideAttackPowerBySpellPower, //404 SPELL_AURA_OVERRIDE_ATTACK_POWER_BY_SP_PCT
|
||||
&AuraEffect::HandleNULL, //405 SPELL_AURA_MOD_RATING_PCT
|
||||
&AuraEffect::HandleModRatingPct, //405 SPELL_AURA_MOD_RATING_PCT
|
||||
&AuraEffect::HandleNULL, //406
|
||||
&AuraEffect::HandleNULL, //407 SPELL_AURA_MOD_FEAR_2
|
||||
&AuraEffect::HandleNULL, //408
|
||||
@@ -4501,7 +4501,23 @@ void AuraEffect::HandleModRatingFromStat(AuraApplication const* aurApp, uint8 mo
|
||||
// Just recalculate ratings
|
||||
for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
|
||||
if (GetMiscValue() & (1 << rating))
|
||||
target->ToPlayer()->ApplyRatingMod(CombatRating(rating), 0, apply);
|
||||
target->ToPlayer()->UpdateRating(CombatRating(rating));
|
||||
}
|
||||
|
||||
void AuraEffect::HandleModRatingPct(AuraApplication const* aurApp, uint8 mode, bool apply) const
|
||||
{
|
||||
if (!(mode & (AURA_EFFECT_HANDLE_CHANGE_AMOUNT_MASK | AURA_EFFECT_HANDLE_STAT)))
|
||||
return;
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
|
||||
if (target->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
// Just recalculate ratings
|
||||
for (uint32 rating = 0; rating < MAX_COMBAT_RATING; ++rating)
|
||||
if (GetMiscValue() & (1 << rating))
|
||||
target->ToPlayer()->UpdateRating(CombatRating(rating));
|
||||
}
|
||||
|
||||
/********************************/
|
||||
|
||||
@@ -270,6 +270,7 @@ class TC_GAME_API AuraEffect
|
||||
// combat rating
|
||||
void HandleModRating(AuraApplication const* aurApp, uint8 mode, bool apply) const;
|
||||
void HandleModRatingFromStat(AuraApplication const* aurApp, uint8 mode, bool apply) const;
|
||||
void HandleModRatingPct(AuraApplication const* aurApp, uint8 mode, bool apply) const;
|
||||
// attack power
|
||||
void HandleAuraModAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
|
||||
void HandleAuraModRangedAttackPower(AuraApplication const* aurApp, uint8 mode, bool apply) const;
|
||||
|
||||
Reference in New Issue
Block a user