MV Yanfly Buffs and States Core- State removal at beginning of turn

I'm trying to create a state using Yanfly's Buffs and States Core, and I need to create a script for the notetag but I don't know how to do it. The state in question is "Staggered"- when applied it sets the restriction that the character cannot move AND causes them to take double damage (the extra damage is handled through damage formula currently which checks for the state, but if someone knows how to handle that in the state itself I'd be grateful).

What I want is for the state to apply to them for one turn and to persist UNTIL their next turn (giving enemies the ability to exploit the extra damage), then for it to be removed at the START of that turn so the character can act again. I don't think it's difficult to achieve, the plug-in even has a "Custom Turn Start" notetag to call a script, I just couldn't figure it out myself. If anyone could help me with this I'd really appreciate it. Thank you!
but if someone knows how to handle that in the state itself I'd be grateful).
Code:
<Custom React effect>
if (this.isDamage())
  value *= 2;
</Custom React effect>

What I want is for the state to apply to them for one turn and to persist UNTIL their next turn (giving attackers the ability to exploit the extra damage), then for it to be removed at the START of that turn so they can act again.
It doesnt sound like you'd need anything written for that. in the battle engine core, theres a notetag specifically to make state timers tick at the start of the turn instead of at the end of the turn. you could use that and give it a duration of 2 turns
Code:
<Custom React effect>
if (this.isDamage())
  value *= 2;
</Custom React effect>


It doesnt sound like you'd need anything written for that. in the battle engine core, theres a notetag specifically to make state timers tick at the start of the turn instead of at the end of the turn. you could use that and give it a duration of 2 turns
Thank you! The damage script worked like a charm, and Battle Engine Core does have that notetag, but I can't get it to do what I want. The state gets removed at the start of the enemy's turn but they still won't act on that turn for some reason.
The state gets removed at the start of the enemy's turn but they still won't act on that turn for some reason.
ah. makes sense actually. im too used to STB. different approach then. try this.
Code:
<Custom Apply Effect>
user._stunned = true;
</Custom Apply Effect>

<Custom Action Start Effect>
if (user._stunned){
  user.clearActions();
  delete user._stunned;
}
else
  user.removeState(stateId);
</Custom Action Start Effect>
youll have to remove the action restriction for this to work.

enemy actions are decided at the start of the turn normally and the state is removed after then, so it would still leave them without an action. this makes it so that if the state is active, once their individual turn rolls around, their action is removed.
Thank you @Robro33 , this script works great!

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-buffs-and-states-core-state-removal-at-beginning-of-turn.169046/