mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 02:50:29 +00:00
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:
@@ -742,12 +742,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
|
||||
bool rewarded = IsQuestRewarded(quest_id) && !quest->IsDFQuest();
|
||||
|
||||
// Not give XP in case already completed once repeatable quest
|
||||
uint32 XP = rewarded ? 0 : uint32(quest->XPValue(GetLevel()) * GetQuestRate(quest->IsDFQuest()));
|
||||
|
||||
// handle SPELL_AURA_MOD_XP_QUEST_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_QUEST_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
AddPct(XP, (*i)->GetAmount());
|
||||
uint32 XP = rewarded ? 0 : CalculateQuestRewardXP(quest);
|
||||
|
||||
sScriptMgr->OnQuestComputeXP(this, quest, XP);
|
||||
int32 moneyRew = 0;
|
||||
@@ -1398,6 +1393,19 @@ bool Player::TakeQuestSourceItem(uint32 questId, bool msg)
|
||||
return true;
|
||||
}
|
||||
|
||||
uint32 Player::CalculateQuestRewardXP(Quest const* quest)
|
||||
{
|
||||
// apply world quest rate
|
||||
uint32 xp = uint32(quest->XPValue(GetLevel()) * GetQuestRate(quest->IsDFQuest()));
|
||||
|
||||
// handle SPELL_AURA_MOD_XP_QUEST_PCT auras
|
||||
Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_QUEST_PCT);
|
||||
for (Unit::AuraEffectList::const_iterator i = ModXPPctAuras.begin(); i != ModXPPctAuras.end(); ++i)
|
||||
AddPct(xp, (*i)->GetAmount());
|
||||
|
||||
return xp;
|
||||
}
|
||||
|
||||
bool Player::GetQuestRewardStatus(uint32 quest_id) const
|
||||
{
|
||||
Quest const* qInfo = sObjectMgr->GetQuestTemplate(quest_id);
|
||||
|
||||
Reference in New Issue
Block a user