MV Follow-up attack waits for skills to complete before casting

Hello! I have a few skills in my game that, when an ally hits an enemy under a certain state, an ally performs a followup attack. It works perfectly, except when the followup is triggered by a multi-hit skill. When a multi-hit skill is casted, the followup casts after the first instance of damage and then completely stops the multi-hit skill. This is the code I'm using for one of the states

JavaScript:
<Custom Respond Effect>
if (user.actorId() != 8 && this.item().stypeId != 5 && !$gameSwitches.value(21)) {   
    $gameActors.actor(8).forceAction(60, target.index());
    BattleManager.forceAction($gameActors.actor(8));
}
</Custom Respond Effect>

I'm using Yanfly's Buffs and States core to check if the attacker is not actor 8 (the character who applies this specific state), and the skill type is not 5 (so followup attacks don't trigger each other), and the check for switch 21 is so that the followup attack only triggers once per turn.

How can I change this so that the code waits for all actions to complete before casting? I've tried lots of different things and I'm at my wits end.
It works perfectly, except when the followup is triggered by a multi-hit skill.
yep... been there 🤣

what i normally do is i that i slip a state onto the current acting battler that has a <Custom Action End Effect> to execute the forced action with the intended user on the intended target after the action instead.
yep... been there 🤣

what i normally do is i that i slip a state onto the current acting battler that has a <Custom Action End Effect> to execute the forced action with the intended user on the intended target after the action instead.
If i use an action end effect, I wouldn't be able to check if the enemy that got hit has the state to trigger the Followup, right? or am I misunderstanding what you're saying?
If i use an action end effect, I wouldn't be able to check if the enemy that got hit has the state to trigger the Followup, right? or am I misunderstanding what you're saying?
you can, but you just have to save the info in a way you can retrieve it later. the case you brought up is almost exactly a case i use it for so ill just abridge it.

try this
this is for the state youre already using
Code:
<Custom react Effect>
if (user.actorId() != 8 && this.item().stypeId != 5 && !$gameSwitches.value(21)){
  origin._follow = [target, x];
  user.addState(stateId+1)
  user.setStateOrigin(stateId+1, origin)
}
</Custom react Effect>
replace the x for the id of the skill that the actor should use as a followup.

then the very next state in the database is this.
Code:
<Custom Action End Effect>
if (origin._follow && origin._follow[0].isAlive())
  BattleManager.queueForceAction(origin, origin._follow[1], origin._follow[0]);
delete origin._follow;
user.removeState(stateId);
</Custom Action End Effect>

change stateId+1 in the first one to just be the second state's id if it cant be the next one.
Sorry for the late response, Finals week and all that.
this is for the state youre already using
this isn't working for me ;_; I'm gonna explain how I have the states set up, just to make sure I'm doing it correctly.
<Custom react Effect> if (user.actorId() != 8 && this.item().stypeId != 5 && !$gameSwitches.value(21)){ origin._follow = [target, x]; user.addState(stateId+1) user.setStateOrigin(stateId+1, origin) } </Custom react Effect>
this code is in a state that is applied to the enemies.
Spoiler: Enemy State
1735337314304.png

the next code you sent me is a state that gets applied to allies?
Spoiler: Ally state
1735337370093.png

The ally state is applying, but the follow-up attack isn't launching. I thought it might be something to do with the switch not working correctly so I tried removing the switch from the code but it still didn't seem to launch. No errors appear in the console either.

I'm probably making some silly mistake as I can't follow the code you sent too well. My js knowledge is VERYY limited lol
Don't crop screenshots that you supply - for example, we can't see the IDs of these states to the left (you said the state is applying correctly, but still).

How about a screenshot of skill 60?

How exactly is the state getting applied to the enemy? If it's not being added by the effects of a skill, Yanfly's origin property won't be in there and the checks and force action won't work.
Sorry about that!

Here's the skill that applies the Bleed state (which is necessary for the follow-up)
Spoiler: Bleed Attack
1735339782491.png
Ignore the names...Its all placeholders 😂 (Huge black bar for same reason)

This skill applies the "Bleed" just fine. Stuff in the note tag is for Damage over Time, which works fine. I also tried removing the DoT from the notetag to see if that was interfering but it didn't seem to help either.

Here's the follow up skill, skill 60. This is what is supposed to launch when an ally hits a bleeding enemy.
Spoiler: Skill 60 (Follow-up)
1735340266725.png

The common event turns a switch ON (switch 21) that prevents the followup from launching multiple times in one turn. It automatically turns back on when Brad (the one who inflicts bleed) takes his turn through a passive state which runs a common event. The whole switch thing works for sure becuase it ran well when i tested it before, but ran into the same issue where the follow up would cut in front of multi-hit skills. (switch status is checked in the React effect of Bleed status.) I tried removing the whole switch effect from the status but that didn't work.


Here's the states again, as well as the exact code in their note boxes with IDs on the side.

Spoiler: Bleed State
1735340068842.png

JavaScript:
<Custom React Effect>

if (user.actorId() != 8 && this.item().stypeId != 5) && !$gameSwitches.value(21)){

  origin._follow = [target, 60];

  user.addState(43)

  user.setStateOrigin(43, origin)

}

