MZ Make a Proper 1 Action "Stun" State.

To lay out things first:
1). State with restriction of 'Cannot Move' will force the Auto-removal Timing to Turn End to prevent unending state effect. (You cannot use Action End on a 'Cannot Move' state).
2). I'm using the STB battle system from Visustella, and I want to make Stun state that lasts for 1 action. Turn End in this case does not work since the state will be purged in the next turn eventhough the target has not taken an action.

My goal:
1). Make a proper Stun state for 1 action, where the target is not able to move on said action.

My workaround so far:
1). I figured, I could use the JS: Pre-Start Action to check if the target is affected by state 12 (Stun) and if so, force them to use a blank skill, therefore effectively "Stun" them.
2). Set the Stun state without any restriction and make the Auto-removal Timing Action End for 1 turn.

Here is said code for JS: Pre-Start Action
JavaScript:
// Declare Constants
const value = arguments[0];
const user = this.subject();
const target = user;
const a = user;
const b = user;
const action = this;
const item = this.item();
const skill = this.item();

// Perform Actions
if (user.isStateAffected(12)) {
    action.setSkill(21);
    action.setItemObject($dataSkills[21]);
    action.apply(user);
    return;
}
//Skill 21 is a blank skill, using skill 0 also has the same effect.

Findings:
1). This works great for the enemies. When they are stunned, they do nothing essentially (force action skill 21).
2). But when the player / actor is stunned, we, the player, still able to choose any action from the the command list (Attack/Guard/Skill/etc.). ALTHOUGH, choosing any command will result in performing skill 21 nonetheless.
*So if you choose Attack, you do nothing, if you choose Guard you still do nothing.

I need help:
I need help or guidance on how to tackle the player/actor problem so that you skip the choosing command phase and straight up do nothing. Any help/suggestion/idea will help. Honestly maybe I overthink the way to do it.
I also can provide you with screen captures if that is any help.

And so, thank you in advance and I really appreciate any help given
❤️
.
Hmmm, I didn't think through all of that, but regarding the 'can input part':
Does it work if you modify the 'canInput' function to add another && condition with that your battler isn't affected by the state in question? (Or modify the 'isRestricted' to account for your state.)
the 'canInput' function to add another && condition with that your battler isn't affected by the state in question? (Or modify the 'isRestricted' to account for your state.)
Thanks for the reply!

As you said, I made a plugin to add a check requirement in the 'canInput' function to check if the battler is not affected by the state 'Stun'. It works for the enemies, and to an extent the actors.

But the new problem is:
It checks the actor whether they are affected by state Stun or not. If so, they skip the command input (which is good). But since technically they did not take their actions, the Stun state does not expire which leads to unending Stun state.

Maybe I did something wrong? It is weird that it works with the enemies, though.

EDIT: Here's an insight. I put a name on the blank skill so I know when they actually use the skill. The enemies seem to use the blank skill, but the actors don't. Maybe this is the fact that the actor skips their command input and therefore not forcing the blank skill action?
Can't you put in the modified function that:
if all the conditions are true -> return 1
else -> remove the state from the battler and return 0

(Again, I'm just commenting on the canInput stuff. Don't know if there's a better/simpler way to do what you want to do.)

edit: edited to remove state in else part
I need help or guidance on how to tackle the player/actor problem so that you skip the choosing command phase and straight up do nothing.

I found a simple solution that works flawlessly with your code for JS: Pre-Start Action:

Add "Special Flag: Auto Battle" to the Stun State (under Traits).

The command input feels like it gets skipped when, in reality, the AI handles it. Plus, there's no unending Stun state because the battler technically does an action (Skill 21).

(I also created a Custom Action Sequence for Skill 21 with Battle Step and Cast Animation turned off. Makes it cleaner, in my opinion.)

Let me know if this works!
I just tested this (cePapillon's code and the auto-battle flag) because I was having the same problem. So far it works beautifully! Thanks so much!
I'm using VisuMZ's STB battle system as well, and the only way I got it to work as intended was setting the auto-removal duration to 0 ~ 0 on the State settings. Setting it to 1 action makes them actually lose 2 turns for some reason.

I found that if I stun an ally that hasn't acted in that round, they don't actually do the empty skill, which I temprorarily made to do a little animation to check if they were actually performing it. But they still lose their turn and return to normal afterwards, so it's moot.

Original thread: https://forums.rpgmakerweb.com/threads/make-a-proper-1-action-stun-state.174357/