MV How to prevent the same state from being applied to a target

Hello everyone, I'm trying to create a state whose effect is to transform into another state after the target's actions are finished (in this case 3). Let's call the first state ID9 and the second state ID10. I don't want the target to have the chance to be hit by ID9 again, as this causes the turn counter to return to 3. How can I manage this?

I'm using YEP Buffs and states core for this. I mixed some codes that I found, and it kinda works, but that specific problem not that much.
JavaScript:
<Custom Apply Effect>
if (user._drowsy === undefined) {
  user._drowsy = 3;
}
</Custom Apply Effect>

<Custom Turn End Effect>
if (user._drowsy !== undefined) {
  user._drowsy--;
 
  if (user._drowsy <= 0) {
    user.removeState(9);
    user.addState(10);
    delete user._drowsy;
  }
}
</Custom Turn End Effect>

<Custom Remove Effect>
delete user._drowsy;
</Custom Remove Effect>

These are the settings
Screenshot 2025-02-15 173645.png


Sorry if this is to simple to ask...But I have Zero knowledge of coding
I don't want the target to have the chance to be hit by ID9 again, as this causes the turn counter to return to 3. How can I manage this?
easiest way imo is to give the state a trait to set the state rate for itself to 0% and make sure whatever way you apply that state uses state rate as a factor.

but also what you wrote does prevent the user from having their drowzy counter reset. its just the state lasts 3 turns, so the turn count resets. the buffs and states plugin already has a notetag to make it so that reapplication doesnt affect the duration
easiest way imo is to give the state a trait to set the state rate for itself to 0% and make sure whatever way you apply that state uses state rate as a factor.

but also what you wrote does prevent the user from having their drowzy counter reset, its just the state last 3 turns, so the turn count resets. the buffs and states plugin already has a notetag to make it so that reapplication doesnt affect the duration
wooow thank you! It works like a charm!
the buffs and states plugin already has a notetag to make it so that reapplication doesnt affect the duration
Just by curiosity, what notetag is this?
1739653494667.png

Original thread: https://forums.rpgmakerweb.com/threads/how-to-prevent-the-same-state-from-being-applied-to-a-target.175494/