diff --git a/src/GameLogic/PlayerActions/Quests/QuestCompletionAction.cs b/src/GameLogic/PlayerActions/Quests/QuestCompletionAction.cs index 72dc18695..8dbb73f61 100644 --- a/src/GameLogic/PlayerActions/Quests/QuestCompletionAction.cs +++ b/src/GameLogic/PlayerActions/Quests/QuestCompletionAction.cs @@ -86,34 +86,35 @@ public async ValueTask CompleteQuestAsync(Player player, short group, short numb foreach (var reward in activeQuest.Rewards) { - await AddRewardAsync(player, reward).ConfigureAwait(false); + await AddRewardAsync(player, reward, activeQuest).ConfigureAwait(false); } await questState.ClearAsync(player.PersistenceContext).ConfigureAwait(false); await player.InvokeViewPlugInAsync(p => p.QuestCompletedAsync(activeQuest)).ConfigureAwait(false); } - private static async ValueTask AddRewardAsync(Player player, QuestReward reward) + private static async ValueTask AddRewardAsync(Player player, QuestReward reward, QuestDefinition quest) { switch (reward.RewardType) { - case QuestRewardType.Attribute: - var attribute = player.SelectedCharacter!.Attributes.FirstOrDefault(a => a.Definition == reward.AttributeReward); - if (attribute is null) - { - attribute = player.PersistenceContext.CreateNew(reward.AttributeReward, 0); - player.SelectedCharacter.Attributes.Add(attribute); - } - - // Compensate level-up points when gaining Hero Status beyond level 220. - if (reward.AttributeReward?.Id == Stats.GainHeroStatusQuestCompleted.Id && attribute.Value == 0) + case QuestRewardType.Attribute: + var attribute = player.SelectedCharacter!.Attributes.FirstOrDefault(a => a.Definition == reward.AttributeReward); + if (attribute is null) { - player.SelectedCharacter!.LevelUpPoints += (int)player.Attributes![Stats.Level] - 220; - } - - attribute.Value += reward.Value; - - await player.InvokeViewPlugInAsync(p => p.ShowAsync(player, QuestRewardType.Attribute, reward.Value, attribute.Definition)).ConfigureAwait(false); + attribute = player.PersistenceContext.CreateNew(reward.AttributeReward, 0); + player.SelectedCharacter.Attributes.Add(attribute); + } + + attribute.Value += reward.Value; + + // Compensate level-up points when doing a quest at a later level. + if (attribute.Definition == Stats.PointsPerLevelUp) + { + var playerLevel = (int)player.Attributes![Stats.Level]; + player.SelectedCharacter.LevelUpPoints += (playerLevel - quest.MinimumCharacterLevel) * reward.Value; + } + + await player.InvokeViewPlugInAsync(p => p.ShowAsync(player, QuestRewardType.Attribute, reward.Value, attribute.Definition)).ConfigureAwait(false); break; case QuestRewardType.Item: var item = player.PersistenceContext.CreateNew();