Immunity from visible map encounters after battle

Hello,


I am implementing on-map encounters using Yanfly's Event Chase Player plugin. The problem that I've run into is that if the player is being chased closely by two or more events and engaged into battle, then if the other enemy has already reached him as well, the player will be engaged into a battle immediately after the first one.


I'd like to get rid of that.


I've tried implementing a common event that is called upon after the battle using Shaz's Battle Result Switches that stops all event movements for a while (with Yanfly's Stop Map Movement plugin) and reenables them after a certain amount of frames.


However, if the enemy has already 'reached' the player beforehand (because it reached the player approximately at the same time as the first enemy), then he is engaged into battle immediately regardless.


I was wondering if there was a way to make the player immune to being engaged on after a battle. Do you have any suggestions on how to implement something like that?


Any kind of help is appreciated! 🙂
You could have it so that when you win a battle, a switch is turned on, and for the other event, if that switch is on, do not run the battle processing. However, you'd need a way to turn off the switch after x time, and the only way I can think of is a parallel process that only runs when the switch is on, set to wait x frames, then turn off the switch.
@bgillisp


Thank you very much! I tried it and it works! 😀


Unfortunately, I have really terrible fps-drops when using this solution (dropping to 1~6 fps after a battle). I didn't think that a single parallel process would cause this much lag. I'm not sure whether this is connected to one of the plugins used or the way that the engine checks for the switches on events.


If someone knows of a more elegant solution (or the cause of those lagspikes), I'd be very happy to hear it 🙂
Hmmm...if you have the wait set long enough it shouldn't matter. Maybe post your parallel process and your battle processing check so we can see them?
02.jpg


This is the event that triggers after every battle. This will in turn trigger the following event:01.jpg


And here is the page for the on-map enemy:


03.jpg


The battle processing itself does not have any event pages.


Edit: Forgot the page for non-moving enemies:


04.jpg


Edit 2: I think I've found the solution. Apparently I messed up some of the enemies' pages and didn't remove their custom routes. I am dumb. Thank you so much for your help, @bgillisp! <3
I'd also move the StopMapMovement command (to turn the switch on) to the start of the common event rather than the end.  Because you've got it set to parallel process instead of autorun, it means events with commands could process while you're doing all those conditional branches and text, so it's still possible for one of the events to start their processing before you get to the command that pauses the events.  That's probably the main cause actually - you don't stop them soon enough.  
That makes sense! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/immunity-from-visible-map-encounters-after-battle.72534/