MV/MZ state that nullifies X amount of attacks then goes away?

I want to make a "dodge" status that lets the user dodge one attack. How do I make a state go away when the user dodges an attack?
Greetings!

Here is one way in which you could do exactly what you want in MZ using the Visustella Battle Core ->

First, create two states. I called them Dummy Dodge (State 121) and Dodge (State 122).

On the first state, apply an Icon of your choice (so it can be seen on the battler) and add the following code to the notebox:

<JS Pre-Apply as Target>
if (this.isPhysical()) {;
target.removeState(121)
};
</JS Pre-Apply as Target>

Next, we'll create the Dodge state. Give this state no Icon whatsoever (so it is hidden), apply an Ex-Parameter Evasion buff of 999% in the State's Traits box, and then add the following code to its notebox:


<JS Post-Apply as Target>
if (!target.isStateAffected(121)) {
target.removeState(122)
};
</JS Post-Apply as Target>


Finally, when you go to use the Skill or Item that applies your Dodge State, make sure it applies both Dummy Dodge and Dodge to the Battler.

------------

What will happen is only the Dummy Dodge Icon will be shown and the Dodge state will be hidden. Then, when an enemy makes a Physical attack against a Battler, the Dummy Dodge State will be removed, the attack will be evaded, and then the Dodge State will be removed as Dummy Dodge is no longer active.

You can take this logic and apply it to other effects by changing the this.isPhysical() part of the code along with the Traits section of your Dodge State, as well 🙂.

Happy game making,
-Niniann
Just to note, this is the MV section and their account's primary engine is MV. Although just swapping the notetags for Yanfly Buffs and States Core equivalents should keep the effect intact, i dont believe you need a 2nd state either? I think that just having the one state and checking if the target's result indicated it didnt connect should be sufficient

using Yanfly's Buffs and States core...
Single state - give it a maximum evasion trait and this in the notetag.
Code:
<Custom Deselect Effect>
if (!target.result().isHit())
  target.removeState(stateId);
</Custom Deselect Effect>
dont put the state's id in the notetag. stateId grabs the state's id automatically
Just to note, this is the MV section and their account's primary engine is MV. Although just swapping the notetags for Yanfly Buffs and States Core equivalents should keep the effect intact, i dont believe you need a 2nd state either? I think that just having the one state and checking if the target's result indicated it didnt connect should be sufficient

using Yanfly's Buffs and States core...
Single state - give it a maximum evasion trait and this in the notetag.
Code:
<Custom Deselect Effect>
if (!target.result().isHit())
  target.removeState(stateId);
</Custom Deselect Effect>
dont put the state's id in the notetag. stateId grabs the state's id automatically
Ahh fair point, I saw the MZ tag in the title of the thread, didn't bother to check what section of the forum this was in, hehe.

For posterity's sake I converted Robro33's idea into a notetag that works with Visustella MZ (remove the physical part if the skill is meant for dodging magic too):

<JS Post-Apply as Target>
if (this.isPhysical() && !target.result().isHit())
target.removeState(stateId);
</JS Post-Apply as Target>

This should work just the same as the 2 States idea I posted earlier for MZ. Don't remember why I did it with two States before, just what I came up with at the time 🙂. But I think Robro33's method is cleaner.

Original thread: https://forums.rpgmakerweb.com/threads/state-that-nullifies-x-amount-of-attacks-then-goes-away.183470/