Get the remaining turns of a specific state in the damage formula

I want to create a skill that has a damage scales with the remaining turns of a specific state. For example, the more turns of sleep remaining an enemy has, the higher the damage it will receive from a skill like "Dream Eater".

I know how to deal extra damage to an enemy with a specific state, it's like "(b.state?(6) ? 8 : 4) * a.mat / b.mdf". However, I can't seem to figure out how to get the remaining turns of a state in the damage formula.

Does anyone know if it is possible to do so in the damage formula? Or must I edit some script? And how?

Thank you.
You can use the state_turns property for this, but in order to do so you'll have to edit Game_Battler slightly to make it an attr_reader or attr_accessor as there isn't a default method for accessing it.
You can use the state_turns property for this, but in order to do so you'll have to edit Game_Battler slightly to make it an attr_reader or attr_accessor as there isn't a default method for accessing it.
Thanks. I figured it out after reading your comment.

Here is how I do it:

Add these lines to Game_BattlerBase:
def state_turns(state_id)
return @state_turns[state_id]
end

Input "10 * b.state_turns(6)" as a damage formula and it works just fine.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/get-the-remaining-turns-of-a-specific-state-in-the-damage-formula.126173/