MV Selection Control sometimes disabling my offensive skills

RMMV version: 1.5.2
Selection Control version: 1.15 (Target Core was 1.04 but I updated it to 1.05 and still got this issue)
Row Formation version: 1.16
Battle System CTB version: 1.17

All Yanfly plugins are in correct order, all non-Yanfly plugins (mostly HIME and SRD but those don't seem to be causing the problem) are underneath the Yanfly plugins.

The background on this issue:
For a while I had been struggling with a strange crash involving Selection Control, Row Formation, and Battle AI Core. Essentially, if an enemy had a skill in their AI list that only targeted the front row, the game would sometimes crash. Not every time, which was weird. And it was always the first enemy to get an action if it happened, it never just happened in the middle of a battle to my recollection.

Figuring it had something to do with the Front Row Only selection, I tried disabling the plugin parameter that auto-set all physical skills to melee, followed by going into all melee-intended enemy skills and giving them the following notetag:

<Custom Select Condition>
if (target.row() === 1 || (target.row() === 2 && $gameParty.rowAliveSize(1) === 0)) {
condition = true;
} else {
condition = false;
}
</Custom Select Condition>
And... it worked! No more crashes! All that was left was to continue playtesting and see if that broke anything.

The issue now:
As best as I have diagnosed the issue, if there are no front row enemies in the current battle (mind you, all bosses are put in the back row for dramatic distance), the first ally to act immediately after an enemy will sometimes have their offensive skills locked out. Their healing/support skills and their Defend command? A-OK. But if it targets an enemy, it can't be used.

If it has anything to do with that Selection Control code, then it has to be something very indirect, as it also affects offensive magic, which has never had any select conditions and still doesn't. And that notetag I posted wasn't applied to any player-side skills (not even modified for $gameTroop), only enemy-side skills.

I checked allies for skill-disabling states that might somehow be getting applied by mistake, but nothing. Checked for enemy states that might have the <Cannot Select: All> tag in there, but there aren't even any states with that tag in there, let alone any applied to any enemies by mistake.

I tried disabling all non-Yanfly plugins to see if maybe something else was interfering, but also no.

I tried disabling Selection Control, and the issue resolved, just... I kind of need it on, you know?

And it's particularly bizarre to me that this only started happening after

My only conclusion is that somehow, an enemy acting causes the immediate ally to perceive all enemies as invalid targets. And that something was triggering before, that then collided with some other issue to cause a crash. But since that issue is gone, there's no crash, but that issue is now instead colliding with something else.

Unfortunately, I'm having a really difficult time pinpointing what that is. Anyone have any insights?
the first ally to act immediately after an enemy will sometimes have their offensive skills locked out.
i believe thats a part of an issue thats been noted before

Edit:
also any particular reason why youre still using MV 1.5.x?
most if not all of Yanfy's plugins are for 1.6.2 now. you may encounter problems down the line stemming from that
i believe thats a part of an issue thats been noted before
Interesting. Where do I paste that new code into Selection Control? Or should I just paste it into a new .js file and load it in underneath Selection Control as a new plugin? (Sadly I had to leave the house, so it'll be a minute before I can actually try any of this.)

Edit:
also any particular reason why youre still using MV 1.5.x?
most if not all of Yanfy's plugins are for 1.6.2 now. you may encounter problems down the line stemming from that
Well, a few reasons. This is a bit of an older project that I decided to try to just finish up since it's basically done (I got stumped at the crash listed above during proper playtesting and gave up), and I'd started it in 1.5.2. As for why I didn't upgrade... I actually did, but SRD's plugins (particularly anything Super Tools-related) stopped working as a result, so I changed it back. And I reeeeaally like HUD Maker, lol

And I mean, like I said, game's basically done. As long as the bugs can be fixed, I'm fine just hammering them out. I doubt any more plugins will get thrown in at this point, so I can't see any new issues arising.
Or should I just paste it into a new .js file and load it in underneath Selection Control as a new plugin?
thatd work just fine

I actually did, but SRD's plugins (particularly anything Super Tools-related) stopped working as a result, so I changed it back.
Just to be sure, youre using the most up to date versions of those plugins? ive done tests on them for other threads before and its completely functional for 1.6.2.
Although if everything is working properly, then no need to make the change.
Just to be sure, youre using the most up to date versions of those plugins? ive done tests on them for other threads before and its completely functional for 1.6.2.
Although if everything is working properly, then no need to make the change.
I checked, HUD Maker is officially on 1.6 and I am on... 1.42. Yikes. Huh.
thatd work just fine

So I finally got a chance to try it... it took longer than it normally does, but I did still get the bug.

Just to be clear, I took the linked code, pasted it into a file editor as-is, saved it as SelectionControlFix, and placed it directly underneath YEP_X_SelectionControl on the plugin menu. Is there anything I did wrong?
Is there anything I did wrong?
youve saved the project after installing the plugin? it wouldnt register as being added to the game till then
youve saved the project after installing the plugin? it wouldnt register as being added to the game till then
Double-checked just to be sure. Yeah, sadly it wasn't quite so easy.

Bizarrely enough, now the console log is telling me my Yanfly plugin order is wrong, but I manually cross-referenced my plugin list with the list the console gave me, and everything is in order. So the new patch plugin might be causing that, since I recall it was telling me my plugins were fine before.

I doubt that's relevant, but I thought I'd bring it up anyway, just in case.
console log is telling me my Yanfly plugin order is wrong, but I manually cross-referenced my plugin list with the list the console gave me, and everything is in order
if youre using Aloe's order checker plugin, its not up to date. the order they appear on yanfly's website is the order to use
So the new patch plugin might be causing that, since I recall it was telling me my plugins were fine before.
Putting the code from my fix into your project couldn't cause that - an order checker plugin can't detect or reference any plugin other than the ones it's programmed to look at.

It's going to be very difficult for other people to help you troubleshoot, due to you using the outdated version of MV and outdated other plugins.

I think your best bet is to do some basic, logical troubleshooting.

Turn off all plugins except the Selection Control, its patch, and any prerequisites (Battle Engine and Target Core). Save the project, start a new game (not loading a save file) and see whether you have the problem with just that setup.

If you do, make a new test project with the current version of MV and the plugins, duplicate the setup, and if you can reproduce the bug then describe how to do it to other people and they should be able to assist.

If your game with all those other plugins disabled does not have the bug, then you turn back on a few at a time, saving and starting a new game every time, until you come up with the specific combination of plugins that causes the problem, and that tells you where to look.
if youre using Aloe's order checker plugin, its not up to date. the order they appear on yanfly's website is the order to use
I did use that list to order them first, for what that's worth... I suppose it's kind of strange that the two lists apparently agreed with each other then, lol

Putting the code from my fix into your project couldn't cause that - an order checker plugin can't detect or reference any plugin other than the ones it's programmed to look at.

It's going to be very difficult for other people to help you troubleshoot, due to you using the outdated version of MV and outdated other plugins.

I think your best bet is to do some basic, logical troubleshooting.

Turn off all plugins except the Selection Control, its patch, and any prerequisites (Battle Engine and Target Core). Save the project, start a new game (not loading a save file) and see whether you have the problem with just that setup.

If you do, make a new test project with the current version of MV and the plugins, duplicate the setup, and if you can reproduce the bug then describe how to do it to other people and they should be able to assist.

If your game with all those other plugins disabled does not have the bug, then you turn back on a few at a time, saving and starting a new game every time, until you come up with the specific combination of plugins that causes the problem, and that tells you where to look.
Honestly, I'm actually having a fair amount of trouble even getting everything isolated for proper playtesting... is there any possibility that simply updating the plugins and RMMV version could fix any of this, or at least get it to being possible? I mean, I suppose that depends on how up-to-date the HIME and Galv libraries are, since I do use a few of theirs. I do have an up-to-date Yanfly library, just... not necessarily all in this exact project.

Does plugins.js change between versions or can I just copy that over?
So on more rigorous playtesting, the lock-up does seem much rarer than before. And I've been fighting the first boss and haven't had a single lock-up against it.

Could it have something to do with how CTB processes turns? Is that a possibility? Like, maybe that cache refreshing isn't kicking in as it's meant to because something about how turns are being handled was changed?

I'm just spitballing, but it really does seem better. And it's weird that it'd just outright fix the issue for everyone but me.
you reminded me of something i found in testing once in STB, but I cant remember if it was a one-off thing or if i added additional calls to clear the cache in other places. ill look into it when i can over the weekend, but if you manage to find a set of steps that get it to happen in CTB, share them and Itll make finding it faster.
Its probably just that theres an additional place needed to clear the cache, but where it is right now should cover any time the game needs to switch the current actor in CTB.
you reminded me of something i found in testing once in STB, but I cant remember if it was a one-off thing or if i added additional calls to clear the cache in other places. ill look into it when i can over the weekend, but if you manage to find a set of steps that get it to happen in CTB, share them and Itll make finding it faster.
Its probably just that theres an additional place needed to clear the cache, but where it is right now should cover any time the game needs to switch the current actor in CTB.
The only consistency I've been able to spot is it sometimes happens to the first actor to act after an enemy does. It's never any other time and it's not even every time.

... that and it doesn't seem to happen so long as an enemy actively exists in the front row (I thought an enemy simply having been in the front row made it not happen, but I was eventually able to trigger it even then). Like I said before, I was playtesting a boss fight (despite what I said before, apparently this guy is in the front row), and I didn't get the lock-up even once.

Best as I can tell, the only conditions are:
1. be the first actor to act after an enemy does
2. no enemies in the front row
3. get unlucky

I also tried finessing a passive state on every actor/enemy that clears the Selection Control cache at action start and action end, but sadly it didn't seem to help consistently. Not to say it didn't help, just... not consistently.

If you got any theories, though, I'd be more than happy to try them. It's just, "turn off every plugin and playtest up" isn't something I can really do, for... a lot of reasons. A lot of my skills have complex effects that rely on plugins to function. I use on-map encounters instead of random, and need plugins to sort that out. Stuff like that.

But I mean, I'm pretty confident it has something to do with some mix of Selection Control, CTB, Row Formation, and Battle AI Core, since the previous crash was to do with all of those (sans CT😎, and I'm pretty confident at this point that that crash was a symptom of this issue.

Original thread: https://forums.rpgmakerweb.com/threads/selection-control-sometimes-disabling-my-offensive-skills.179561/