Yanfly Skill Mastery Levels Conditional Check

http://www.yanfly.moe/wiki/Skill_Mastery_Levels_(YEP)

I'm currently using the above in my project.

I'd like to create a training system. If the skill level is less than a certain value then for a price the trainer can increase it for you.

Yanfly provided the code for how to edit a skill level.

Code:
battler.gainSkillMasteryLevel(skillId, value)

So on its own that's fine. I'm just struggling with the "If the skill level is less than" part.

And there also seems to be a code that checks the value of the skill level and runs a common event.

Code:
<After Eval>
if (user.skillMasteryLevel(item.id) >= 3) {
  $gameTemp.reserveCommonEvent(5)
}
<After Eval>

"The above code will make a check to see if the user's current mastery level
of the skill is greater than or equal to 3. If it is, common event 5 will be
reserved and ran once applicable." - From the help section

But when I created a common event for my trainer nothing happened.

These were "Skill Notetag" examples however.

I'm looking for a way to have the trainer check to see that the skill is less than a certain amount and then offer to train it only if it is less than said amount.

As always any help would be appreciated.

Thanks.

EDIT: If there is somehow a way to set the skill mastery level of various skills to a variable that would be most ideal.
You can get around this using Yanfly's passive states and some js. I just recently did this for my game in which i wanted my skills to change scope based upon skill mastery. Basically, you'll want to have it so that if you skill mastery is below a certain level, then the passive state will be off.

Spoiler: Custom Passive
<Custom Passive Condition>
if (user.skillMasteryLevel(41) > 5) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>

Please change the numbers in italics to your desired skill and then the desired level in which to deactivate the ability to train.

Then in your event, just have it check for the passive state, if the state is on, then no training is available. Keep in mind that if you have more than one character, you will need a conditional for each one.
@Johnboy Thanks for your help. I must have done something wrong however as having the passive state caused the game to have so much lag it literally became unplayable.
Hmmm. Passive states shouldn't cause much lag. I have almost 100 due to the various innate abilities and mastery levels in my game and experience no lag. Perhaps you can take a couple screenshots of your plugin list and note tags and upload them here? I'd be happy to help you get to the bottom of it.
Spoiler: Plugins
2019-10-14 (1).png 2019-10-14 (2).png 2019-10-14 (3).png
Spoiler: State Notetag
Code:
<Custom Passive Condition>

if (user.skillMasteryLevel(6) > 5) {

condition = true;

} else {

condition = false;

}

</Custom Passive Condition>
​
Spoiler: Actor Notetag
Code:
<Passive State: 69 to 72>



<Custom Face Image Eval>

if (user.isStateAffected(59)) {

faceName = 'Concerned Kevin';

faceIndex = 0;

} else if (user.isStateAffected(60)) {

faceName = 'Concerned Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(61)) {

faceName = 'Hurt Kevin';

faceIndex = 0;

} else if (user.isStateAffected(67)) {

faceName = 'Hurt Kevin';

faceIndex = 0;

} else if (user.isStateAffected(4)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(5)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(6)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(7)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(8)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(9)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(11)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(12)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(41)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(42)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(43)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(62)) {

faceName = 'Hurt Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(63)) {

faceName = 'Kevin KO';

faceIndex = 0;

} else if (user.isStateAffected(64)) {

faceName = 'Kevin KO 2';

faceIndex = 0;

} else if (user.isStateAffected(65)) {

faceName = 'Kevin';

faceIndex = 0;

} else if (user.isStateAffected(66)) {

faceName = 'Kevin 2';

faceIndex = 0;

} else if (user.isStateAffected(10)) {

faceName = 'Thoughtful Kevin 2';

faceIndex = 0;

}

</Custom Face Image Eval>

Regarding the Actor Notetag.- Passive state 69 to 72 refer to the states I wish to apply to my actor regarding training. There will eventually be 16 states.
Each State have notetags identical to the one I shared in the "State Notetag" Spoiler with the only change being the number referring to the skill.
The rest of the code on the actor has to do with another plugin I am using to change actor face images in battle depending on different conditions.
It is the last plugin on the list.

Currently I am unable to even recreate the problem with the lag as the passive states do not seem to be applying themselves despite the conditions being met. My actor knows the required move and it is below skill mastery level 5.

Thanks again for your willingness to help.
I see you have Victor's Core loaded twice in your plugin list. I highly doubt that it will be the root cause of this issue, but it might cause all sorts of other issues at a later date.

Everything seems to be good other than that. I am assuming skill 6 needs to be below skill mastery level 5 to be able to train in it? If so then your notetag appears correct.

Could I see your event that you would call to train a skill level? I'll see if I can replicate everything in the next day or so
So regarding the lag.
Originally I had wanted a training system where the price would vary on the skill level.
I have 2 skills from each of the 8 default elements. One that hits a single enemy and one that hits all enemies.
Skill mastery levels range from 0 to 10
I had a state assigned for each mastery level.
Code:
<Custom Passive Condition>
if (user.skillMasteryLevel(6) = 0) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>
As you can see I altered the code that you provided slightly from a ">" to a "=".

I have 8 trainers. 1 for each element.
I tested this system on the first trainer who specializes in Fire.

I had 22 passive states assigned for that trainer alone.

Code:
<Passive State: 69 to 90>>

Spoiler: Fire Trainer Event
2019-10-14 (8).png 2019-10-14 (9).png

The above proceeds to check for each of the 22 separate conditions and train accordingly.

And this is where the game breaking lag occurred.

If it was this bad for 22, I can only imagine what it would have been for 176. 22 states to check for 8 different elements.

That's why I thought it would be best to assign a variable to the amount of the skill mastery levels. 16 variables is better than 176 passive states.

So then I went with the ">5" passive state from my previous post.
The event is the same except each skill has a state that checks to see if it is greater than 5.
And training only is available if the skill is less than 5. At a later point in the game I would create a state to check if it is less than 10 to unlock more training options.

So ultimately 32 passive states would be needed.

And it was at this point that the >5 states would not even apply themselves if conditions were met.

I have also since discovered another issue.

Code:
battler.gainSkillMasteryLevel(6, 1)

The code I was using to change the skill levels in training doesn't seem to have any effect.

EDIT: Also thanks for pointing out the Victor Engine thing. I hadn't noticed that.
You changed a '>' to a '=' so instead of each state checking if the mastery value is a number, each one is setting it to that number. You need to use '==' in an if check.
That is probably going to explain the lag, as each state is going to be spam changing that value continuously all the time.
Thanks! That dealt with the lag. The states are also applying themselves. Now the only issue that seems to remain is the fact that the training doesn't seem to have any affect.
Code:
battler.gainSkillMasteryLevel(skillId, value)

- 'battler' is a variable that represents an actor/enemy. Replace 'skillId'
with the ID of the skill whose mastery level you wish to increase.
Replace 'value' with the amount of levels to increase (or decrease) the
skill's current mastery level by.

Still having issues getting the above to work properly. If anyone can help I'd appreciate it.



Code:
battler.gainSkillMasteryLevel(6, 1)

This is what I used. I'm trying to make Skill 6 increase by one level. It doesn't have any effect however.

Am I supposed to do something with the "battler" part?


​

I've moved this thread to Plugin Support. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-skill-mastery-levels-conditional-check.114230/