Status Duration = Variable...?

Ok, so I'm trying create a special status for one of my actors.

Basically she has a skill that can unseal her power temporarily, creating a buff that does various things.
Now, I'm using the Yanfly engine, so doing some of the basics is simple:

I want this skill to buff her for X turns where X is the amount of TP she consumes to activate the skill [it simply uses ALL of her TP] divided by 10 [rounding nearest (<5 down; >5 up) (and if used with 100TP instead of say 96, Take another action)].

Getting the X is the easy part.
Just set the cost of the skill to 10.
During the Setup Action [Yanfly], have it store her (remaining) TP as a variable. 
{Common Event:
Set X to 1.
Conditional branch series to check how it will round.
Divide by 10.
Add appropriate value to X,
If 100 set a switch to arm the extra turn}
Then have it drain out the remainder of her TP.
Switch off the Extra Turn Switch. Apply rest of the skill's effects.


It's making it last for X that's tripping me up.
The problem is that there doesn't appear to be a method to have the duration of a State last for a variable.
 
I've moved this thread to JS Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.
I've moved this thread to JS Plugin Support. Please be sure to post your threads in the correct forum next time. Thank you.
It...wasn't in the wrong place though.

It was general.

I'm using a plugin, but it's not the plugin I'm requesting support with. It's the rest of it. (I can work what I need to with the plugin just fine. It's after the plugin's work [which really is just creating a variable to work with] is done where I'm getting lost [converting said variable into a state duration (I mean I might need a plugin for that, but...)].)
I haven't been using JavaScript much yet and can't verify this code right now either, so I can't promise it will work:

var actor = $gameActors.actor(ActorID);

actor._stateTurns[StateID] = $gameVariables.value(VariableID);
It...wasn't in the wrong place though.

It was general.

I'm using a plugin, but it's not the plugin I'm requesting support with. It's the rest of it.
You're wrong, because the default cannot make the duration of a state variable in that way, so you'll need either an additional plugin as a solution or a modification/add-on to yanfly's Plugins.

But your problem can't be solved without a plugin
While cracking my brain over this, I may have figured it out:

State doesn't clear itself.

Have a conditional Battle Event set to run at the end of every turn [Turn 0+X, Turn End, Span Turn]

Conditional Branch:
If [Character] is [state] Then:
Variable [Turn Counter]=+1
Nested Branch: If Turn Count = [X] Then:
Remove State Character [state]
Turn Counter = 0

Tested it a few times at different values, it works AFICT.
Solved my own problem with Events.

Of course, that needs to be in any battle where that character can be in, so either mass copypasta, or another plugin [of which, Yanfly has].
 

Original thread: https://forums.rpgmakerweb.com/threads/status-duration-variable.49941/