Problem with misbehaving If statement that checks the timer

Hi!
I wanted to create enemies that regenerate after a certain amount of time and can be killed by using certain items for a small demo project for my portfolio. I needed two things - a timer that when the count is equal to zero regenerates an enemy and a small interface to use an item to kill it permanently.
Thanks to a thread that Shaz replied to I got the timer to work correctly so my enemies correctly regenerate in a loop, but it all goes to hell when I try to create the interface to interact with a corpse.
question for forum 1.jpg


As soon as I activate the interface page (4th one) and it is possible to interact with a corpse, the If timer < 0 statement on page 3 suddenly stops working, despite the fact that nothing switches off the B self-switch (even if I don't interact with a corpse).

question for forum 2.jpg


Picking option No or when the player does not have the required item works correctly, after picking any of those options the enemy correctly self-resurrects after a certain amount of time.
I've tried to fix it for 2 days but I've only started to code recently and I honestly don't know what I'm doing wrong. Thx in advance for help.

For reference, page 5 of the behavior works correctly.
question for forum 3.jpg
So, the way you have your pages set up confuses me.

On Page 1 if you defeat the enemy you turn on Self Switch A to advance to Page 2.

On Page 2, which is Autorun, you start a timer and then turn on both Self Switch B & C.

This skips Page 3 and goes directly to Page 4 (C) which is an Action Button.

On Page 4 you have to click on the enemy again and then it immediately stops the timer before checking anything else. So I am curious why you started the timer in the first place on Page 2. And I am curious why you have Page 3 before Page 4 if you are going to skip over Page 3 initially.

On Page 4 it looks like if you don't have the necessary powder or you don't want to use it, that starts a timer again and turns off Self Switch C, which essentially sends you back to Page 3 (😎 that you skipped in the first place which is a Parallel.

Page 3 checks to see if the timer is <= to 0 and if so, it turns off Self Switches A, B, and C, essentially sending the event back to Page 1 to be ready to fight again.

What exactly is happening on Page 3 that tells you it isn't working? Have you tried changing the If statement to just = 0 instead of <= to 0? Don't know if that would make a difference, but that is something I would try since the timer shouldn't be less than 0.

I apologize if I have misunderstood your pages. They just seem a bit confusing to me.

Maybe someone else will look at this and know exactly what is wrong.
It seems a little messy since only one event page can be active at any given time. Personally, I would separate the timer event from the werewolf event...

But in any case, to humbly echo ZombieKidzRule, since you flip both switch B and C to ON at the same time, event 4 will be given priority and event 3 will not be active at all... so there really is no point (I think) in flipping switch B to ON on page 2. Perhaps try to switch B to ON with the NO and ELSE branches on page 4?
Hi, thanks for your replies!
1686493116931.png
This diagram sums up what I wanted to achieve. My big misconception was how event pages work. I thought that two separate pages can work simultaneously if one of them is set as parallel. Since it is not the case, I need to come up with something different.
1686493409257.png

1686493435603.png

I have only those two options ZombieKidzRule, but since only one page can be active at the same time, I doubt it would help.

​

I don't see what the point is in page 2, just put those commands in the If Win branch of page 1.

Then, you don't need to have the event checking the timer itself, you turn on a switch that activates a parallel common event. So your event page structure would be something like:
- Page 1, no condition: touch to initiate battle. On win, turn on game switch 5, set timer for 10 seconds
- Page 2, condition game switch 5, do the stuff to douse the corpse and turn on self switch A
- Page 3, condition self switch A, no graphic because you burned the enemy up.

Then you have a common event:
- Parallel, trigger of game switch 5. Wait 30, then if timer is <= 0, turn game switch 5 off

I'm saying switch 5, but obviously whatever ID you have free.
Thx for all advices, ATT_Turan, werzque, ZombieKidsRule! I've set up parallel events in order to start the timer and check the timer, I will refactor them a bit later. Now I know all I needed to progress further with my work, I think this thread can be closed now.

Original thread: https://forums.rpgmakerweb.com/threads/problem-with-misbehaving-if-statement-that-checks-the-timer.158225/