diff options
Diffstat (limited to 'src/server/game/Quests/QuestDef.cpp')
-rw-r--r-- | src/server/game/Quests/QuestDef.cpp | 64 |
1 files changed, 36 insertions, 28 deletions
diff --git a/src/server/game/Quests/QuestDef.cpp b/src/server/game/Quests/QuestDef.cpp index 303d8ad9651..52a9c3ebb59 100644 --- a/src/server/game/Quests/QuestDef.cpp +++ b/src/server/game/Quests/QuestDef.cpp @@ -391,42 +391,30 @@ void Quest::LoadConditionalConditionalQuestCompletionLog(Field* fields) uint32 Quest::XPValue(Player const* player) const { - return XPValue(player, _level, _rewardXPDifficulty, _rewardXPMultiplier, _expansion); + return XPValue(player, GetQuestLevelForPlayer(player) , _minLevel, _rewardXPDifficulty, _rewardXPMultiplier, _expansion); } -uint32 Quest::XPValue(Player const* player, int32 questLevel, uint32 xpDifficulty, float xpMultiplier /*= 1.0f*/, int32 expansion /*= -1*/) +uint32 Quest::XPValue(Player const* player, uint32 questLevel, int32 questMinLevel, uint32 xpDifficulty, float xpMultiplier /*= 1.0f*/, int32 expansion /*= -1*/) { - if (player) - { - uint32 effectiveQuestLevel = questLevel == -1 ? player->GetLevel() : questLevel; - QuestXPEntry const* questXp = sQuestXPStore.LookupEntry(effectiveQuestLevel); - if (!questXp || xpDifficulty >= 10) - return 0; - - uint32 xp = questXp->Difficulty[xpDifficulty]; - - int32 diffFactor = 2 * (effectiveQuestLevel - player->GetLevel()) + 20; - if (diffFactor < 1) - diffFactor = 1; - else if (diffFactor > 10) - diffFactor = 10; - - xp = diffFactor * xp * xpMultiplier / 10; - if (player->GetLevel() >= GetMaxLevelForExpansion(CURRENT_EXPANSION - 1) && player->GetSession()->GetExpansion() == CURRENT_EXPANSION && expansion >= 0 && expansion < CURRENT_EXPANSION) - xp = uint32(xp / 9.0f); + QuestXPEntry const* questXp = sQuestXPStore.LookupEntry(questLevel); + if (!questXp || xpDifficulty >= 10) + return 0; - xp = RoundXPValue(xp); + int32 diffFactor = 2 * (questLevel - (questMinLevel == -1 ? 0 : -5) - (player ? player->GetLevel() : 0)) + 10; + if (diffFactor < 1) + diffFactor = 1; + else if (diffFactor > 10) + diffFactor = 10; - if (sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO)) - { - uint32 minScaledXP = RoundXPValue(questXp->Difficulty[xpDifficulty] * xpMultiplier) * sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO) / 100; - xp = std::max(minScaledXP, xp); - } + uint32 xp = RoundXPValue(diffFactor * questXp->Difficulty[xpDifficulty] * xpMultiplier / 10); - return xp; + if (sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO)) + { + uint32 minScaledXP = RoundXPValue(questXp->Difficulty[xpDifficulty] * xpMultiplier) * sWorld->getIntConfig(CONFIG_MIN_QUEST_SCALED_XP_RATIO) / 100; + xp = std::max(minScaledXP, xp); } - return 0; + return xp; } /*static*/ bool Quest::IsTakingQuestEnabled(uint32 questId) @@ -476,6 +464,26 @@ bool Quest::IsImportant() const return false; } +uint32 Quest::GetQuestLevelForPlayer(Player const* player) const +{ + if (_level != -1) + return static_cast<uint32>(_level); + + int32 questLevel = _minLevel; + if (_level == -1 && _scalingFactionGroup != 0 && player->m_unitData->ScalingFactionGroup != _scalingFactionGroup) + questLevel = _maxScalingLevel; + + int32 playerLevel = player->GetLevel(); + if (playerLevel >= questLevel) + { + questLevel = playerLevel; + if (_maxScalingLevel < playerLevel) + return static_cast<uint32>(_maxScalingLevel); + } + + return static_cast<uint32>(questLevel); +} + void Quest::BuildQuestRewards(WorldPackets::Quest::QuestRewards& rewards, Player* player) const { rewards.ChoiceItemCount = GetRewChoiceItemsCount(); |