fix(Core/Quest): Correct XP Display when modified by SPELL_AURA_MOD_XP_QUEST_PCT (#19060)

* fix(Core): Correct Quest XP Display when modified by SPELL_AURA_MOD_XP_QUEST_PCT

The quest XP displayed on the gossip window was not modified for auras that increase quest XP gain (e.g. spell ID 57353). This commit corrects the quest XP display when accepting/returning quests.

* refactor(Entities/Player): Added a `CalculateQuestRewardXP()` function to reduce duplicated code

* cleanup(Entities/Creature): Removed now unused variable `playerLevel`

* Apply suggestions from code review

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>

---------

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
This commit is contained in:
atrapalis
2024-06-19 01:41:39 +03:00
committed by GitHub
parent 90de4bb230
commit dea3748629
3 changed files with 17 additions and 10 deletions
@@ -451,7 +451,6 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU
uint32 moneyRew = 0;
Player* player = _session->GetPlayer();
uint8 playerLevel = player ? player->GetLevel() : 0;
if (player && (player->getLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player)))
{
moneyRew = quest->GetRewMoneyMaxLevel();
@@ -461,7 +460,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, ObjectGuid npcGU
uint32 questXp;
if (player && !sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player))
{
questXp = uint32(quest->XPValue(playerLevel) * player->GetQuestRate());
questXp = player->CalculateQuestRewardXP(quest);
}
else
{
@@ -704,7 +703,6 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUI
uint32 moneyRew = 0;
Player* player = _session->GetPlayer();
uint8 playerLevel = player ? player->GetLevel() : 0;
if (player && (player->GetLevel() >= sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL) || sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player)))
{
moneyRew = quest->GetRewMoneyMaxLevel();
@@ -714,7 +712,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, ObjectGuid npcGUI
uint32 questXp;
if (player && !sScriptMgr->ShouldBeRewardedWithMoneyInsteadOfExp(player))
{
questXp = uint32(quest->XPValue(playerLevel) * player->GetQuestRate());
questXp = player->CalculateQuestRewardXP(quest);
}
else
{