A State That Has Chance To Consume Zero Energy

Hi, I was wondering if there was a way to implement a state that if applied to a character, they have a chance to use zero energy when using a skill or attacking? I'm currently using have handful of Yanfly Plugins, but I have yet to come across a post or a video of someone's whose made something similar.
By energy, are you perhaps referring to MP or TP?

You could use the custom MP/TP cost notetags in all skills that should be affected by the state.

Code:
<Custom MP Cost>
if(user.isStateAffected(n) && Math.random() < 0.3)
{
  cost=0;
}
</Custom MP Cost>
Replace 'n' with the ID of the state. This would give a 30% chance for the skill to cost 0 MP if the user is affected by said state. You can also replace 0.3 with any other values between 0 and 1 if you'd like a different success rate. (0 = 0%, 1 = 100%)

While not necessary, I'd suggest using Victor's notes text file plugin if you're going to have a lot of skills, for convenience sake.

By energy, are you perhaps referring to MP or TP?

You could use the custom MP/TP cost notetags in all skills that should be affected by the state.

Code:
<Custom MP Cost>
if(user.isStateAffected(n) && Math.random() < 0.3)
{
  cost=0;
}
</Custom MP Cost>
Replace 'n' with the ID of the state. This would give a 30% chance for the skill to cost 0 MP if the user is affected by said state. You can also replace 0.3 with any other values between 0 and 1 if you'd like a different success rate. (0 = 0%, 1 = 100%)

While not necessary, I'd suggest using Victor's notes text file plugin if you're going to have a lot of skills, for convenience sake.

Sorry I completely forgot I asked this question, but thanks it's really helpful.

Original thread: https://forums.rpgmakerweb.com/threads/a-state-that-has-chance-to-consume-zero-energy.147844/