How to add a status after critical hit (MZ)

I want to implement a mechanic in my game, when a critical hit occurs a state is applied to whoever suffered the damage, be it actor or enemy. I also use visustella's battler core plugin if that can make anything easier.
So in the BattleCore under "Mechanical Settings" you can set it so that a Switch turns on when anyone lands a Critical Hit.
Critical.png


It doesn't have to be Switch 66, so for the rest of the example, let's call this 'x' and x will be whatever Switch you decide to use. You don't have to worry about resetting Switch x, since it will turn off at the start of the next action.

Next you need to create a Passive State; this will require the SkillsStateCore plugin.
Create a state, name it whatever you want, then in the Note section of the state put in this code:
Code:
<JS Passive Condition>
 condition = $gameSwitches.value(x);
</JS Passive Condition>

<JS Post-Damage as Target>
 target.addState(y);
</JS Post-Damage as Target>

This will made the passive state active ONLY when Switch x is ON and only apply State y to the one receiving the damage.
Replace 'x' with the Critical Hit Switch number and replace 'y' with the state number you want to apply when a critical hit lands.

Finally in the SkillsStateCore plugin, in the Passive States parameters, there's an option to apply Passive States to all Actors and Enemies, it's called Global Passives and it looks like this:
Global.png


Assign the state that you created to it and you are done! I hope it works for you.
I'm wondering if all this work with switches and passive states is actually necessary.

In VX Ace one simply put it in the damage formula like this:
Code:
if b.result.critical; b.add_state(2); end;a.atk * 4 - b.def * 2
Is it really the case that MZ does not have an equivalent to b.result.critical?
So in the BattleCore under "Mechanical Settings" you can set it so that a Switch turns on when anyone lands a Critical Hit.
View attachment 255553

It doesn't have to be Switch 66, so for the rest of the example, let's call this 'x' and x will be whatever Switch you decide to use. You don't have to worry about resetting Switch x, since it will turn off at the start of the next action.

Next you need to create a Passive State; this will require the SkillsStateCore plugin.
Create a state, name it whatever you want, then in the Note section of the state put in this code:
Code:
<JS Passive Condition>
 condition = $gameSwitches.value(x);
</JS Passive Condition>

<JS Post-Damage as Target>
 target.addState(y);
</JS Post-Damage as Target>

This will made the passive state active ONLY when Switch x is ON and only apply State y to the one receiving the damage.
Replace 'x' with the Critical Hit Switch number and replace 'y' with the state number you want to apply when a critical hit lands.

Finally in the SkillsStateCore plugin, in the Passive States parameters, there's an option to apply Passive States to all Actors and Enemies, it's called Global Passives and it looks like this:
View attachment 255554

Assign the state that you created to it and you are done! I hope it works for you.

It didn't work for me, I did everything as you said, but in battle when I land a critical hit it seems that it inflicts the global state itself for an instant and then the state disappears, it doesn't inflict the other state.
Screenshot_1.png

That's the global state note section, it should inflict state 63 right? but he ends up inflicting himself as I said, it happens very quickly and then the state disappears.
Change it from target.addState(63); to user.addState(63); and see what happens.
Nothing has changed, it's still the same, here's the clean project
Okay, I think I solved your problem and good news! You don't need the Global Passive State! So you can delete state 4.

What you need to do is add this in the Note Section of every Skill you want this effect to happen:
Code:
<JS Post-Damage>
 if(target.result().critical == true)
 {
    target.addState(5);
 }
</JS Post-Damage>

And that's it. Sorry it took so long for me to get around to this.
Worked perfectly, thanks CrocPirate 👍😉

Original thread: https://forums.rpgmakerweb.com/threads/how-to-add-a-status-after-critical-hit-mz.155665/