How do I create states In RPG maker MV that are dictated by mp percentage?

So, I want to create an effect based off of mp percentage. For example, If a character's mp was below 10%, they would have a speed debuff. I've already looked in the troop events, but the only percentages there are for health.
Is this for your players or enemies?
for both
There are normally multiple solutions to any problems. Here's one that i can think of.


- Install Yanfly's Auto Passive State.


- Create a state without icon that reduces AGI. You can use icon to verify and check. Note the id of this state


- Put the following notetag into ALL of your actors and enemies. Change x to the id of the state above:


<Passive State: x>




- Put the following notetag into the speed debuff state:


<Custom Passive Condition>
if ((user.mmp > 0) && (user.mpRate() <= 0.10)) {
condition = true;
} else {
condition = false;
}
</Custom Passive Condition>





So what this notetag does is apply this state when user's MaxMP is more than 0 (to prevent weird behaviour when MaxMP is 0) and MP is at 10% or below.


Hope that helps!


- Riff
It did, thanks!

Original thread: https://forums.rpgmakerweb.com/threads/how-do-i-create-states-in-rpg-maker-mv-that-are-dictated-by-mp-percentage.59544/