diff options
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 69 |
1 files changed, 44 insertions, 25 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 41ed4882826..ec31194680c 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -669,8 +669,8 @@ bool Player::Create( uint32 guidlow, const std::string& name, uint8 race, uint8 // Played time m_Last_tick = time(NULL); - m_Played_time[0] = 0; - m_Played_time[1] = 0; + m_Played_time[PLAYED_TIME_TOTAL] = 0; + m_Played_time[PLAYED_TIME_LEVEL] = 0; // base stats and related field values InitStatsForLevel(); @@ -1340,8 +1340,8 @@ void Player::Update( uint32 p_time ) if (now > m_Last_tick) { uint32 elapsed = uint32(now - m_Last_tick); - m_Played_time[0] += elapsed; // Total played time - m_Played_time[1] += elapsed; // Level played time + m_Played_time[PLAYED_TIME_TOTAL] += elapsed; // Total played time + m_Played_time[PLAYED_TIME_LEVEL] += elapsed; // Level played time m_Last_tick = now; } @@ -2460,9 +2460,12 @@ void Player::GiveLevel(uint32 level) SetUInt32Value(PLAYER_NEXT_LEVEL_XP, objmgr.GetXPForLevel(level)); //update level, max level of skills - if(getLevel()!= level) - m_Played_time[1] = 0; // Level Played Time reset + m_Played_time[PLAYED_TIME_LEVEL] = 0; // Level Played Time reset + + _ApplyAllLevelScaleItemMods(false); + SetLevel(level); + UpdateSkillsForLevel (); // save base values (bonuses already included in stored stats @@ -2490,6 +2493,8 @@ void Player::GiveLevel(uint32 level) SetPower(POWER_FOCUS, 0); SetPower(POWER_HAPPINESS, 0); + _ApplyAllLevelScaleItemMods(true); + // update level to hunter/summon pet if (Pet* pet = GetPet()) pet->SynchronizeLevelWithOwner(); @@ -6666,13 +6671,16 @@ void Player::_ApplyItemMods(Item *item, uint8 slot,bool apply) sLog.outDebug("_ApplyItemMods complete."); } -void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool apply) +void Player::_ApplyItemBonuses(ItemPrototype const *proto, uint8 slot, bool apply, bool only_level_scale /*= false*/) { if(slot >= INVENTORY_SLOT_BAG_END || !proto) return; - ScalingStatDistributionEntry const *ssd = proto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(proto->ScalingStatDistribution) : 0; - ScalingStatValuesEntry const *ssv = proto->ScalingStatValue ? sScalingStatValuesStore.LookupEntry(getLevel()) : 0; + ScalingStatDistributionEntry const *ssd = proto->ScalingStatDistribution ? sScalingStatDistributionStore.LookupEntry(proto->ScalingStatDistribution) : NULL; + ScalingStatValuesEntry const *ssv = proto->ScalingStatValue ? sScalingStatValuesStore.LookupEntry(getLevel()) : NULL; + + if(only_level_scale && !(ssd && ssv)) + return; for (uint8 i = 0; i < MAX_ITEM_PROTO_STATS; ++i) { @@ -7235,10 +7243,7 @@ void Player::CastItemCombatSpell(Unit *target, WeaponAttackType attType, uint32 float chance = pEnchant->amount[s] != 0 ? float(pEnchant->amount[s]) : GetWeaponProcChance(); if (entry && entry->PPMChance) - { - uint32 WeaponSpeed = GetAttackTime(attType); - chance = GetPPMProcChance(WeaponSpeed, entry->PPMChance, spellInfo); - } + chance = GetPPMProcChance(proto->Delay, entry->PPMChance, spellInfo); else if (entry && entry->customChance) chance = entry->customChance; @@ -7439,6 +7444,24 @@ void Player::_ApplyAllItemMods() sLog.outDebug("_ApplyAllItemMods complete."); } +void Player::_ApplyAllLevelScaleItemMods(bool apply) +{ + for (int i = 0; i < INVENTORY_SLOT_BAG_END; ++i) + { + if(m_items[i]) + { + if(m_items[i]->IsBroken()) + continue; + + ItemPrototype const *proto = m_items[i]->GetProto(); + if(!proto) + continue; + + _ApplyItemBonuses(proto,i, apply, true); + } + } +} + void Player::_ApplyAmmoBonuses() { // check ammo @@ -14262,8 +14285,8 @@ bool Player::MinimalLoadFromDB( QueryResult *result, uint32 guid ) // the instance id is not needed at character enum - m_Played_time[0] = fields[7].GetUInt32(); - m_Played_time[1] = fields[8].GetUInt32(); + m_Played_time[PLAYED_TIME_TOTAL] = fields[7].GetUInt32(); + m_Played_time[PLAYED_TIME_LEVEL] = fields[8].GetUInt32(); m_atLoginFlags = fields[9].GetUInt32(); @@ -14834,8 +14857,8 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) } m_cinematic = fields[19].GetUInt32(); - m_Played_time[0]= fields[20].GetUInt32(); - m_Played_time[1]= fields[21].GetUInt32(); + m_Played_time[PLAYED_TIME_TOTAL]= fields[20].GetUInt32(); + m_Played_time[PLAYED_TIME_LEVEL]= fields[21].GetUInt32(); m_resetTalentsCost = fields[25].GetUInt32(); m_resetTalentsTime = time_t(fields[26].GetUInt64()); @@ -16177,9 +16200,9 @@ void Player::SaveToDB() ss << m_cinematic; ss << ", "; - ss << m_Played_time[0]; + ss << m_Played_time[PLAYED_TIME_TOTAL]; ss << ", "; - ss << m_Played_time[1]; + ss << m_Played_time[PLAYED_TIME_LEVEL]; ss << ", "; ss << finiteAlways(m_rest_bonus); @@ -17387,11 +17410,7 @@ void Player::RemoveSpellMods(Spell * spell) checkedSpells.find(aur->GetParentAura()) != checkedSpells.end()) continue; - flag96 const * mask = spellmgr.GetSpellAffect(aur->GetId(), aur->GetEffIndex()); - if (!mask) - mask = &spellInfo->EffectSpellClassMask[aur->GetEffIndex()]; - - if (spell->m_spellInfo->SpellFamilyFlags & *mask) + if (spell->m_spellInfo->SpellFamilyFlags & spellInfo->EffectSpellClassMask[aur->GetEffIndex()]) { checkedSpells.insert(aur->GetParentAura()); spell->m_appliedMods.erase(aur->GetParentAura()); @@ -20360,7 +20379,7 @@ bool Player::isTotalImmune() bool Player::HasTitle(uint32 bitIndex) { - if (bitIndex > 192) + if (bitIndex > MAX_TITLE_INDEX) return false; uint32 fieldIndexOffset = bitIndex / 32; |