aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/game/Player.cpp58
-rw-r--r--src/game/Player.h4
-rw-r--r--src/game/StatSystem.cpp1
3 files changed, 45 insertions, 18 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp
index a0b13dacee1..e97731fc754 100644
--- a/src/game/Player.cpp
+++ b/src/game/Player.cpp
@@ -5207,7 +5207,36 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply)
{
m_baseRatingValue[cr]+=(apply ? value : -value);
- int32 amount = uint32(m_baseRatingValue[cr]);
+ // explicit affected values
+ switch (cr)
+ {
+ case CR_HASTE_MELEE:
+ {
+ float RatingChange = value / GetRatingCoefficient(cr);
+ ApplyAttackTimePercentMod(BASE_ATTACK,RatingChange,apply);
+ ApplyAttackTimePercentMod(OFF_ATTACK,RatingChange,apply);
+ break;
+ }
+ case CR_HASTE_RANGED:
+ {
+ float RatingChange = value / GetRatingCoefficient(cr);
+ ApplyAttackTimePercentMod(RANGED_ATTACK, RatingChange, apply);
+ break;
+ }
+ case CR_HASTE_SPELL:
+ {
+ float RatingChange = value / GetRatingCoefficient(cr);
+ ApplyCastTimePercentMod(RatingChange,apply);
+ break;
+ }
+ }
+
+ UpdateRating(cr);
+}
+
+void Player::UpdateRating(CombatRating cr)
+{
+ int32 amount = m_baseRatingValue[cr];
// Apply bonus from SPELL_AURA_MOD_RATING_FROM_STAT
// stat used stored in miscValueB for this aura
AuraEffectList const& modRatingFromStat = GetAuraEffectsByType(SPELL_AURA_MOD_RATING_FROM_STAT);
@@ -5218,9 +5247,6 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply)
amount = 0;
SetUInt32Value(PLAYER_FIELD_COMBAT_RATING_1 + cr, uint32(amount));
- float RatingCoeffecient = GetRatingCoefficient(cr);
- float RatingChange = 0.0f;
-
bool affectStats = CanModifyStats();
switch (cr)
@@ -5272,18 +5298,9 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply)
break;
case CR_CRIT_TAKEN_SPELL: // Implemented in Unit::SpellCriticalBonus (only for chance to crit)
break;
- case CR_HASTE_MELEE:
- RatingChange = value / RatingCoeffecient;
- ApplyAttackTimePercentMod(BASE_ATTACK,RatingChange,apply);
- ApplyAttackTimePercentMod(OFF_ATTACK,RatingChange,apply);
- break;
+ case CR_HASTE_MELEE: // Implemented in Player::ApplyRatingMod
case CR_HASTE_RANGED:
- RatingChange = value / RatingCoeffecient;
- ApplyAttackTimePercentMod(RANGED_ATTACK, RatingChange, apply);
- break;
case CR_HASTE_SPELL:
- RatingChange = value / RatingCoeffecient;
- ApplyCastTimePercentMod(RatingChange,apply);
break;
case CR_WEAPON_SKILL_MAINHAND: // Implemented in Unit::RollMeleeOutcomeAgainst
case CR_WEAPON_SKILL_OFFHAND:
@@ -5303,6 +5320,12 @@ void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply)
}
}
+void Player::UpdateAllRatings()
+{
+ for(int cr = 0; cr < MAX_COMBAT_RATING; ++cr)
+ UpdateRating(CombatRating(cr));
+}
+
void Player::SetRegularAttackTime()
{
for (uint8 i = 0; i < MAX_ATTACK; ++i)
@@ -15825,8 +15848,6 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
SetUInt32Value(PLAYER_TRACK_CREATURES, 0 );
SetUInt32Value(PLAYER_TRACK_RESOURCES, 0 );
- _LoadSkills(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSKILLS));
-
// make sure the unit is considered out of combat for proper loading
ClearInCombat();
@@ -15842,10 +15863,13 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder )
// reset stats before loading any modifiers
InitStatsForLevel();
- InitTaxiNodesForLevel();
InitGlyphsForLevel();
+ InitTaxiNodesForLevel();
InitRunes();
+ // load skills after InitStatsForLevel because it triggering aura apply also
+ _LoadSkills(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSKILLS));
+
// apply original stats mods before spell loading or item equipment that call before equip _RemoveStatsMods()
//mails are loaded only when needed ;-) - when player in game click on mailbox.
diff --git a/src/game/Player.h b/src/game/Player.h
index 1067105d227..41aa8644ee9 100644
--- a/src/game/Player.h
+++ b/src/game/Player.h
@@ -1726,11 +1726,13 @@ class TRINITY_DLL_SPEC Player : public Unit, public GridObject<Player>
void UpdateDamagePhysical(WeaponAttackType attType);
void ApplySpellPowerBonus(int32 amount, bool apply);
void UpdateSpellDamageAndHealingBonus();
+ void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
+ void UpdateRating(CombatRating cr);
+ void UpdateAllRatings();
void CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bool addTotalPct, float& min_damage, float& max_damage);
void UpdateDefenseBonusesMod();
- void ApplyRatingMod(CombatRating cr, int32 value, bool apply);
inline void RecalculateRating(CombatRating cr) { ApplyRatingMod(cr, 0, true);}
float GetMeleeCritFromAgility();
float GetDodgeFromAgility();
diff --git a/src/game/StatSystem.cpp b/src/game/StatSystem.cpp
index 0a4f1472ff8..6c69caf1580 100644
--- a/src/game/StatSystem.cpp
+++ b/src/game/StatSystem.cpp
@@ -148,6 +148,7 @@ bool Player::UpdateAllStats()
for (int i = POWER_MANA; i < MAX_POWERS; ++i)
UpdateMaxPower(Powers(i));
+ UpdateAllRatings();
UpdateAllCritPercentages();
UpdateAllSpellCritChances();
UpdateDefenseBonusesMod();