Common Events can be interrupted by other Parallel events? How best to event instead?

I initially posted about this issue here, but I am having my doubts that it is an issue to do with the script(s) used:

http://forums.rpgmakerweb.com/index.php?/topic/48848-ace-proximity-events-keep-retriggering/

Now, when you're running a parallel event that activates a battle upon proximity 1 to the player (as per the script used) one will activate, then a second event - a second battle - will also activate, if it activates at the exact right time. This causes the game to be thrown into an infinite loop whereby even if you win battle 1, battle 2 gets processed, then battle 1's victory processing (specifically, events set up to occur after battle) never goes through.

So I have here a conundrum. 

When making common events, you cannot use "erase event" as per normal, since that just erases the common event. You have to use the self-switch commands (which is weird, considering erase event should also work in this context if self-switches do, but nevertheless...) to go to another page of the event to cause it to erase itself.

Now, because common events don't work as I'd like them to, this puts me in a bit of an awkward situation. I could re-event the entire map of encounter events to erase themselves, thereby hopefully avoiding the common event queue situation, as well as probably implementing a completely different proximity event script that doesn't require PP. I have tested without the use of common events, and battles seem to clear and activate just fine...

However, this means such encounters are not so easily tweaked.

How would one implement an on-touch, proximity-based encounter system? (Essentially, I don't want approach to occur until the player is within X tiles of the encounter)

The best way I have had it to work so far is by simply utilizing an event touch rather than the proximity script on proximity 1, but the default event touch is terrible, as there is a huge delay before the event "touches" you properly. As in, it has to be on a tile next to you and actually moving toward you to register as a touch. Even that is very sporadic in whether it works or not.

Still, it is the most reliable way I've found so far that doesn't trigger infinite loops.

Is there a way to improve the event touch processing so that there isn't such a huge lag in its actual process (hence why I was using proximity 1 from the script earlier as a battle condition) and yet utilize common events, or am I SOL with parallel processes and common event interruptions?

(I'm happy to provide a demo with the common event interruption as an example if required)
I don't know if I got what you need but you could try something like this (it is untested so I am not sure it works).

  1. Set up any event in the map to react to a switch (we call it FIGHT_WON from now on). If FIGHT_WON is off the event follows the player and reacts to proximity. When in range it stores its ID in a variable (we call it v[iD] from now on) and changes another variable to a certain value (we call it v[encounter] from now on). If FIGHT_WON is on then the event checks for v[iD] value, if it is the same as its ID then sets v[iD] to 0 and SelfSwitch A on.
  2. Set up another parallel process in the map that checks v[encounter] value. If it is not equal to 0 the event triggers a battle. If the player wins it turns FIGHT_WON ON and sets v[encounter] to 0, if the player runs it just sets v[encounter] to 0. If v[encounter] is 0 and FIGHT_WON is ON the event checks for v[iD]. If v[iD] is 0 then turns FIGHT_WON off.
This way the battle is processed by another event and it cannot process 2 battles simultaneously. You should still have your proximity working but the second battle won't trigger unless you solved the first one.

I hope this helps.
Yup, got it working so the events stack, rather than causing a weird loop. Thanks. Had to use a script flag on battle win/escape, but the general idea works, made it a little simpler.

However, now a situation is arising with the way RM is actually handling event processing.

If say, there are 4 enemies in an area, and you leave through a door, and as you are just about to get through the door, the enemies get really close to you (one tile away). However, you go through the door and nothing happens. Then you go back to the same room, returning to where you left (so basically, back through the door) - a battle will trigger.

Either RM is not refreshing events fast enough when you return to a map (unlikely, the events were back to their original spots after going back through the door) or the parallel process is continuing from before (the proximity 1 flag), and therefore the event goes to self switch C (the battle trigger event) and attacks me, FROM MEMORY.

Currently bashing my head in trying to get this to work as it should -_-
Did you try to reset the flag when the player touches the transfert event?
Just for additional info:

Please follow the link "bughunting" in my signature, it explains about what parallel processes really are and how they can create timing problems if mixed.

Original thread: https://forums.rpgmakerweb.com/threads/common-events-can-be-interrupted-by-other-parallel-events-how-best-to-event-instead.48925/