</Custom React Effect>
Spoiler: Ally State
1735340113795.png

JavaScript:
<Custom Action End Effect>
if (origin._follow && origin._follow[0].isAlive())
  BattleManager.queueForceAction(origin, origin._follow[1], origin._follow[0]);
delete origin._follow;
user.removeState(43);
</Custom Action End Effect>
No errors appear in the console either.
are you certain?
if (user.actorId() != 8 && this.item().stypeId != 5) && !$gameSwitches.value(21)){
your parentheses are mismatched. youre missing an opening one.
More specifically, you shouldn't have a close parenthesis after != 5
are you certain?

your parentheses are mismatched. youre missing an opening one.
Alright I adjusted the parenthesis, now I have this under the Bleed state
JavaScript:
<Custom React Effect>
if (user.actorId() != 8 && this.item().stypeId != 5 && !$gameSwitches.value(21)){
  origin._follow = [target, 60];
  user.addState(43)
  user.setStateOrigin(43, origin)
}
</Custom React Effect>

Its still not launching the followup attack. State 43 is being applied to the attacker, but the attack isn't launching.

I'm getting no errors in the console still. (unless i'm looking in the wrong place, if that's the case I apologize)

Spoiler: console screenshot
1735348159334.png
Just for the sake of it, try replacing the queueForcedAction() with the standard code for it.

Code:
<Custom Action End Effect>
if (origin._follow && origin._follow[0].isAlive())
{
    origin.forceAction(origin._follow[1], origin._follow[0].index());
    BattleManager.forceAction(origin);
}
delete origin._follow;
user.removeState(43);
</Custom Action End Effect>
Just for the sake of it, try replacing the queueForcedAction() with the standard code for it.

Code:
<Custom Action End Effect>
if (origin._follow && origin._follow[0].isAlive())
{
    origin.forceAction(origin._follow[1], origin._follow[0].index());
    BattleManager.forceAction(origin);
}
delete origin._follow;
user.removeState(43);
</Custom Action End Effect>
The follow-up still isn't launching. Could you explain what the "origin follow" is doing? I haven't seen this before in a script and I can't find it in the js library.
Yanfly's origin property
You said this, is it part of the Yanfly core engine? or is there another plugin that i need to download to utilize it?
The follow-up still isn't launching. Could you explain what the "origin follow" is doing? I haven't seen this before in a script and I can't find it in the js library.
It's just the name @Robro33 chose for a property created on the origin battler in the first notetag.

1735360821165.png


That's nothing to do with RPG Maker, it's standard JavaScript syntax.

You said this, is it part of the Yanfly core engine? or is there another plugin that i need to download to utilize it?
It's a part of the Buffs & States Core, which you must already have in your project otherwise none of these notetags would be doing anything.

So do this to troubleshoot.
Code:
<Custom Action End Effect>
console.log("origin is ", origin, ", origin._follow is ", origin._follow);
if (origin._follow && origin._follow[0].isAlive())
{
    origin.forceAction(origin._follow[1], origin._follow[0].index());
    BattleManager.forceAction(origin);
}
delete origin._follow;
user.removeState(43);
</Custom Action End Effect>

Then during battle press F8, go to the Console tab, and post a screenshot of the printed log.
I haven't seen this before in a script and I can't find it in the js library.
you wouldnt.
Could you explain what the "origin follow" is doing?
when youre working directly with JS youre allowed to write your own properties on existing objects as the need arises. the _follow property is a container that holds both the skill id and the intended target for the skill that's to be used

origin is a shortcut created by Yanfly's Buffs & States plugin to reference the battler that gave the state to the battler in question (in most cases. its really the active battler at the time of application iirc).
when the battler with the marking skill applied it to the enemy, they become the origin for that state. when the other ally attacks the marked enemy and has the following state applied to them, the attacker become the origin for the following state, but a command is used to then change it to the battler who placed the mark to make tracking easier.

You said this, is it part of the Yanfly core engine? or is there another plugin that i need to download to utilize it?
as long as you have Yanfly's buffs and states plugin, states have origins. at that point id add some console log lines to make sure the origi--- Turan got that covered mid explanation 🤣.

But also just to have the info, can you provide a screenshot of your plugin manager? just to make sure everything is in the right order and nothing is out of date.
Then during battle press F8, go to the Console tab, and post a screenshot of the printed log.
I must be doing something wrong or looking in the wrong tab, I don't see anything being printed into the console. The state is being applied, I can see the icon above the SV Actors, but nothing in the log.
Spoiler: Console
1735365351408.png
when youre working directly with JS youre allowed to write your own properties on existing objects as the need arises. the _follow property is a container that holds both the skill id and the intended target for the skill that's to be used
Ahhh thank you. This makes sense. I was having trouble trying to follow what the code was accomplishing but this is clearer now. 😮‍💨

Here's my plugin manager...There's quite a few plugins because this game is mostly just me trying to get better and more familiar with the battle system and I wanted to try out some stuff.
Spoiler: plugin manager
1735365583505.png
1735365610369.png
1735365597316.png
I'm pretty sure there's no compatibility issues. I had this follow-up attack working before its just the multi-hit problem I was running into as I said before. But I wouldn't be surprised if there was some issue in here somewhere because theres like a billion plugins 😔
I must be doing something wrong or looking in the wrong tab, I don't see anything being printed into the console. The state is being applied, I can see the icon above the SV Actors, but nothing in the log.
2 things.
whenever you make changes to plugin parameters and notetags, those changes do not take place until the project is saved.
Whenever you test via playtest, always create a new save. some data is only ever written as the file is created and making changes and loading old files with old data will more often than not bring up issues.

I'm pretty sure there's no compatibility issues. I had this follow-up attack working before its just the multi-hit problem I was running into as I said before. But I wouldn't be surprised if there was some issue in here somewhere because theres like a billion plugins
your yanfly plugins are all kinds of out of place. if theyre not loaded in the order as they appear on their website youre also likely to run into issues.
2 things.
whenever you make changes to plugin parameters and notetags, those changes do not take place until the project is saved.
Whenever you test via playtest, always create a new save. some data is only ever written as the file is created and making changes and loading old files with old data will more often than not bring up issues.


your yanfly plugins are all kinds of out of place. if theyre not loaded in the order as they appear on their website youre also likely to run into issues.
You would not believe how hard my jaw just hit the floor. I can't believe it was so simple as rearranging my plugins ;_;. I set them into the order on his website and now the Followup is launching, however..

Sometimes it launches exactly like i want, which is directly after another party member's action is complete, but other times it stays queued (like the action icon appears next to the actors name, but doesn't yet launch) until the next person does an action. This would be fine, except the skill MP and TP costs still are taken without actually using their skills, which is troublesome.

