[Ace] Proximity Events Keep Retriggering

http://forums.rpgmakerweb.com/index.php?/topic/415-proximity-events/

I'm trying to make a system where you have on-map battles.

If an enemy sees you within a range of 5, they run toward you and initiate battle.

If you flee, the enemy also flees (or at least, is meant to - is where I run into issues as you'll see in a second)

You see, if there are multiple enemies in the same area and they all initiate battle at the same time, then the player will be stuck in an endless loop of battles, as the battle screen is never exited before the next battle starts, and I simply cannot get the other events to stop their battle processing whilst in range if already triggered.

This is most likely due to the events being Parallel processes, but the script requires this so I'm not quite sure what else I can do :/

Here is an example which I set up and duplicated a few times (the real one is more complicated) but both run into the same issue, if they all attack the player at the same time.

EDIT: I realize I don't have an erase event on the 'if win' in this example but that doesn't seem to be the actual issue lol

Spoiler
w0jAqjw.png


umLMD1L.png
You should make an "invincibility" time after each battle (so the events will not be able to trigger another random battle until the inv time is over). So far, all of the on-map encounter systems I saw used that system.

Here is a basic invincibility time maker snippet you can try:

Spoiler
class Game_System attr_accessor :inv_time alias init_inv_time5532 initialize def initialize init_inv_time5532 @inv_time = 0 end endclass Scene_Battle < Scene_Base alias set_inv_time8875 terminate def terminate set_inv_time8875 $game_system.inv_time = 300 end endclass Scene_Map < Scene_Base alias upd_inv_time6654 update def update upd_inv_time6654 $game_system.inv_time -= 1 if $game_system.inv_time > 0 end end
Insert this anywhere on your script list (towards the bottom would be ideal).

What this does?

It makes a custom variable for you to be used as the inv time counter.

I have set the invincibility time to 5 seconds in the snippet (300 frames), but you can raise/lower it how you want. Don't forget that it is measured in frames.

Aside from entering this snippet into your script list, you will need to add another check for your battle initiating events.

The scripted condition check would look like this:

$game_system.inv_time <= 0This means that anything inside this check will only run when the inv time reached zero/expired.I did not check the above snippet, just wrote it hastily now. Try it out and see if it works or not.

The snippet could also be expanded with some visual effects, such as the player blinking while in invincibility time, etc, I just don't have the time to do that now.

Original thread: https://forums.rpgmakerweb.com/threads/ace-proximity-events-keep-retriggering.48848/