Reducing state duration of a single state

Hello, I'm trying to find a way to reduce the duration of a single, specific state. I know about $gameActors.actor(id).updateStateTurns(), but that reduces the duration of all states on the battler. If anyone knows how to do this, I'd be glad to hear it.

I'm trying to do this on a project with no plugins whatsoever, so I'd prefer the solution to not use one. If it's impossible without plugins, I'd still be glad to hear it for future reference.
Use this:
Code:
$gameActors.actor(actorId)._stateTurns['stateId'] = duration

Replace actorId, stateId, change the operation and duration as needed,
I got something similar, with a catch to stop it dipping below 0 turns. May not visually update the state icon immediately, though:
Spoiler
Code:
var stateId = 4;                         // * state ID to affect
var batt = $gameActors.actor(4);         // * battler to affect
var turns = 2;                           // * turns to remove
if (batt.isStateAffected(stateId)) {          // if present
  if (turns >= batt._stateTurns[stateId]) {   // check turn count
    batt.removeState(stateId);                // remove state if apt
  } else {                                    // otherwise
    batt._stateTurns[stateId] -= turns;       // reduce turn count
    batt.refresh();                           // refresh display
  }
}
Edit the values on the first three lines as appropriate~

Much more convenient with a plugin; e.g. Yanfly's Buffs & States Core offers a simple <State x Turns: -y> notetag for skills/items.

I feel it's also worth mentioning that a plugin is basically just a bundle of script calls with a convenient interface. More efficient, too, since it doesn't have to go through an eval every time. 😅
While Astfgl66's solution should work, I'd like to add:
- Make sure your actor is actually affected by the state or the command might result in an error
- Make sure to not reduce the remaining duration below 0 or the state will never run out

You can check the remaining duration first by wrapping the command in an "if"-statement:
if ( $gameActors.actor('actorId')._stateTurns['stateId'] > 'number' ) {
...
}

Edit: Too slow, Caethyrils script has also covered these cases.
@Astfgl66 Thanks for that, it works like a charm!

I know that using plugins would save me a lot of hassle, but for this one I want to see how far I can take it with just the base editor and some simple script calls.

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/reducing-state-duration-of-a-single-state.110755/