Huge step in the right direction though, I feel bad this whole thing was basically solved with plugin rearranging LOL

Here's the console log, in case its still needed.
Spoiler: console log
1735367857439.png
Sometimes it launches exactly like i want, which is directly after another party member's action is complete, but other times it stays queued (like the action icon appears next to the actors name, but doesn't yet launch) until the next person does an action. This would be fine, except the skill MP and TP costs still are taken without actually using their skills, which is troublesome.
now that its working, retry the BattleManager.queueForceAction once again just to see
now that its working, retry the BattleManager.queueForceAction once again just to see
It's working perfectly now. Thank you so much!

Actually, one more question @Robro33 .
I have more characters in the game with similar followup attacks, how can I edit the script to allow them to be used on the same team and allow both of their follow up attacks to work? i tried changing the name of the "origin" to "origin2" but that didn't seem to work.


nevermind LOL the other state i made just had a typo. Sorry!!
i tried changing the name of the "origin" to "origin2" but that didn't seem to work.
as said before, origin is a shortcut. its a predefined variable within the plugin itself that refers to a battler. changing it to origin2 is to try and access another variable that most definitely doesnt exist unless you defined it prior.

how can I edit the script to allow them to be used on the same team and allow both of their follow up attacks to work?
if they should be concurrent, then you want to make a copy of the states and change the duplicate "bleed" state to point towards the second folowup skill and the duplicate followup state instead. You want the followup state to be a unique state so that one follow doesnt overwrite the other

(or you could change _follow to be an array of target and skill pairings and loop through them in a single state, but its easier not to. you wouldnt have to duplicate the folowup state that way, but theres no getting around having to duplicate the bleed state)

Original thread: https://forums.rpgmakerweb.com/threads/follow-up-attack-waits-for-skills-to-complete-before-casting.173877/