Propertly update combat ratings fields, by VladimirMangos.

--HG--
branch : trunk
This commit is contained in:
n0n4m3
2010-01-16 19:05:27 +03:00
parent e21e0ce95b
commit e031df23fc
3 changed files with 45 additions and 18 deletions

View File

@@ -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.