MV Yanfly Battle AI Core + Selection Control conflict?

So like anyone here, I've been working on a small game recently. I'm actually really close to release, but when I handed a friend a little teaser just to give an idea of what's to come as well as get some feedback, he discovered that the game crashes when some really strange, oddly specific combinations of encounters occur. While somewhat on the rare side, it's something I've been able to mostly consistently recreate, which means it isn't just some freak incident and I actually have a legitimate issue on my hands.

After a whole day of testing out practically everything I could think of (such as disabling every plugin that isn't Yanfly, removing pieces of notetag data, altering stats, changing encounters, reordering plugins [I'll be up front and say they're not in precise order, but doing so created other problems and didn't even fix the issue at hand, so I had to put them back], etc. etc.), I happened upon something curious: if I disabled either Battle AI Core or Selection Control, the game ran fine, no crashes. (Or at least, the same methods couldn't recreate them.) Which tells me this has to do with those two interfering with each other.

This doesn't seem to be an isolated incident, either. In my search for solutions, I spotted a thread from a few months ago (it actually was what put me on the right track to begin with) where someone was also having crashes as a result of these two plugins conflicting.

Unfortunately, their solution was to simply disable one of them, as the OP had put the entire Yanfly library into their plugins folder and wasn't actually using one of them (forget which it was) in their game. Fair enough, but... I am using both, and quite extensively at that. I really can't afford to cut either one.

Alas, my knowledge of Javascript isn't sufficient enough to dive into the plugins' code and fix this myself... which leads me to all of you. I'm not necessarily asking for any handouts, just... guidance in solving this, hopefully. I feel I'm just way too far along to scrap everything or start over with a different framework in mind.

Here's the crash report, for what it's worth. If there's any other information I can provide, I'd be happy to. (On that note, I'm running in 1.5.2, both on the game itself and in the RPG Maker MV program I'm building it on. As well, both BattleAICore and SelectionControl are up to date.)

1676768886636.png
The only solution is to search what cause this. Before fixing on script..
Seing word like frontRow (?) It seem this battle have position on front, back , middle?
And your battler nothing in front?
The only solution is to search what cause this. Before fixing on script..
Seing word like frontRow (?) It seem this battle have position on front, back , middle?
And your battler nothing in front?
Well, a front and back row, to be more precise, but yes, I am using Row Formations as well. (also integral to the combat, unfortunately.)

I usually playtest with characters in both rows, though. In this particular case I only had one character and they were in the front row though, so it wouldn't seem that specifically would be causing anything.

... that being said, I did try testing the situation without RowFormations active anyway, and sure enough, you're right, the crashes did go away. So it's not merely a conflict between Battle AI Core and Selection Control... it's some kind of three-way conflict between Battle AI Core, Selection Control, and Row Formations. This got a lot weirder very quickly.

For what it's worth, Row Formations is also up to date.
the solution I can give.. Is added try catch to avoid those error on YEP_X_SelectionControl. But I don't know what happen if fixing on there can make bug on other part.
is kinda skip the error

the solution I can give.. Is added try catch to avoid those error on YEP_X_SelectionControl. But I don't know what happen if fixing on there can make bug on other part.
is kinda skip the error

I think I understand the principle, though I'm unfortunately having trouble wrapping my head around how I'd actually... do this, if that makes sense.

I get that I'm probably supposed to wrap the problematic code in a try {} bracket (which I do think I've pinpointed the code in question), but I'm not sure what to put in a catch {} bracket. To note, it references a "target" within the code (one full string is if (target.isActor() === this.subject().isActor()) return true;, as one example), and the core issue is that apparently "target" is undefined (if that error message is being completely honest, at any rate), so how would I amend that in a catch {} bracket?
You can make condition like this before going to execute the error/warning line
Code:
If(target!=null) 
.... Line that produce error
I think you're being led down the wrong path.

There's no need to add additional checks for the target to exist inside of that function, because under correct circumstances it should be impossible for that function to be called on a target that doesn't exist.

A few things that set off warning lights for me in your post:
I'll be up front and say they're not in precise order, but doing so created other problems and didn't even fix the issue at hand, so I had to put them back
This is huge. Having Yanfly's plugins out of the specified order can cause random, unsolvable errors. You are much better off putting them into the correct order and then troubleshooting whatever other problems come up.

