MZ MP cost based on target status

Hi.
I'm trying to create a skill in MZ with a conditional MP cost based on the target applied status.

In short:
The skill A has a 10 MP cost, but if the target has the Poison state, then the cost will be zero.

I tried config this with my limited coding skill, but have no success. 🙁
Someone knows how to do this?

Ps: I'm currently using the VisuStella Core plugins.
there is a simple way to do this even without a plugin, if you allow for a slight limitation:
have the skill cost always be 10 MP (set in the database) and refund 10 MP by damage formula coding if the target is found to have that state.

The limitation is that this only works for single-target-skills, because a multiple-target-skill would have the risk of refunding multiple times.
there is a simple way to do this even without a plugin, if you allow for a slight limitation:
have the skill cost always be 10 MP (set in the database) and refund 10 MP by damage formula coding if the target is found to have that state.

The limitation is that this only works for single-target-skills, because a multiple-target-skill would have the risk of refunding multiple times.

Thanks for the quick response.
Yeah, that's a problematic limitation, cause I intended to create multiple-target skills.
Other limitation would be if the user has no MP, he couldn't use the skill. 🙁
cause I intended to create multiple-target skills.
Then you don't explain if ANY or ALL of the target has the state. Your explanation is for a single target attack.
I was able to solve my problem using damage formula:

if ( b.isStateAffected(4) ) { a.atk * 1.25; } else { a.gainMp(-50); a.atk * 1.25; }

And in the database, I set the skill to zero MP cost.

However, when the MP is deducted there is a "MP damage" popup. I'll try to hide it.
@Forastero But wouldn't the skill then be able to be used at 0 MP? Players could cheat the system in that case.
@Forastero But wouldn't the skill then be able to be used at 0 MP? Players could cheat the system in that case.

Thanks for the reply!

Actually, thats more or less my intention. 😀
In my game the MP is replaced by stamina, and the "stamina cost" refers to "the difficulty to overcome the enemy defense".

The status that I want to check refers to the "defense exposure".
So, if the target has that status, there is no defense to overcome, then the character will not use stamina to perform the skill.

Btw, the players wouldnt be able to abuse this system because that status does not occur frequently.

Basically that.
if ( b.isStateAffected(4) ) { a.atk * 1.25; } else { a.gainMp(-50); a.atk * 1.25; }
but this will have the same problem as my solution with multiple targets as the damage formula gets executed on every target.
but this will have the same problem as my solution with multiple targets as the damage formula gets executed on every target.

I noticed that too.

So, I ll have to adapt to that. 😳

Original thread: https://forums.rpgmakerweb.com/threads/mp-cost-based-on-target-status.133482/