aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorOvahlord <dreadkiller@gmx.de>2024-06-14 03:38:26 +0200
committerOvahlord <dreadkiller@gmx.de>2024-06-14 03:38:26 +0200
commit9687039d1c0c75a94cf32560c81460d242795ee0 (patch)
treecf2d1d035d018b88388ecefc5462ddb48e705172 /src
parent38c2efe5d1b8aee1752c1b70eacd575c64ed1e97 (diff)
Core/Quests: implement quest level scaling
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Quests/QuestDef.cpp64
-rw-r--r--src/server/game/Quests/QuestDef.h3
-rw-r--r--src/server/game/Spells/SpellEffects.cpp2
3 files changed, 39 insertions, 30 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();
diff --git a/src/server/game/Quests/QuestDef.h b/src/server/game/Quests/QuestDef.h
index 113917e6067..715ec970bf8 100644
--- a/src/server/game/Quests/QuestDef.h
+++ b/src/server/game/Quests/QuestDef.h
@@ -532,12 +532,13 @@ class TC_GAME_API Quest
void LoadConditionalConditionalQuestCompletionLog(Field* fields);
uint32 XPValue(Player const* player) const;
- static uint32 XPValue(Player const* player, int32 questLevel, uint32 xpDifficulty, float xpMultiplier = 1.0f, int32 expansion = -1);
+ static uint32 XPValue(Player const* player, uint32 questLevel, int32 questMinLevel, uint32 xpDifficulty, float xpMultiplier = 1.0f, int32 expansion = -1);
uint32 MoneyValue(Player const* player) const;
uint32 MaxMoneyValue() const;
uint32 GetMaxMoneyReward() const;
Optional<QuestTagType> GetQuestTag() const;
bool IsImportant() const;
+ uint32 GetQuestLevelForPlayer(Player const* player) const;
bool HasFlag(QuestFlags flag) const { return (_flags & uint32(flag)) != 0; }
bool HasFlagEx(QuestFlagsEx flag) const { return (_flagsEx & uint32(flag)) != 0; }
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index e9a0197b312..e7474d63580 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -5406,7 +5406,7 @@ void Spell::EffectGiveExperience()
if (!playerTarget)
return;
- uint32 xp = Quest::XPValue(playerTarget, effectInfo->MiscValue, effectInfo->MiscValueB);
+ uint32 xp = Quest::XPValue(playerTarget, 0, 0, effectInfo->MiscValueB);
playerTarget->GiveXP(xp, nullptr);
}