I know you said it didn't fix this when you rearranged them, but it's a basic foundation.

On that note, I'm running in 1.5.2, both on the game itself and in the RPG Maker MV program I'm building it on.
This is also significant. The core scripts for MV 1.5.2 have unaddressed bugs. If your Yanfly plugins are older (e.g. version 1.13 of Selection Control), they may have unaddressed bugs.

And if your Yanfly plugins are up to date (e.g. version 1.15 of Selection Control), they're not compatible with MV 1.5.2.

I can't think of any reason for you to work with outdated software, and it makes it almost impossible for other people to help you troubleshoot because we're not going to have cached prior versions of MV and Yanfly code to refer to.

If you're using some plugin that's not compatible past 1.5.2, you should be able to get assistance with making it work with the newest version.

So my strong suggestion is to update your project to 1.6.1, make sure you have the updated Yanfly library, put it in the correct order, then troubleshoot from there.
I think you're being led down the wrong path.

There's no need to add additional checks for the target to exist inside of that function, because under correct circumstances it should be impossible for that function to be called on a target that doesn't exist.

A few things that set off warning lights for me in your post:

This is huge. Having Yanfly's plugins out of the specified order can cause random, unsolvable errors. You are much better off putting them into the correct order and then troubleshooting whatever other problems come up.

I know you said it didn't fix this when you rearranged them, but it's a basic foundation.


This is also significant. The core scripts for MV 1.5.2 have unaddressed bugs. If your Yanfly plugins are older (e.g. version 1.13 of Selection Control), they may have unaddressed bugs.

And if your Yanfly plugins are up to date (e.g. version 1.15 of Selection Control), they're not compatible with MV 1.5.2.

I can't think of any reason for you to work with outdated software, and it makes it almost impossible for other people to help you troubleshoot because we're not going to have cached prior versions of MV and Yanfly code to refer to.

If you're using some plugin that's not compatible past 1.5.2, you should be able to get assistance with making it work with the newest version.

So my strong suggestion is to update your project to 1.6.1, make sure you have the updated Yanfly library, put it in the correct order, then troubleshoot from there.
If memory serves, I think the entire SRD library stops being functional in 1.6.1... and I use a lot of his library. And that's just the one I noticed right away that got me heading back to 1.5.2., because stuff like his HUD Maker are a big deal.

As far as the plugin order goes, for what it's worth I did make sure to follow the basic directions when adding them. If it says "make sure this is below X and Y", I made sure it was below X and Y. It's not in the optimal order, and I do have a backup of the "right" order, but said order made the menu crash the game, so I'm admittedly not too eager to try that again... though I'm also not completely against it, either.

I just wish there were some guarantee that doing all this would fix the issue :/
If memory serves, I think the entire SRD library stops being functional in 1.6.1... and I use a lot of his library.
That isn't correct. I don't use a lot of his plugins, but the several I do use work perfectly fine. There are absolutely people on the current version of MV using HUD Maker.

If that's a big concern, you can update MV (which won't affect your existing project until you copy the files over), make a new project, put the SRD stuff in, configure it for basic use, see if it pops any errors.

Then if there are problems using them in the current version of MV, ask separately for help updating them as necessary. But I have seen zero support threads over, like, two years about that. And SRD plugins get referenced/recommended often.

Heck, copy your project directory and apply the 1.6.1 update process to that, so you can roll back if your world explodes.

Then turn off all plugins that aren't Yanfly. Make sure those plugins are also the latest versions. Sort them into the order listed on the Yanfly Engine Web site.

Test your game. If the error that prompted this thread is still happening, you get help troubleshooting with your project in that condition.

Then when you fix it (or if it never happens after those steps), you turn on non-Yanfly plugins and see what works or what doesn't.

For the grand part, if another plugin causes a conflict, you should be able to solve it by moving that plugin in the plugin manager - I can't imagine why a plugin conflict would force you to reorder your Yanfly plugins.

I just wish there were some guarantee that doing all this would fix the issue :/
I understand your frustration, but the current state of your project really makes it not feasible for other people to help you. We have no way of knowing whether something is conflicting between your plugins because they conflict, or because they're expecting different versions of the game, or because they're not compatible with the version of your game at all.

Once you standardize your material a bit, then we have a point of reference for any errors you're still getting.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-battle-ai-core-selection-control-conflict.155090/