MV Removing a state when switching out an actor with YEP Active Party Switch...

http://www.yanfly.moe/wiki/Actor_Party_Switch_(YEP) I use this plugin to switch actors in and out of battle. But I was wondering is there a way to remove a state from an actor when they switch out. I have a combo state where it goes away when you're hit or when you miss an attack, either way ending the current combo streak. I don't want that actor to keep the streak though if they switch out to another actor. I'm not sure how to go about this one though. the most I know how to do with states and switching is making it so you can't switch with certain states active.

any help would be greatly appreciated, thanks everyone.
How are you applying the state?
I have a dummy "hit state" where if the player lands a hit, the state is added through that state.
I have a dummy "hit state" where if the player lands a hit, the state is added through that state.
Is the hit state a passive state?
actually no. tho it probably could be. basically every attack has the state on it and is apply like a normal state on hit.
What if instead of every skill having the dummy state, every actor had a passive state that does the same thing?

Then, you could make one of the conditions check if they're in the active battle party.

Then, the combo state could check if the initial state is active.
I was thinking about that actually, but I can't figure out how to make the state go away if the player misses anymore. the dummy state makes sure it's only added on a hit and always goes away on a miss. I'm not sure how to do that with it as a passive state. Tho, maybe there's a way to make it just reset to 0 instead of go away...
How are you handling the increase of the bonus per hit?

Or I guess a better question is foes the bonus state change as the number of hits increases?

Or is it a single level that's just there as long as you don't miss?
basically I tweaked http://www.yanfly.moe/wiki/Combo_Attack_(MV_Plugin_Tips_&_Tricks) a little. each hit that connects increases the level of damage done up to 10 hits. as long as you A. don't miss and B. don't get hit, it would always go up by one when you did hit. I was thinking about it like a fighting game in that sense. the state goes to the player when it lands the dummy state on the enemy.
Okay, I don't have work tomorrow so I'll sit down at my laptop then and give you some help with this.
thanks, much appreciated
Okay, so I've had started looking at this and from looking at the yanfly tips and tricks, I think this can all be done with a passive state that increases a counter every successful hit and reverts it to zero after a miss or a successful hit on the enemy's part.

I'm gonna need more time to work it out but the buff from the state will be based off the value of the counter.

I'll let you know when I begin testing.

-UPDATE-

So I should have remembered this from before but passive states never run the apply effect code because they're never "applied" so a passive state is never going to work for this, my mistake.

As far as a JS condition to check whether an actor is in the active party:

JavaScript:
$gameParty.battleMembers().contains(user)
Will work,I just need to figure out how to run it when the actor is swapped in or out.

There might be an existing timing effect that will work.

I feel like the "Custom Action End Effect" might work.

-UPDATE 2-
Try adding this notetag to your combo state:
JavaScript:
<Custom Action End Effect>
if (!$gameParty.battleMembers().contains(user)) {
  user.removeState(StateID);
}
</Custom Action End Effect>

Replace 'StateId' with the Id number of the combo state. It should get removed from the actor when they switch out.
I'll test this out once I've got a second! thanks!

EDIT: so I tried it and the problem now is it won't apply the initial state because of the whole apply/passive thing. I think I remember that's why I didn't want it as a passive. also it didn't seem to work when I switched out the party member that had it on them. Though I feel it should've based on what I know about JS.
@zerobeat032 I apologize, I should have said that this method should work with your initial setup.

I tested this in a battle by applying the state through the console and then switching the party member out and then back in. When I switched them back in, the state was gone.

I can test it more if you'd like.

-EDIT- @zerobeat032

Okay, so I tested this again and it seems to be working for me. I had thought it wasn't, but I made a simple error. Here's the notetag for the combo state. Most of it is taken from the Combo Attack Tips and Tricks from Yanfly. The very last notetag is what removes the state when the user switches out.

JavaScript:
<Custom Apply Effect>
// Defaults user's combo stacks to 0.
user._comboStacks = user._comboStacks || 0;
// Get the current number of stacks. Min 0, Max 10.
var stacks = user._comboStacks.clamp(0, 10);
// Set the combo counter for the state.
user.setStateCounter(403, 'x' + stacks);
</Custom Apply Effect>

<Custom Confirm Effect>
//(When actor lands an attack)
// Check if the user is delivering physical damage.
if (this.isPhysical() && value > 0) {
// Get the current number of stacks. Min 0, Max 10.
var stacks = user._comboStacks.clamp(0, 10);
// Calculate the extra damage rate from Combo stacks.
var rate = 1.00 + stacks * 0.10;
// Round the damage upward.
value = Math.ceil(value * rate);
// Increase stack count.
stacks += 1;
// Set stack count min to 0, max to 10.
stacks = stacks.clamp(0, 10);
// Set the combo counter for the state.
user.setStateCounter(403, 'x' + stacks);
// Apply stack count to user's combo count.
user._comboStacks = stacks;
}
</Custom Confirm Effect>

