Yanfly Skill mastery level Skill Success

pre-mention: I am using pretty much just Yanfly's plugins.

So in my game there is a skill like FF's Protect. However, at lower levels, the chances of it succeeding is low. As you continue to use it (using Yanfly's skill mastery levels) you will level up the skill. Currently in the database, the protect skill has a success of 25%.
the goal is that as you progress in levelling up this skill, the success rate of the skill will increase. The issue is implementing this into the coding.

I assumed that the answer lied within Skill Core using the lunatic <Before Eval> and checking the current mastery level of that skill. If the criteria is met, it would somehow increase the success rate. Is this the route to take? or maybe I am just not using the right scripting for the <Before Eval>

I've attempted
<Before Eval>

if (user.skillMasteryLevel(138) >=1) {

user.skillHitRate(138) +200%;

}

</Before Eval>
this was the test I have used. 138 is the skill ID, to ensure that it would work, I wanted to increase the success rate to 200%.
I think a better approach for this is to set the Protect skill to Certain Hit with 100% success, but in the code, try this:

<After Eval>

var odds = 0.25;

var chance = Math.random();

if (user.skillMasteryLevel(138) >= 1) {

odds += 0.05 * user.skillMasteryLevel(138);

}

if (chance <= odds) {

target.addState(protectStateId);

}

</After Eval>

Rather than changing the success rate of the skill, which can be tricky, the skill runs the above code that adds the state. If the state is added through the trait database, that part should be removed since the database can't run variable odds. Replace protectStateId with the ID of the Protect state, and you should be set.
I will test this out as soon as I get a chance and let you know of the results. Thank you in advance!
I have managed to test it out and....IT WORKED!
thank you again. I added a few modifications to simplify the process. It is:

<After Eval>
var odds = 1
var chance = Math.randomInt(6) + 1;
if (user.skillMasteryLevel(138) >= 1) {
odds += 1 * user.skillMasteryLevel(138);
}
if (chance <= odds) {
target.addState(50);
} else {
target.result().missed=true;
}
</After Eval>

the protect skill is the 138 and the actual state is the 50.
Gotta admit that it feels like its not paying attention to the odds += equation but none-the-less it is working as I feel like it is intended to do.
Thank you again, this was a huge weight off my shoulders. I've been trying to figure this out for a couple days now.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-skill-mastery-level-skill-success.121746/