Skip to content

fix: set Player::ChangeExp to use internal func#255

Open
shad0wshayd3 wants to merge 3 commits intollde:masterfrom
shad0wshayd3-TES4:ModPlayerSkillExp-Fix
Open

fix: set Player::ChangeExp to use internal func#255
shad0wshayd3 wants to merge 3 commits intollde:masterfrom
shad0wshayd3-TES4:ModPlayerSkillExp-Fix

Conversation

@shad0wshayd3
Copy link

@shad0wshayd3 shad0wshayd3 commented Feb 23, 2026

The original code doesn't properly trigger the game to notify the player about skill increases with corner messages or skill mastery menu popups, and likewise doesn't trigger the OnSkillUse event handler. The UseSkill function that replaces the logic for increasing skill xp does consistently produce these messages, and also applies the same modifications to the passed skill xp amount (with the fSkillUse game settings).

The underlying logic used in the original code does at least seem to function correctly for the purpose of modifying skill xp and setting skill values accordingly, so it's been retained for the negative skill xp code, since it shouldn't 't trigger any of the normal skill increase events anyway.

@shadeMe
Copy link
Collaborator

shadeMe commented Feb 24, 2026

Please update the PR description with some context - Was the replaced code incorrect or does UseSkill perform the exact same calculation? This could be a breaking change.

@llde
Copy link
Owner

llde commented Feb 24, 2026

@shadeMe context is on Discord

@shadeMe
Copy link
Collaborator

shadeMe commented Feb 24, 2026

@shadeMe context is on Discord

Nevertheless, it should be in the PR description foremost (particularly given that Discord isn't searchable from public internet).

@shad0wshayd3
Copy link
Author

@shadeMe added context

@llde
Copy link
Owner

llde commented Mar 1, 2026

@shad0wshayd3 restore .gitmodules please

@llde
Copy link
Owner

llde commented Mar 2, 2026

@shad0wshayd3
I'm looking at the code:
OBSE provide multiple functions to increase the player skill
TriggerPlayerSkillUse
IncrementPlayerSkillUse

IncrementPlayerSKilUse is a 3 arguments function that directly call ModExperience from the PlayerCharacter vtbl.
This function is what call 0x00668B30 internally
TriggerPlayerSkillUse instead call the 3 args variant of ChangeExperience that depending on the last parameter howManyTimes it either call the 2 args ChangeExperience or ModExperience.

What baffle me at the beginning is that howManyTimes cause the invocation of ModExperience if greater then 0 and the manual ChangeExperience if lesser then 0.
There is no equal to 0 check

TriggerPlayerSkillUse docs have:

If howManyTimes is positive, calls the same function as IncrementPlayerSkillUse. Therfore, AttributeBonus is handled correctly at SkillUp.

If howManyTimes is negative, calls the same function as ModPlayerSkillExp. Therfore, AttributeBonus has to be adjusted manually at SkillDown.

Ok this is officially a mess... the names of parameters are all over the place, howManyTimes become baseDelta, whichUse scaleIndex. WTF?
I may need a bit of time to properly decode this mess.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants