aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2016-07-16 16:04:42 +0200
committerShauren <shauren.trinity@gmail.com>2016-07-16 16:04:42 +0200
commit1849a4fcc197d38233eda4d11593f5bee11faa06 (patch)
treed99b51c586a9180388ead54bfc826711ab95a18f /src
parent649e3a9ac59a1d24eeec3419138d0d5f11dee566 (diff)
Core/Spells: Implemented SPELL_AURA_MOD_RATING_PCT
* Initial patch by @fatalaim Closes #16962
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp67
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.cpp20
-rw-r--r--src/server/game/Spells/Auras/SpellAuraEffects.h1
3 files changed, 56 insertions, 32 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 8a4b23718ef..afcb58b3c42 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -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:
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.cpp b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
index 7b5083b8580..278fccfdce6 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.cpp
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.cpp
@@ -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));
}
/********************************/
diff --git a/src/server/game/Spells/Auras/SpellAuraEffects.h b/src/server/game/Spells/Auras/SpellAuraEffects.h
index 73766bbcf1a..d01b5cdeaae 100644
--- a/src/server/game/Spells/Auras/SpellAuraEffects.h
+++ b/src/server/game/Spells/Auras/SpellAuraEffects.h
@@ -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;