Yanfly: Have an actor take multiple action and not take multiple state turns.

Using standard yanfly plugins and yanfly ATB
I have an actor use a skill, then a forced skill common event is run a few times.
The issue is that the states on the actor go down in correlation to the number of actions taken when I only would want them to go down by one turn count.
I looked into this and tried to fix it but to no avail.
The following changes in YEP_BuffStatesCore checks if a switch is active.
If I set the switch to true, the states are never updated.
If I set the state back to false at the end of the common event or in the action sequence, the states are triggered multiple times like it was queued up. If I force the initial skill instead, no states are updated.

Code:
Yanfly.BSC.Game_BattlerBase_updateStateTicks =
   Game_BattlerBase.prototype.updateStateTicks;
Game_BattlerBase.prototype.updateStateTicks = function() {
    if(!$gameSwitches.value(55)){
    $gameTemp._customLeaveEffectEval = true;
    Yanfly.BSC.Game_BattlerBase_updateStateTicks.call(this);
    $gameTemp._customLeaveEffectEval = undefined;
    }
};
Presuming the skill you're forcing is unique (i.e. they can't choose to use it at other times), I'd add a Skill Core notetag to add 1 to the duration of all states when it's used. (or do it in the skill's action sequence, if you're using that)

That will counteract the losing one from duration and you won't have to mess with any of the code.
Thanks for the response.
Is there a specific syntax for adjusting all turns on an actors current states and a buffs?
I looked around and didn't see anything for that specifically.
Each battler has a _stateTurns property, which is a key-value pair collection where the key is the state ID and the value is the number of turns remaining on it, and _buffTurns, which is an 8-element array where each element is the number of turns remaining on its corresponding buff ID.
That did it. Thanks so much.


Code:
eval: Object.keys(user._stateTurns).forEach(key => {user._stateTurns[key] += 3;});
Each battler has a _stateTurns property, which is a key-value pair collection where the key is the state ID and the value is the number of turns remaining on it, and _buffTurns, which is an 8-element array where each element is the number of turns remaining on its corresponding buff ID.
Is there a way to have poison and regen not apply multiple times when the players turns ends?
Is there a way to have poison and regen not apply multiple times when the players turns ends?
I think you're running into some of the reasons that Yanfly discontinued support for these extra battle systems. When you break the constructs of RPG Maker's turn system there are a lot of other little pieces relying on it to function properly.

You'd have to delve into the plugin to see how the end of the action corresponds to the end of a turn and figure out how to selectively call the regeneration phases depending on the conditions you want.

You could try taking those effects out of Traits and into Custom Regeneration Phase or Custom DoT Formula notetags, have the code in those notetags be conditional based on a switch which you toggle back and forth inside of your other skills.
Thanks for the reply.
I didnt know yanfly's ATB was so messy until I got to deep in.

Luckily I did figure out a fix along the lines you mention.
I just gave the user a check at the end of their turn to see if they took poison damage (since forced action queues end turn effects together) and only apply it once.


Code:
 <Custom Apply Effect>
if(target.isEnemy() == true)
{
target.addState(45);
}
  </Custom Apply Effect>

<Custom Turn Start Effect>
target._poisonCheck = 0;
</Custom Turn Start Effect>

<Custom Turn End Effect>
if(target._poisonCheck == 0 ){
target.gainHp(Math.floor(-target.mhp * 0.10));
target.startDamagePopup();
}
target._poisonCheck++
</Custom Turn End Effect>

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-have-an-actor-take-multiple-action-and-not-take-multiple-state-turns.153496/