Open Hanter-19 opened 1 year ago
First attempt to fix was tested by Bella'kor.
This time, we detected a bug where drinking the Potion of Oblivion resulted in the character getting refunded more points than they were supposed to based on the number of times they leveled up.
The resetPerks
function iterates over all of the character's skills and counts any Skill object that is the Perk type. This means that additional Perks added after refunding FE perks will get included in this count, therefore inflating the number of perk points refunded by resetPerks
In the same hook that I wrote for resetPerks
, add some logic to reduce the actor's total perk points (after resetPerks
has been called). We will reduce the amount by the number of FE flags that we removed (therefore accounting for the inflated points)
My brain is too tired to work out the details right now, but we will need to consider what is the effect of the Proposed Solution for the following edge case:
Will revisit this potential edge case next time and analyse the impact.
By following the Proposed Solution outlined in the previous comment, the Possible Edge Case raised would be handled.
Consider the following example:
A character has spent 2 Perk Points, 1 on a Favoured Enemy Perk and 1 on some other refundable perk:
Number of Perks Owned | Number of Available Perk Points |
---|---|
2 | 0 |
The character has just fulfilled the requirement to refund the Favoured Enemy Perk Point:
Number of Perks Owned | Number of Available Perk Points |
---|---|
2 | 1 |
The character drinks the Potion of Oblivion and resets their perk points, which initially results in the following:
Number of Perks Owned | Number of Available Perk Points |
---|---|
0 | 3 |
Following the Proposed Solution, we would have counted 1 Flag for having fulfilled the Favoured Enemy Refund, so we would subtract 1 Perk Point from the Number of Available Perk Points, resulting in the following:
Number of Perks Owned | Number of Available Perk Points |
---|---|
0 | 2 |
Thus, we have successfully started with 2 Perks Owned and ended with 2 Available Perk Points.
The above illustration shows that our Edge Case is handled by the Proposed Solution
Reported by Bella'kor on Discord: https://discord.com/channels/547043336465154049/1088956924516634707/1112341341452640316
To summarize the issue:
Current Behaviour
Expected Behaviour
Code Analysis and Proposed Fix
Currently the FE Perk refund process checks for the existence of a flag in the actor, and will only refund the point if the flag is not already present. (see
legend_favoured_enemy_skill.onUpdate()
)When drinking Potion of Oblivion, the flags are not removed, so when the Player picks the FE Perk again, this check will detect the flags and not refund the Perk Point.
I propose we hook the
entity/tactical/actor.resetPerks()
function to also remove all FE Perk-related flags in the actor.