Bonfire respawn?

Hello.

I have made a system where enemies in-map respawn after the player dies/interacts with a "bonfire".
1592582291306.png

These commands check if the "Respawn" switch (which is turned ON after the player dies or interacts with a "bonfire") is on and then reset the enemy event to its default.
This causes all enemies in the map where the player died and all enemies in the map where the player rested at a "bonfire" to respawn. Problem is... what happens to the enemies in the middle?

This video illustrates it:


As it's shown, the player kills all enemies in Map 1 and 2, then dies in Map 3. This death triggers the parallel process-common event that activates (then quickly deactivates to avoid infinite respawning) the Respawn switch, resetting all enemies in both the map where the player died and the map where they respawned in. But all the enemies in the middle map stay dead instead of properly respawning.

The same problem occurs after resting in the "bonfire". If you kill enemies in Map 1 and 2, then rest at the "bonfire" in Map 1, only the enemies on Map 1 will be respawned, enemies in other maps won't because the switch hasn't been triggered in their maps.

I've been thinking a lot about this and would deeply appreciate any ideas! 😀
please show full screenshots of the event code.

most likely you messed up with page priority somewhere, and we need to see all events and their event pages to find out where.

edit:
and the self-switches are different on each event, so using them will not reset more than one event directly - another reason why we need to see the entire code
Selfswitches are called that because they are switches relating to a given event itself. It's possible to change the selfswitches of another event (and there are many uses for that), but in that code snippet you only change the switches of your specific event.

As Andar said, please provide all your code so we have a clearer understanding of what might have gone wrong.
Okay, i'm using SAS as the main ABS script. When enemies die, they switch to their "Local Switch D" page. All enemies have their D switches looking like this: (It's in Portuguese but you may be able to comprehend)

1592591533477.png

It's a Parallel Process that's asking for the state of the Respawn switch, which is activated whenever the player dies or interacts with a "bonfire".
Here's the (rather convoluted) page for when the player dies, it is an Autorun common event page that runs everytime player HP reaches zero(click to enlarge, then zoom in):
1592592225372.png


Notice the "Respawn" activation occurs right before the player teleports (so it assures all enemies in the map he died are reseted) and right after he teleports (assuring that every enemy in the last map he interacted with a bonfire is also reseted.) This solves the issue in both Map 1 and Map 3, but it doesn't respawn enemies in Map 2, which is what i'm trying to achieve.

It's convoluted eventing but it works. You can be sure nothing else in the "code" affects what i'm trying to achieve. The problem requires ingenious eventing to solve.
@RedFawkes You have not shown us what happens on pages 1 and 2 of that first event.
@RedFawkes You have not shown us what happens on pages 1 and 2 of that first event.
The contents of pages 1 and 2 are not really pertinent to the problem: the enemy events are essentially identical and work as intended with the respawning system. Nevertheless, here is page 1, which runs a common event (enemy AI) as a parallel process (click to enlarge):.
1592667206071.png

Here's the enemy AI common event page for this particular enemy:
1592667300828.png

When the enemy dies, their local switch C is activated, which runs a common event as a parallel process:
1592667377990.png

Here's the common event, a "death" process which, at its end, activates the local switch D :
1592667464648.png

Here's page 3 of the event, with local switch D activated:
1592667530035.png

It is a parallel process that's constantly asking if the player has triggered a respawn event.

I hope you're able to understand the essentials.
If I understand your original problem correctly, then you'll need a different respawn switch for every map, and that respawn switch needs to be switched off only after entering that specific map.

The problem is that events are only processed if their map is loaded, so the respawn needs to happen on entering that specific map. And that means the events of any map can't react to a respawn switch that has already reset on a previous map.

as for handling the respawn switch, make a parallel process map event on that map, with (in this order) a wait of three frames first, then control switch respawn off, then erase event.

if you want to hide the flicker of respawns, have a fadeout before entering the map and fadein after the switch is off and before the erase event
If I understand your original problem correctly, then you'll need a different respawn switch for every map, and that respawn switch needs to be switched off only after entering that specific map.

The problem is that events are only processed if their map is loaded, so the respawn needs to happen on entering that specific map. And that means the events of any map can't react to a respawn switch that has already reset on a previous map.

as for handling the respawn switch, make a parallel process map event on that map, with (in this order) a wait of three frames first, then control switch respawn off, then erase event.

if you want to hide the flicker of respawns, have a fadeout before entering the map and fadein after the switch is off and before the erase event
Actually, the respawn switch must be switched on after entering the map. I remember trying something similar, like this (this is supposed to run everytime the player changes maps):
1592671747448.png

But that makes so that enemies in every map respawn regardless of player dying or touching the "bonfire". Then i added a switch that is turned ON everytime the player dies or touches the "bonfire", this is the result:
1592671453280.png

Now enemies in map will respawn if the player touched a "bonfire" or died. However, every enemy in every map will respawn because there's no "Off" condition for this switch. Say i killed enemies in map 1 and map 2, then died in map 2, i'll activate the "Touched Flame" switch because i died, now enemies will respawn in map 1, then i'll go to map 2 and they've also respawned, but if i go back to map 1, however, enemies will respawn because the "Touched Flame" switch is still ON.

I hope you're able to understand.
i'll activate the "Touched Flame" switch because i died, now enemies will respawn in map 1, then i'll go to map 2 and they've also respawned, but if i go back to map 1, however, enemies will respawn because the "Touched Flame" switch is still ON.
and that is exactly why I told you you need one respawn switch per map.
you need one switch "respawn map 1", one switch "respawn map 2", one switch "respawn map 3" and so on. Each switch to trigger the respawn on that specific map, with all enemies having an event page triggered by that switch on parallel process that resets them. And the event I described above is to guarantee that the respawn only work once on that map.

and then you set the different map respawns based on where the player was and what happened.
You CANNOT have enemies of different maps react to the same respawn switch, or you will have the problems that you cannot set the respawn of those maps independently of each other.

and yes, that means that your bonfire or death events have to set multiple switches if they want respawns on multiple maps. as long as you have the respawn of multiple maps handled by a single switch they will be connected where you don't want them.
With that and some additional workarounds i managed to make it work! Thank you!

Original thread: https://forums.rpgmakerweb.com/threads/bonfire-respawn.123073/