Battles inside sub-maps showing extreme lag

Extreme lag = frames advance so slowly it's basically unplayable.

On the "World Map" (a top-level map) battles (both random encounters and Battle Processing events) work just fine. However, when I'm inside of "sub maps" (fields, dungeons, and towns) I experience the slowdown.

My project uses many scripts, but again, battles run perfectly on the world map. I can enter a town/field/dungeon (where battles are broken) and return to the world map, and battles continue to run perfectly.

I tried many different searches for my issue, but most of them had to do with accidental autorun events.

image:


Sorry for all the redactions.
It is likely to do with scripts. What battle script is you using?
I'm using two: Yanfly and RBS (which is compatible with Yanfly)
What events do you have on those maps that are set to parallel process? Or a common event that's set to parallel process, that's enabled when you're on those maps. Or troop events that might be set to run during the whole battle?

How big are all of those maps, and your world map? Is it ONLY the world map where they work okay?
I agree with Shaz. It's likely that you have several events set to parallel process on each map, but not the world map. If the battles are fine on the world map, then it should not be the script. It may be other scripts that have an effect on the maps.
Something I didn't ask ... on those maps, is it ONLY the battles that are laggy? Or is it the whole map (and maybe more noticeable in battles)? Are the battles done via the normal battle screen, or do you have some kind of on-map-battle system happening?

If it's regular battles, where you go to the battle screen, then it won't be events, but it could still be troop events.
I didn't ask about events because I assumed it went into regular battles which led me to believe it had something to do with scripts. I asked what kind to see if that could be something, but alas, none.

I will say I agree with Shaz that if what I assumed was correct, it may be event troop pages.

If what I assumed was wrong, then its probably events.
I'm using two: Yanfly and RBS (which is compatible with Yanfly)
Please give links to the websites of those plugins

Not only will that be neccessary to check if there is indeed something with the scripts, but I don't even know what RBS is (and the same probably goes to a lot of others here), and we can't really help you without knowing what might connect those scripts to lag or battleproblems.
What events do you have on those maps that are set to parallel process? Or a common event that's set to parallel process, that's enabled when you're on those maps.
As far as I know, there are no parallel processes on these maps. I am implementing the battle system before the scenario-type events in each town/dungeon/area, so those areas are currently only full of doors (no NPCs, no treasures). It is possible that I (somehow) unintentionally set an event to a parallel process that isn't supposed to be.

To check, I created a new sub-map without any events except one that starts battle processing, and it did work correctly. It seems I will have to check all maps for events accidentally created with a parallel process.

However, for example, there is one sub-map that has only a single event--an exit. It plays a SE then transfers the player back to where they came. It is set to Player Touch. Battles slow down there.

Or troop events that might be set to run during the whole battle?
I'm not sure what a troop event is.

How big are all of those maps, and your world map?
The sub-maps range from small (30x30) to quite large (200x200+). The World Map is 300x300.

Is it ONLY the world map where they work okay?
I used to think so, but as I wrote above, I created a new sub-map with no events and battles work there.

Something I didn't ask ... on those maps, is it ONLY the battles that are laggy? Or is it the whole map (and maybe more noticeable in battles)?
Only the battles are laggy. The map runs fine.

Are the battles done via the normal battle screen, or do you have some kind of on-map-battle system happening?
Normal battle screen. No special battle maps.

Please give links to the websites of those plugins

Not only will that be neccessary to check if there is indeed something with the scripts, but I don't even know what RBS is (and the same probably goes to a lot of others here), and we can't really help you without knowing what might connect those scripts to lag or battleproblems.
Ramiro's Battle Engine
Ace Core Engine

From the RBS script:
# List of Compatible YEA scripts:
# BATTLE SCRIPTS:
# - Ace Battle Engine (Insert BEFORE RBS)
# Known Issues: Disable one of the popup systems or YEA popup or
# RBS popup.

And they are indeed compatible because, as stated, battles work just fine. It's certain maps where they are breaking.
Working =/= compatible. They could both run but due to how they are set up they might make certain functions not work as intended, and you may never know this until you need that function or notice your damage or something isn't what you expect.

However, I don't think that is the issue. I'd check your troop events as that seems to be the most likely culprit, as it acts like you have one set to always run in some battles. Troop events are set on the troops tab of the database. Check there. Otherwise, I'd suspect your map size (as 300 x 300 is really huge, like say ~8 - 9x as large as Final Fantasy 6's world map in terms of area). See if you can get it to work on smaller maps first as well and go from there.

Edit: Can you also hit F2 and get the FPS on both the maps it works well on and the one it doesn't? A video of a battle on the bad map will help too, but at least post the FPS counts for those who cannot watch videos.
I'm not sure what a troop event is.
An event defined on the troop page of the database

I'm reasonably sure about what is going on here, but that is not easy to solve and needs some explanations before you can even start searching for the (multiple) causes - exactly because it has multiple causes and not a single one.
It is lag, but lag everywhere and from multiple causes.

