MV Creating a "Play after..." skill on an STB battle system

Hello!

I'm working on expanding the strategic options in my game's combat, and it's crazy how helpful the Buffs and States Core is when it comes to creating complex effects. I can basically do battle eventing wherever I want, which is perfect for my new idea.
The idea is that sometimes it'd be a better move for one actor to pause their turn and tag back in right after an ally, and that's the skill I want to make.
So far I managed to have a lasting way to define who's jumping in and after who, I can make the actor's turn pause pretty easily, and then when it comes to tagging in I can't get it to work. I can force the actor who's jumping in to use a special skill, which makes the user jump back into the action, but it's the only skill that actor does. The game doesn't actually make them resume their turn.

So that was a non-technical way to explain what I'm trying to do, let's move on to the specifics.
There's 4 plugins at play for this situation, all by Yanfly:
The Buffs and States Core, here to execute code when I'm playing around with states. My JS proficiency is just clever copy-pasting, don't worry about complexity if you've ever done that, I'm even going to explain what the code does.
Weapon Unleash, here to replace the End turn command (taking up the Guard spot) by a different skill if needed.
Instant Cast, core of my battle system. Every action besides those that end the user's turn are instant skills.
The STB extension of the Battle Engine Core, it's here to make actors select their skills only when it's their turn to act.

I used this script call list to know which lines of code serve the same purpose as events.

For my idea to work, I've got 3 skills:
Spoiler: Skill 47 - Play After...
Active skill that can be used from the battle commands. Targets an ally. Adds state #38 - Followed up.
Spoiler: Skill 48 - My Turn Again!
Triggered skill that will only be used through force action. Targets the user. Removes state #39 - Waiting to tag.
Spoiler: Skill 49 - Tag out
Skill that appears instead of the "end turn" command if under state #38 - Followed up. Targets the user. It removes state #38, adds a state that processes the end of a turn, and has this in the formula as MP recovery: $gameParty.members()[a.getStateCounter(38)].forceAction(48,-1); BattleManager.forceAction($gameParty.members()[a.getStateCounter(38)]); (a.isStateAffected(41)) ? a.addParam(1,0-a.getStateCounter(41)); a.mmp-a.mp
Explanation of this code:
JavaScript:
$gameParty.members()[a.getStateCounter(38)].forceAction(48,-1);  //Forces the person who used Play After... to use My Turn Again!
BattleManager.forceAction($gameParty.members()[a.getStateCounter(38)]); //Pushes the action so it's executed right now in the battle manager
(a.isStateAffected(41)) ? a.addParam(1,0-a.getStateCounter(41)); //Irrelevant to the current situation, but state #41 gives extra MP which are counted, until the wearer's turn ends
a.mmp-a.mp //recharges the user's MP because their turn ends, which is the base of my system
I also have 2 states:
Spoiler: State 38 - Followed up
Removed at battle end, seals the skill Play After..., here's what's in the notes:
JavaScript:
<Custom Deselect Effect> //Executed after the wearer was targeted by a skill. Couldn't be Apply because it doesn't catch who the user was.
if(!target.getStateCounter(38)) { //If the state has no counter, that means the skill received was "Play After..."
  target.setStateCounter(38,$gameParty.members().indexOf(user)); //Stores the battle party index of the user of "Play After..."
  user.addState(39); //The user then gets the second state, "Waiting to tag"
}
</Custom Deselect Effect>
<Replace Guard: 49> //Replaces the normal "End turn" command by "Your turn!"
Spoiler: State 39 - Waiting to tag
Removed at battle end, resists the state #38 "Followed up"

So now that's it's all introduced, here's how it should work:
  1. USER uses "Play after..." on TARGET.
  2. TARGET gets "Followed up".
  3. Its Deselect effects are processed:
    1. The state was just applied so there's no counter value, the condition is valid.
    2. The counter is set to USER's battle party ID, we can now point at USER reliably thanks to $gameParty.members()[TARGET.getStateCounter(38)].
    3. USER gets "Waiting to tag".
  4. "Play after..." isn't an instant skill, so USER's turn is over. (their MP doesn't get maxed out because it's actually "paused")
  5. People play, now it's TARGET's turn.
  6. TARGET does their actions, then ends their turn. Weapon Unleash (through "Followed up") turned that command into using "Tag out".
    1. The first command forces USER's next action to be "My turn again!"
    2. The second command pushes the action, so USER cuts in line and uses "My turn again!" immediately.
    3. If USER had bonus MP, they're removed.
    4. USER's turn ended, so their MP get maxed out.
    5. TARGET loses "Waiting to tag".
  7. USER gets to resume their turn since they've cut in line in step 6.2. (this is the only part that doesn't work)
The crazy part is that I already made a mob cut in line by accident. I wanted it to have a triggered skill, but triggering it made the mob straight up cut the current actor's turn short. It used the triggered skill, and then started throwing hands like it was already their turn again. I fixed it, but now that this is an effect I want an actor to have I can't reproduce it.

The plugins are all in the right order. Can somebody help me make this last part work as intended?

Also, this is my cue to show off the 2.0 of my Turn-based 2.0 pretty soon, any part that was confusing about my battle system here will be a lot clearer. I'll work on that in the meantime. Sorry in advance for the headache.

Original thread: https://forums.rpgmakerweb.com/threads/creating-a-play-after-skill-on-an-stb-battle-system.125974/