diff options
author | megamage <none@none> | 2009-01-22 22:44:27 -0600 |
---|---|---|
committer | megamage <none@none> | 2009-01-22 22:44:27 -0600 |
commit | ab4b9160f2d1d534832372422fd1e2bc514b808a (patch) | |
tree | ee5ec121b585b419ff8ec38193ec008d930e75da /src/game/Player.cpp | |
parent | 4230318f962f5faeddf188d61a367a635a8bb81a (diff) |
*Update to Mangos 7151.
--HG--
branch : trunk
Diffstat (limited to 'src/game/Player.cpp')
-rw-r--r-- | src/game/Player.cpp | 76 |
1 files changed, 51 insertions, 25 deletions
diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 3a8ebeede4d..ccf3eefcb6f 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -301,6 +301,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this) m_comboPoints = 0; m_usedTalentCount = 0; + m_questRewardTalentCount = 0; m_regenTimer = 0; m_weaponChangeTimer = 0; @@ -430,7 +431,7 @@ Player::Player (WorldSession *session): Unit(), m_achievementMgr(this) for (int i = 0; i < MAX_COMBAT_RATING; i++) m_baseRatingValue[i] = 0; - + m_baseSpellDamage = 0; m_baseSpellHealing = 0; m_baseFeralAP = 0; @@ -2351,7 +2352,8 @@ void Player::InitTalentForLevel() } else { - uint32 talentPointsForLevel = uint32((level-9)*sWorld.getRate(RATE_TALENT)); + uint32 talentPointsForLevel = CalculateTalentsPoints(); + // if used more that have then reset if(m_usedTalentCount > talentPointsForLevel) { @@ -3273,8 +3275,7 @@ bool Player::resetTalents(bool no_cost) CharacterDatabase.PExecute("UPDATE characters set at_login = at_login & ~ %u WHERE guid ='%u'", uint32(AT_LOGIN_RESET_TALENTS), GetGUIDLow()); } - uint32 level = getLevel(); - uint32 talentPointsForLevel = level < 10 ? 0 : uint32((level-9)*sWorld.getRate(RATE_TALENT)); + uint32 talentPointsForLevel = CalculateTalentsPoints(); if (m_usedTalentCount == 0) { @@ -4654,7 +4655,7 @@ float Player::OCTRegenMPPerSpirit() void Player::ApplyRatingMod(CombatRating cr, int32 value, bool apply) { m_baseRatingValue[cr]+=(apply ? value : -value); - + int32 amount = uint32(m_baseRatingValue[cr]); // Apply bonus from SPELL_AURA_MOD_RATING_FROM_STAT // stat used stored in miscValueB for this aura @@ -10267,7 +10268,7 @@ uint8 Player::CanEquipItem( uint8 slot, uint16 &dest, Item *pItem, bool swap, bo if(!CanDualWield()) return EQUIP_ERR_CANT_DUAL_WIELD; } - else if (type == INVTYPE_2HWEAPON) + else if (type == INVTYPE_2HWEAPON) { if(!CanDualWield() || !CanTitanGrip()) return EQUIP_ERR_CANT_DUAL_WIELD; @@ -13011,6 +13012,12 @@ void Player::RewardQuest( Quest const *pQuest, uint32 reward, Object* questGiver SetTitle(titleEntry); } + if(pQuest->GetBonusTalents()) + { + m_questRewardTalentCount+=pQuest->GetBonusTalents(); + InitTalentForLevel(); + } + // Send reward mail if(pQuest->GetRewMailTemplateId()) { @@ -14732,16 +14739,15 @@ bool Player::LoadFromDB( uint32 guid, SqlQueryHolder *holder ) _LoadSpells(holder->GetResult(PLAYER_LOGIN_QUERY_LOADSPELLS)); - // after spell load - InitTalentForLevel(); - learnSkillRewardedSpells(); - learnDefaultSpells(); - - // after spell load, learn rewarded spell if need also _LoadQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADQUESTSTATUS)); _LoadDailyQuestStatus(holder->GetResult(PLAYER_LOGIN_QUERY_LOADDAILYQUESTSTATUS)); + // after spell and quest load + InitTalentForLevel(); + learnSkillRewardedSpells(); + learnDefaultSpells(); + _LoadTutorials(holder->GetResult(PLAYER_LOGIN_QUERY_LOADTUTORIALS)); // must be before inventory (some items required reputation check) @@ -15404,6 +15410,9 @@ void Player::_LoadQuestStatus(QueryResult *result) if(CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(pQuest->GetCharTitleId())) SetTitle(titleEntry); } + + if(pQuest->GetBonusTalents()) + m_questRewardTalentCount+=pQuest->GetBonusTalents(); } sLog.outDebug("Quest status is {%u} for quest {%u} for player (GUID: %u)", questStatusData.m_status, quest_id, GetGUIDLow()); @@ -15680,29 +15689,29 @@ InstancePlayerBind* Player::BindToInstance(InstanceSave *save, bool permanent, b void Player::SendRaidInfo() { + uint32 counter = 0; + WorldPacket data(SMSG_RAID_INSTANCE_INFO, 4); - uint32 counter = 0, i; - for(i = 0; i < TOTAL_DIFFICULTIES; i++) - for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) - if(itr->second.perm) counter++; + size_t p_counter = data.wpos(); + data << uint32(counter); // placeholder - data << counter; - for(i = 0; i < TOTAL_DIFFICULTIES; i++) + for(int i = 0; i < TOTAL_DIFFICULTIES; ++i) { for (BoundInstancesMap::iterator itr = m_boundInstances[i].begin(); itr != m_boundInstances[i].end(); ++itr) { if(itr->second.perm) { InstanceSave *save = itr->second.save; - data << (save->GetMapId()); - data << (uint32)(save->GetResetTime() - time(NULL)); - data << save->GetInstanceId(); - data << uint32(counter); - counter--; + data << uint32(save->GetMapId()); + data << uint32(save->GetResetTime() - time(NULL)); + data << uint32(save->GetInstanceId()); + data << uint32(save->GetDifficulty()); + ++counter; } } } + data.put<uint32>(p_counter,counter); GetSession()->SendPacket(&data); } @@ -19251,7 +19260,7 @@ bool Player::isHonorOrXPTarget(Unit* pVictim) if(pVictim->GetTypeId() == TYPEID_UNIT) { - if (((Creature*)pVictim)->isTotem() || + if (((Creature*)pVictim)->isTotem() || ((Creature*)pVictim)->isPet() || ((Creature*)pVictim)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_XP_AT_KILL) return false; @@ -20060,7 +20069,7 @@ void Player::UpdateCharmedAI() void Player::ConvertRune(uint8 index, uint8 newType) { SetCurrentRune(index, newType); - + WorldPacket data(SMSG_CONVERT_RUNE, 2); data << uint8(index); data << uint8(newType); @@ -20125,3 +20134,20 @@ void Player::AutoStoreLootItem(uint8 bag, uint8 slot, uint32 loot_id, LootStore StoreNewItem (dest,lootItem->itemid,true,lootItem->randomPropertyId); } + +uint32 Player::CalculateTalentsPoints() const +{ + uint32 base_talent = getLevel() < 10 ? 0 : uint32((getLevel()-9)*sWorld.getRate(RATE_TALENT)); + + if(getClass() != CLASS_DEATH_KNIGHT) + return base_talent; + + uint32 talentPointsForLevel = + (getLevel() < 56 ? 0 : uint32((getLevel()-55)*sWorld.getRate(RATE_TALENT))) + + m_questRewardTalentCount; + + if(talentPointsForLevel > base_talent) + talentPointsForLevel = base_talent; + + return talentPointsForLevel; +} |