State duration scaling off of actor stats.

Hello, I'm trying to make a state that has a duration that scales off of one of the stats of the actor that uses it. Specifically, I'd like a "Stealth" state that has a duration that is determined by the actor's magic defense stat, so that as the actor's magic defense stat increases, so does the duration of the "Stealth" state.

I'm using the Visustella MZ Skills and States Core plugin, and several of the other basic Visustella MZ plugins. I attempted to use the "<Set State id Turns: x>" notetag on the skill that applies the state to achieve this effect, but it seems that when I replace "x" with anything other than a flat number value the notetag doesn't work. I've been searching for solutions for this issue but unfortunately the only ones I've been able to find are for MV or VX ace and aren't applicable to MZ.

I feel like I am overlooking something, but I'm not sure what it could be, so I'll just ask if anyone else has attempted to get state durations to scale off actor stats in MZ, and if so, how did you accomplish it?

Thank you in advance for your replies.
I attempted to use the "<Set State id Turns: x>" notetag on the skill that applies the state to achieve this effect, but it seems that when I replace "x" with anything other than a flat number value the notetag doesn't work.
Correct - plugin authors will explicitly tell you when a field can accept JavaScript. Otherwise, it can only take a single value of the type (number, word) specified.

You could try something like this:
Code:
<JS On Add State>
target._stateTurns[state.id]=Math.ceil(origin.mdf/10);
</JS On Add State>

You didn't say how you wanted the parameter to affect the turns, so I put MDF divided by 10. You can change that however you like.
That worked perfectly! Thank you for your quick and informative reply. Your example is exactly what I needed to see!

Original thread: https://forums.rpgmakerweb.com/threads/state-duration-scaling-off-of-actor-stats.159505/