Event that disables enemy respawn

Hi, some time ago I was looking for a way to create events with opponents that rise again some time after the battle and I implemented everything with the code that was advised to me here:

first thread

So now my encounters consist of 3 pages that looks like this:

1643736031668.png

var key = [this._mapId, this._eventId, "A"];
$gameSelfSwitches._data[key] = $gameVariables.value(82) + 5;
(variable 82 is my respawn clock timer)
1643736077309.png

$gameVariables.value(82) >= $gameSelfSwitches._data[[this._mapId, this._eventId, "A"]]
1643736105818.png


And it works great, when you defeat the enemy, it will lie on the ground for around a minute and then stand up again, but there is one problem. Like I said in the previous post, I need a special "tombstone" event that will trigger a specific switch that disables the respawn of the enemies (activates the third blank event page for all of them).

But for some reason, It doesn't work as it should. Sometimes when the switch is activated, all events with enemies go to page 3, and sometimes even after the switch is activated, all enemies remain active.

So, my question is, can the following code somehow toggle the switch? The thing is that when I activate the switch all the events with the enemies should immediately go to a third blank page, but for some reason, it does not always happen and it's strange.
it might be cause another plugin interfer or test on 2 enemies with an alternate
switch on page 2 and change page 3!

as for page 2, create an else handler, and see if you can set it up like:

else
if Switch (81) = ON
selfswitch B = ON
end

you might want to check that first, if OFF, do the code, else SS B is on.
than page 3, set SS B as requirement.

if that doesn't work, than I'm not sure, but there might be other methodes
as well.
it might be cause another plugin interfer or test on 2 enemies with an alternate
switch on page 2 and change page 3!

as for page 2, create an else handler, and see if you can set it up like:

else
if Switch (81) = ON
selfswitch B = ON
end

you might want to check that first, if OFF, do the code, else SS B is on.
than page 3, set SS B as requirement.

if that doesn't work, than I'm not sure, but there might be other methodes
as well.
I think that's a good idea to set up a safe else handlers, but the thing is: the first page is toggled by the event touch. It's the active stage when the event is walking and looking for you. And the second one is parallel where the event is laying down waiting for his resurrection timer to toggle the first page again. So no matter where I put this safe condition, you have to interact with the event (on the first page event must touch you and despite the fact that second page is parallel, to activate the second page on at least one enemy, you have to defeat it on his first page). There is a location with a lot of enemies that should already be laying down when you enter it with the active switch, or actively walking if you didn't activate the switch.

I tried to test it without battles and everything works fine, it is just that some players of my game reported that sometimes the disabling does not work and enemies remain active after turning the switch on. I myself, unfortunately, not even faced with this and do not know how to reproduce such a bug.
maybe set the switch instead of 2page to the 1st page with else handler.

if Switch(81) = ON
SS B = ON
else
the code of the original one
end

I think this will trigger SS B is on on revival (which is after the timer gone).
as it does't resurrect. (I can be wrong) but you can test it out.

you have to play around, otherwise I have no idea why it keeps going.
as the toggle is done on the scriptcall, and the parallel shouldn't
be active if page 3 requirement is met, otherwise it's really weird though.

Original thread: https://forums.rpgmakerweb.com/threads/event-that-disables-enemy-respawn.144537/