Lag is additive, and the computer has a reserve for handling lag without making it obvious. That reserve is mostly created by the upper limit of 60 fps on the game, if that were not the case you would see the fps dropping even without battles on different maps.

Something on your project uses up a lot of that reserve, allowing the game to continue barely without lag as long as you're not using up more by the map and going into battle.
The battlesystem you use is resource-intensive simple because it has a lot of animations and action sequences - that needs processing power, but usually most computers have that power - unless it is already used up by other things.

And because this doesn't happen on all maps (and because a single parallel can't use up all reserves unless you have a really old computer), I suspect that it is a result of several things using up only a bit of the power each.
Please check the common events, you might accidentally have switch one to parallel process without really using it (happened before) as well as your troop events.

And please check if any of the animations used by the engine uses a hue calculation to change color - those are really, really hard on the processor for a neglegtible effect, it's usually better to make a second picture with the color corrected outside the engine.
It wouldn't be a common event in battles, unless you have a plugin to allow common events to run during battles.

I also suspect it's not a troop event as the OP didn't even know what that means, and while it might be possible that one or two were accidentally set to span battle, it's unlikely that the majority were. One way to test this would be to find a troop where the battles lag, and then to make a NEW troop entry with the same enemies - don't copy/paste, but create it from scratch. Then change your event to fight that troop instead of the original one, on a map that has the issues, and see if it continues to happen. If it does, then it's not troop event pages.

I'm thinking it's either one of the scripts or a combination of the scripts (plugins).

That note you pasted here from RBS states that you need to disable one of the popup systems as there is a known issue when they are both enabled. This in itself indicates the plugins are not compatible. Did you disable one of them?
Edit: Can you also hit F2 and get the FPS on both the maps it works well on and the one it doesn't? A video of a battle on the bad map will help too, but at least post the FPS counts for those who cannot watch videos.
I'm going to come back to this thread again to respond to everyone, but I did a quick check on this. Oddly, the FPS continues at a perfect 60 even during the battle lag.

I'll return with more replies and a video.
Oddly, the FPS continues at a perfect 60 even during the battle lag.
That is the most important info at all, because it means that this is NOT lag, but something deliberately paused something in your battles.
We need an exact description of what happens during the battle to give a better guess at what this really is.


I'll give you an example for the difference what happens here.
Let's assume you have a parallel process that checks if a button is pressed to do something whenever the player presses the button.

If you make that PP without any waits, it is processed sixty times per second - that uses up a lot of CPU resources, thereby adding to lag. At the same time no player will ever be able to press the button sixty times per second, so there is no need for that.
So the usual solution is to add a command wait(6) or so, causing the engine to skip processing that event for six frames before checking the button again. That results in the button being checked again only 8-9 times per second - still more than enough to react to any input.

Now assume that someone makes a mistake and sets the wait to wait(60) or so.
Now the parallel process only checks for the button once per second (which means any reaction can be delayed by up to a second), and if the player is pressing and releasing the button very fast the engine might even skip detection in one second, because the button needs to be pressed at the exact frame when the PP is processed.

The second part looks like lag to the player, because the reaction to the buttons is slowed a lot - but it isn't real lag because the CPU idles most of the time, the cause is that the button check is too rare to be fast.

There are a few other things that might look like lag but aren't, and the better your description of what really happens the better our chances of guessing right where it comes from.
A video showing four different battles.

Sorry in advance for the poor editing. I muted the video because Bandicam somehow recorded every sound twice as if with an echo effect.
At this point I would ask for a working demo. However I can't guarantee I could help anytime over the next month. I'm moving and my internet will be sporadic, plus my main computer will be in a box.
Thanks everyone for your input. I managed to figure out, and it turns out it was none of the above. It had nothing to do with scripts or events.

I systematically changed options to see if I could break the "debug submap" I created. That's the one that worked perfectly when I tested it--a new submap with no events. I finally managed to break it by changing the tileset the map used. What I believe was happening was that, because I had added a page or two to some of the tilesets, when the battle background was trying to get drawn the system got confused and tried to display the given tile as the battle background. Since I changed the tilesets, I may have broken that function. As you may know, by default all non-world map tilesets are set to "Field" mode, while the rest are set to "Area" mode.

So, I simply used the Specify Battle Background option (which I had planned to do anyway for all maps--just didn't get to it yet). Voila, problem solved.

Thanks again for your input.
yes, there is a connection there - but it would not happen by default unless there are other problems influencing this.
Is it possible that one of the tilesheets in that problematical tileset is incomplet? MV gets into problems if the tilesheets are not the exact size required, because they're mathematically split and if part of the data is missing, those formula don't work correctly.

If that incomplete data then gets calculated into the field-setting of no specified background, it might really cause some problems for the engine.
Because if no background is specified, the engine usually tries to create a background based on the tile on that position...

Original thread: https://forums.rpgmakerweb.com/threads/battles-inside-sub-maps-showing-extreme-lag.81353/