MV How can I make an skill do damage based on the turns left in a state

Hi! I was wondering if there's a way to make a skill do damage based on the amount of turns left in a certain status on the actor using that skill. My first thought is there might be a way to do it with Yanfly's Skill Core, but I wouldn't know how to retrieve the number of turns left on a status. Do any of you know how? Thank you!
short answer, yes, it's possible.
you have to grab everything before processing it and returning the damage, which is done at the damage formula by default, but I doubt the formula box is large enough to fit all that.
my solution would be, make a new module, add a function there that deals with the processing, and call that from the damage formula with a much shorter instruction.
it all depends on how versed you are with the coding.
short answer, yes, it's possible.
you have to grab everything before processing it and returning the damage, which is done at the damage formula by default, but I doubt the formula box is large enough to fit all that.
my solution would be, make a new module, add a function there that deals with the processing, and call that from the damage formula with a much shorter instruction.
it all depends on how versed you are with the coding.
Well, I don't know as much in JS as I do in some other languages, but I feel I could probably just accomplish something similar with Yanfly's Skill Core's notetags, I think...? I imagine it would look something like this:

JavaScript:
<Pre-Damage Eval>
// The damage function's result is the variable "value" in this plugin.
if (user.hasStatus(42)) {
  turns = "Whatever function would return the number of turns left on a status";
  value = value*turns;
} else {
  value = 0;
}
</Pre-Damage Eval>
You can fetch the remaining turns for state ID 123 on battler like this:
JavaScript:
battler._stateTurns[123]
So I suggest a damage formula like this (no plugins necessary):
JavaScript:
(a.mat + 50) * (a._stateTurns[123] || 0)
I.e. "a.mat + 50 multiplied by the remaining turns of state 123 on the action user (or zero if they don't have that state)". Change each part as needed for your situation~

Technical: _stateTurns[123] will be undefined (a "falsy", but non-numeric, value) if the bearer does not have that state. That's why I've included the || 0 to make sure the multiplier is always a number. More info here:

Original thread: https://forums.rpgmakerweb.com/threads/how-can-i-make-an-skill-do-damage-based-on-the-turns-left-in-a-state.138488/