State that goes away when you run out of MP of TP?

I'm wanting there to be a state which gives the user a buff, but slowly drains their MP or TP. When that runs out, it should go away. Is there a plugin that could make this possible? Would anyone be up for making one?
Yanfly's buffs and states core.
This plugin can do most of the thing you require.
Specifically, with Yanfly's Buffs & States plugin you could put something like this in your state's notebox:
Code:
<Custom Turn End Effect>
if (user.mp <= 0) {
  user.removeState(state.id);
}
</Custom Turn End Effect>
I.e. at the end of each turn it'll check the affected battler's MP, and if MP = 0 the state will remove itself. You might want to use a different tag, maybe Action End instead of Turn End, depending on when it should check. To check TP instead of MP, just replace mp with tp.
Specifically, with Yanfly's Buffs & States plugin you could put something like this in your state's notebox:
Code:
<Custom Turn End Effect>
if (user.mp <= 0) {
  user.removeState(state.id);
}
</Custom Turn End Effect>
I.e. at the end of each turn it'll check the affected battler's MP, and if MP = 0 the state will remove itself. You might want to use a different tag, maybe Action End instead of Turn End, depending on when it should check. To check TP instead of MP, just replace mp with tp.

Ok, thanks. One other question: Is there a way to have it reduce the amount of MP by a specific amount?
Ok, thanks. One other question: Is there a way to have it reduce the amount of MP by a specific amount?
You could use another buffs & states notetag on the skill, e.g.
Code:
<Custom Regenerate Effect>
user.gainMp(-10);
</Custom Regenerate Effect>

Original thread: https://forums.rpgmakerweb.com/threads/state-that-goes-away-when-you-run-out-of-mp-of-tp.103679/