<Custom Respond Effect>
//(When actor is hit by an attack)
</Custom Respond Effect>


<Custom Remove Effect>
// Reset combo stacks to 0.
user._comboStacks = 0;
// Get the current number of stacks. Min 0, Max 10.
var stacks = user._comboStacks.clamp(0, 10);
// Set the combo counter for the state.
user.setStateCounter(403, 'x' + stacks);
</Custom Remove Effect>

<Custom Action End Effect>
if (!$gameParty.battleMembers().contains(user)) {
  user.removeState(403);
}
</Custom Action End Effect>

Also note, this isn't a complete setup because I didn't do the code for landing a hit and getting hit.

Let me know if this works with your initial setup.
I tagged you in my update so you'll get a notification, I missed your edit since I was simply looking for a notification -_-

-EDIT-
• Added the notetag for landing a hit
• Changed "Custom Establish Effect" to "Custom Confirm Effect"
Ahh I should've tagged you or something. sorry about that lol. Hmm I think the problem is because of the actor switching out, their actual action doesn't happen? It doesn't get rid of the state stiil unfortunately. I'm thinking it might just be easier to keep it seeing how weird the engine is being about canceling it when you go to a reserve slot.
Hmmmm...its working for me. I even tested adding the death state to the last notetag and the actor dies when they have the state and then they switch out.

Maybe it has to do with the dummy state adding the combo state upon a hit.

The only thing I think im doing differently is adding the state through the console at the start of the battle.

If this is a mechanic you want to be present across all battles Maybe there's another way to handle it, through a troop event that applies to every battle, which yabfly had a plugin for. I could set it up so the initial hit doesn't add any bonus damage.

You could also show here all the notetags you have just incase there's something I'm missing.
Code:
<Custom Apply Effect>
// Defaults user's combo stacks to 0.
user._comboStacks = user._comboStacks || 0;
// Get the current number of stacks. Min 0, Max 10.
var stacks = user._comboStacks.clamp(0, 10);
// Set the combo counter for the state.
user.setStateCounter(41, 'x' + stacks);
</Custom Apply Effect>

<Custom Confirm Effect>
//(When actor lands an attack)
// Check if the user is delivering physical damage.
if (this.isPhysical() && value > 0) {
// Get the current number of stacks. Min 0, Max 10.
var stacks = user._comboStacks.clamp(0, 10);
// Calculate the extra damage rate from Combo stacks.
var rate = 1.00 + stacks * 0.25;
// Round the damage upward.
value = Math.ceil(value * rate);
// Increase stack count.
stacks += 1;
// Set stack count min to 0, max to 10.
stacks = stacks.clamp(0, 10);
// Set the combo counter for the state.
user.setStateCounter(41, 'x' + stacks);
// Apply stack count to user's combo count.
user._comboStacks = stacks;
}
</Custom Confirm Effect>

<Custom Respond Effect>
//(When actor is hit by an attack)
</Custom Respond Effect>


<Custom Remove Effect>
// Reset combo stacks to 0.
user._comboStacks = 0;
// Get the current number of stacks. Min 0, Max 10.
var stacks = user._comboStacks.clamp(0, 10);
// Set the combo counter for the state.
user.setStateCounter(41, 'x' + stacks);
</Custom Remove Effect>

<Custom Action End Effect>
if (!$gameParty.battleMembers().contains(user)) {
  user.removeState(41);
}
</Custom Action End Effect>

I copied what you have and just changed the state to the one I'm using... I can't get it to work though on my end. the state stays whenever someone switches... I even turned off a ton of plugins to see if something was conflicting and nope, still an issue.
Okay, I'm gonna make a brand new project and test it there. I probably should have done that from the beginning honestly.

@zerobeat032 Which battle system are you using?
I believe its working on my end because I'm using the STB battle system from Yanfly.
I'm using the OTB battle system. tho I tried it on the default system and still had issues. I'm still wondering if it's just something conflicting with things on my end.
Well, I tried it in a fresh project with just yanfly core, battle core, buff and state core, party system and actor swap and it didn't work.

I went back to the project I first tested it in and turned off the STB battle plugin and it stopped working.

As for the OTB, if you have the plugin below the party plugins, try putting it directly above them in the load list and see if that makes a difference.

@zerobeat032 I got it working with the OTB. Here's the plugins I have loaded in that project:
Spoiler: Plugin List
1659577647992.png

Original thread: https://forums.rpgmakerweb.com/threads/removing-a-state-when-switching-out-an-actor-with-yep-active-party-switch.149789/