Whack-A-Mole Minigame Bug

Hey everyone!

It's been months that I've been working on a special project on RPG Maker MV and finally I'm sharing my first post. I have a problem with the eventing of a little minigame inside my RPG and can't figure out what exactly the problem is.

whackamole.jpg

I followed this tutorial on RPG Maker Web by @hiddenone to build a whack-a-cat minigame, set up the events, the variables, thought I had understood the logic, but the game gets stuck in the play test.

The cats randomly flash up, but much too fast, and the player doesn't turn, no matter which buttons I press. The timer does count down, but when reaching 00:00, nothing happens, the game does not stop. Overall: It doesn't work! And I don't know why!
Can someone help me figure out what I'm not seeing?

Spoiler: Event Screenshots
whackamole01.jpg

whackamole02.jpg

whackamole03.jpg

whackamole04.jpg

whackamole05.jpg

Above screenshots of the 5 different events and following the eventing of the Autorun Event. I'd appreciate it greatly if anyone could take the time and take a look at it and tell me what the hell I'm doing wrong!

Code:
◆Tint Screen:(0,0,0,0), 30 frames (Wait)
◆Show Balloon Icon:Player, Exclamation (Wait)
◆If:Bezuna Random = 0
  ◆Text:felicity(0), Window, Bottom
  :    :Hit the arrow keys to catch the cats!
  :    : ↑ cat above you ↓cat under you
  :    : → cat right of you ← cat left of you \!
  :    :Minigame starts in 3,\| 2,\| 1,\| Go!\|
  ◆Control Timer:Start, 0 min 30 sec
  ◆
:End
◆Loop
  ◆Control Variables:#0005 Bezuna Random = Random 0..4
  ◆If:#0013 ≠ Bezuna Previous
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Control Variables:#0007 Bezuna Timer = 30
◆Control Variables:#0008 Bezuna Choice = 0
◆Control Variables:#0006 Bezuna Previous = Bezuna Random
◆Control Variables:#0009 Bezuna Total += 1
◆Loop
  ◆If:Button [Left] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Left
    ◆Control Variables:#0008 Bezuna Choice = 3
    ◆
  :End
  ◆If:Button [Right] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Right
    ◆Control Variables:#0008 Bezuna Choice = 2
    ◆
  :End
  ◆If:Button [Up] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Up
    ◆Control Variables:#0008 Bezuna Choice = 1
    ◆
  :End
  ◆If:Button [Down] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Down
    ◆Control Variables:#0008 Bezuna Choice = 4
    ◆
  :End
  ◆If:Bezuna Choice ≥ 1
    ◆If:Bezuna Choice = Bezuna Random
      ◆Flash Screen:(0,119,0,51), 5 frames
      ◆Wait:5 frames
      ◆Control Variables:#0010 Bezuna Score += 1
      ◆Break Loop
      ◆
    :End
    ◆
  :Else
    ◆Flash Screen:(119,0,0,51), 5 frames
    ◆Wait:5 frames
    ◆Play SE:Wind4 (50, 100, 0)
    ◆Break Loop
    ◆
  :End
  ◆Control Variables:#0007 Bezuna Timer -= 1
  ◆If:Bezuna Timer = 0
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆
:Repeat Above
◆If:Timer ≤ 0 min 0 sec
  ◆Text:felicity(3), Window, Bottom
  :    :Time's up!
  :    :
  :    :You caught \v[10] of \v[9] cats!
  ◆Transfer Player:Orchard (9,7) (Direction: Down)
  ◆
:End
Could you change the autorun setting to parallel and see what happens?
thanks for your quick reply! if I change the Autorun event to parallel, the cats flash up at random spots (much too fast) and instead of being stuck in the middle, the player can walk around the map while the minigame is on... the timer counts down but when it reaches 00:00, still nothing happens.
The problem is if you use an autorun the player cannot do any input until the autorun event is over. If you want to make it so the player can't move but can do other input use this before your timer start
Script:
JavaScript:
if($gamePlayer.moveByInputCached === undefined)
//This checks if the value is undefined

$gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
//If it is undefined, it sets to the current value of $gamePlayer.moveByInput which is 'true'

$gamePlayer.moveByInput = function(){
return false;
}

and this after your timer ends
JavaScript:
$gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
//This resets the value of moveByInput to the cached value

Also after If:Timer ≤ 0 min 0 sec
do
Control Timer: Stop

What's on the first page of the cat event?
Okay, I updated the eventing and switched it back to autorun, but still nothing happens after the timer is over and the player is stuck in the middle without being able to turn, no interaction with the targets at all.

Code:
◆Tint Screen:(0,0,0,0), 30 frames (Wait)
◆Show Balloon Icon:Player, Exclamation (Wait)
◆If:Bezuna Random = 0
  ◆Text:felicity(0), Window, Bottom
  :    :Hit the arrow keys to catch the cats!
  :    : ↑ cat above you ↓cat under you
  :    : → cat right of you ← cat left of you \!
  :    :Minigame starts in 3,\| 2,\| 1,\| Go!\|
  ◆Script:if($gamePlayer.moveByInputCached === undefined)
  :      :$gamePlayer.moveByInputCached = $gamePlayer.moveByInput;
  :      :$gamePlayer.moveByInput = function(){
  :      :return false;
  :      :}
  ◆Control Timer:Start, 0 min 30 sec
  ◆
:End
◆Loop
  ◆Control Variables:#0005 Bezuna Random = Random 0..4
  ◆If:#0013 ≠ Bezuna Previous
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Control Variables:#0007 Bezuna Timer = 30
◆Control Variables:#0008 Bezuna Choice = 0
◆Control Variables:#0006 Bezuna Previous = Bezuna Random
◆Control Variables:#0009 Bezuna Total += 1
◆Loop
  ◆If:Button [Left] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Left
    ◆Control Variables:#0008 Bezuna Choice = 3
    ◆
  :End
  ◆If:Button [Right] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Right
    ◆Control Variables:#0008 Bezuna Choice = 2
    ◆
  :End
  ◆If:Button [Up] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Up
    ◆Control Variables:#0008 Bezuna Choice = 1
    ◆
  :End
  ◆If:Button [Down] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Down
    ◆Control Variables:#0008 Bezuna Choice = 4
    ◆
  :End
  ◆If:Bezuna Choice ≥ 1
    ◆If:Bezuna Choice = Bezuna Random
      ◆Flash Screen:(0,119,0,51), 5 frames
      ◆Wait:5 frames
      ◆Control Variables:#0010 Bezuna Score += 1
      ◆Break Loop
      ◆
    :End
    ◆
  :Else
    ◆Flash Screen:(119,0,0,51), 5 frames
    ◆Wait:5 frames
    ◆Play SE:Wind4 (50, 100, 0)
    ◆Break Loop
    ◆
  :End
  ◆Control Variables:#0007 Bezuna Timer -= 1
  ◆If:Bezuna Timer = 0
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆
:Repeat Above
◆If:Timer ≤ 0 min 0 sec
  ◆Control Timer:Stop
  ◆Script:$gamePlayer.moveByInput = $gamePlayer.moveByInputCached;
  ◆Text:felicity(3), Window, Bottom
  :    :Time's up!
  :    :
  :    :You caught \v[10] of \v[9] cats!
  ◆Transfer Player:Orchard (9,7) (Direction: Down)
  ◆
:End

The first page of each of the 4 cat events looks like this:

whackamole06.jpg
I'll look at this tomorrow if no one else does as it's 1AM where I am right now. However I took a look at the tutorial you linked and it is in an autorun, so you don't need the javascript I posted, that's only if you set the event to parallel.

Also the events in that tutorial are really fast, so you would have to change the settings to slow them down.
Yeah, I figured that the settings are set to fast, but even experimenting with the variable doesn't change anything. I actually figured out a small mistake I had in my eventing and updated it, still all my problems remain... Why does my conditional branch loop that checks what input the player gives not do anything? Why doesn't my player turn?

Code:
◆Tint Screen:(0,0,0,0), 30 frames (Wait)
◆Show Balloon Icon:Player, Exclamation (Wait)
◆If:Bezuna Random = 0
  ◆Text:felicity(0), Window, Bottom
  :    :Hit the arrow keys to catch the cats!
  :    : ↑ cat above you ↓cat under you
  :    : → cat right of you ← cat left of you \!
  :    :Minigame starts in 3,\| 2,\| 1,\| Go!\|
  ◆Control Timer:Start, 0 min 30 sec
  ◆
:End
◆Loop
  ◆Control Variables:#0005 Bezuna Random = Random 0..4
  ◆If:#0013 ≠ Bezuna Previous
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Control Variables:#0007 Bezuna Timer = 100
◆Control Variables:#0008 Bezuna Choice = 0
◆Control Variables:#0006 Bezuna Previous = Bezuna Random
◆Control Variables:#0009 Bezuna Total += 1
◆Loop
  ◆If:Button [Left] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Left
    ◆Control Variables:#0008 Bezuna Choice = 3
    ◆
  :End
  ◆If:Button [Right] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Right
    ◆Control Variables:#0008 Bezuna Choice = 2
    ◆
  :End
  ◆If:Button [Up] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Up
    ◆Control Variables:#0008 Bezuna Choice = 1
    ◆
  :End
  ◆If:Button [Down] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Down
    ◆Control Variables:#0008 Bezuna Choice = 4
    ◆
  :End
  ◆If:Bezuna Choice ≥ 1
    ◆If:Bezuna Choice = Bezuna Random
      ◆Flash Screen:(0,119,0,51), 5 frames
      ◆Script:target = $gameMap.event($gameVariables.value(5))
      :      :$gameTemp.requestAnimation([target], 2);
      ◆Wait:5 frames
      ◆Control Variables:#0010 Bezuna Score += 1
      ◆Break Loop
      ◆
    :Else
      ◆Flash Screen:(119,0,0,51), 5 frames
      ◆Wait:5 frames
      ◆Play SE:Wind4 (50, 100, 0)
      ◆Break Loop
      ◆
    :End
    ◆
  :End
  ◆Control Variables:#0007 Bezuna Timer -= 1
  ◆If:Bezuna Timer = 0
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆
:Repeat Above
◆If:Timer ≤ 0 min 0 sec
  ◆Break Loop
  ◆Control Timer:Stop
  ◆Text:felicity(3), Window, Bottom
  :    :Time's up!
  :    :
  :    :You caught \v[10] of \v[9] cats!
  ◆Transfer Player:Orchard (9,7) (Direction: Down)
  ◆
:End

Is it a problem with RPG Maker MZ/MV compatibility maybe? I think the tutorial is intended for MZ, I just applied everything to MV.

Thanks anyway for your help so far, and if anyone else could take the time and a look, I'd greatly appreciate it!
My thoughts, Autorun Event is fine in this Circumstance, it prevents the player from moving,
and the Autorun Event is detecting the pressed directional buttons. That seems fine.

The Code looks very clean and good so far, the last part confuses me a little bit, will edit here if i notice something.
Edit1:
My big blind Guess, in your first shown Eventcode Picture in post1, try this in that Backup:
The following code block is the last one in your Picture, copy paste it into the Loop above.
And delete the one on the last Position.
It looks wrong, that its down there. But iam not sure.

Code:
◆If:Timer ≤ 0 min 0 sec
  ◆Break Loop
  ◆Control Timer:Stop
  ◆Text:felicity(3), Window, Bottom
  :    :Time's up!
  :    :
  :    :You caught \v[10] of \v[9] cats!
  ◆Transfer Player:Orchard (9,7) (Direction: Down)
  ◆
:End

Edit2: In the Place where you took the above Codeblock, you could add the Eventcommand
Wait or Wait Random, to delay the new spawning of a Cat. This is also a Guess and i hope i did not
missread the Code.

Edit: All is with reference to the First Post and the Pictures shown there.

EDIT3:
Variable7 Bezuna Timer is set to 30. That means half a second until a Cat respawns/time to react?.
60 = 1 Second. You would need to increase that number to fix the Flashing up of Cats.
I mean this line in your Eventcode:
Code:
◆Control Variables:#0007 Bezuna Timer = 30

Edit4:
I dont have MV installed at the moment, but in MZ Conditional Branch Button Press, you can choose between Pressed and Triggered, if MV also offered that, try changing that to Triggered.
Iam not sure why your Player cant turn. Did you by accident activate Direction Fix in another Event?
To test that you could use the command: deactivate direction fix, than the turn command.
If it works than, than you somewhere have such Event interfering.

Edit5:
Do not use old Safe Files.
Thanks a bunch! Unfortunately, playing around with Variable 7 Bezuna Timer does not change anything, I tried that before, but for some reasons the cats keep flashing at the same speed, no matter if I put in 30, 60 or 100.
My big blind Guess, in your first shown Eventcode Picture in post1, try this in that Backup:
The following code block is the last one in your Picture, copy paste it into the Loop above.
And delete the one on the last Position.
It looks wrong, that its down there. But iam not sure.
Tried that, had no effect. The autorun eventcode now looks like this:
Code:
◆Set Weather Effect:None, 60 frames (Wait)
◆Tint Screen:(0,0,0,0), 30 frames (Wait)
◆Show Balloon Icon:Player, Exclamation (Wait)
◆If:Bezuna Random = 0
  ◆Text:felicity(0), Window, Bottom
  :    :Hit the arrow keys to catch the cats!
  :    : ↑ cat above you ↓cat under you
  :    : → cat right of you ← cat left of you \!
  :    :Minigame starts in 3,\| 2,\| 1,\| Go!\|
  ◆Control Timer:Start, 0 min 30 sec
  ◆
:End
◆Loop
  ◆Control Variables:#0005 Bezuna Random = Random 0..4
  ◆If:#0013 ≠ Bezuna Previous
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Control Variables:#0007 Bezuna Timer = 100
◆Control Variables:#0008 Bezuna Choice = 0
◆Control Variables:#0006 Bezuna Previous = Bezuna Random
◆Control Variables:#0009 Bezuna Total += 1
◆Loop
  ◆If:Button [Left] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Left
    ◆Control Variables:#0008 Bezuna Choice = 3
    ◆
  :End
  ◆If:Button [Right] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Right
    ◆Control Variables:#0008 Bezuna Choice = 2
    ◆
  :End
  ◆If:Button [Up] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Up
    ◆Control Variables:#0008 Bezuna Choice = 1
    ◆
  :End
  ◆If:Button [Down] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Down
    ◆Control Variables:#0008 Bezuna Choice = 4
    ◆
  :End
  ◆If:Bezuna Choice ≥ 1
    ◆If:Bezuna Choice = Bezuna Random
      ◆Flash Screen:(0,119,0,51), 5 frames
      ◆Script:target = $gameMap.event($gameVariables.value(5))
      :      :$gameTemp.requestAnimation([target], 2);
      ◆Wait:5 frames
      ◆Control Variables:#0010 Bezuna Score += 1
      ◆Break Loop
      ◆
    :Else
      ◆Flash Screen:(119,0,0,51), 5 frames
      ◆Wait:5 frames
      ◆Play SE:Wind4 (50, 100, 0)
      ◆Break Loop
      ◆
    :End
    ◆
  :End
  ◆Control Variables:#0007 Bezuna Timer -= 1
  ◆If:Bezuna Timer = 0
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆If:Timer ≤ 0 min 0 sec
    ◆Break Loop
    ◆Control Timer:Stop
    ◆Text:felicity(3), Window, Bottom
    :    :Time's up!
    :    :
    :    :You caught \v[10] of \v[9] cats!
    ◆Transfer Player:Orchard (9,7) (Direction: Down)
    ◆
  :End
  ◆
:Repeat Above
Check for any other Parallel Events or Common Events running Parallel /Autorun
that might interfere with your Code. Plugins that use the Same Variables and maybe are changing them.
It is very strange that the Game is not turning the Player.

Also i Edited more in the above Post.


Edit:
Bug Found:
Code:
◆Control Variables:#0005 Bezuna Random = Random 0..4
I guess it needs to be this:
Code:
◆Control Variables:#0005 Bezuna Random = Random 1..4

0 is only for the start initialisation. Later it has to be 1,2,3 or 4 to Work.

This could cause some trouble.
I've been wondering about the triggered/pressed down difference too, unfortunately there is no option to choose in MV it seems...

whackamole07.jpg


Maybe something I can do with a script call instead?

There's no Direction Fix anywhere, Common Events should not interfere, automated/parallel events on other maps previously include weather changes, tint screen, and cut scenes that are deactivated after they appeared. My player doesn't get stuck anywhere else, only in this mini game. What else might be interfering with it?

As also the ending of the timer has no effect, it seems like the whole game dynamic is at fault here and I'm overseeing something crucial... idk!

edit: I'm starting the game fresh every single time, no old save files being used.

edit 2: I changed what you've identified as bug, but nothing changed. Then I found another bug myself! The Variable for Bezuna Random was wrongly assigned in the beginning of the code.
Code:
  ◆If:#0013 ≠ Bezuna Previous

    ◆Break Loop

Now that I've corrected that, my player can actually move!

The cats stopped flashing, spawning now in a correct amount and the screen also flashes green when the player caught a cat, but the script call to get the animation did not work as this script call does not seem to exist on MV. I removed it.

For some reason, the exclamation icon kept reappearing on the players head regularly, so I took it out of the event all together.

The mini-game does not stop when 00:00 is reached, no matter if the end part is outside of the loop as the tutorial suggested or inside of the loop, as @Bex suggested.

Now the eventcode looks like this:

Code:
◆Set Weather Effect:None, 60 frames (Wait)
◆Tint Screen:(0,0,0,0), 30 frames (Wait)
◆If:Bezuna Random = 0
  ◆Text:felicity(0), Window, Middle
  :    :Hit the arrow keys to catch the cats!
  :    : ↑ cat above you ↓cat under you
  :    : → cat right of you ← cat left of you \!
  :    :Minigame starts in 3,\| 2,\| 1,\| Go!\|
  ◆Control Timer:Start, 0 min 30 sec
  ◆
:End
◆Loop
  ◆Control Variables:#0005 Bezuna Random = Random 1..4
  ◆If:Bezuna Random ≠ Bezuna Previous
    ◆Break Loop
    ◆
  :End
  ◆
:Repeat Above
◆Control Variables:#0007 Bezuna Timer = 30
◆Control Variables:#0008 Bezuna Choice = 0
◆Control Variables:#0006 Bezuna Previous = Bezuna Random
◆Control Variables:#0009 Bezuna Total += 1
◆Loop
  ◆If:Button [Left] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Left
    ◆Control Variables:#0008 Bezuna Choice = 3
    ◆
  :End
  ◆If:Button [Right] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Right
    ◆Control Variables:#0008 Bezuna Choice = 2
    ◆
  :End
  ◆If:Button [Up] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Up
    ◆Control Variables:#0008 Bezuna Choice = 1
    ◆
  :End
  ◆If:Button [Down] is pressed down
    ◆Set Movement Route:Player (Wait)
    :                  :◇Turn Down
    ◆Control Variables:#0008 Bezuna Choice = 4
    ◆
  :End
  ◆If:Bezuna Choice ≥ 1
    ◆If:Bezuna Choice = Bezuna Random
      ◆Flash Screen:(0,119,0,51), 5 frames
      ◆Wait:5 frames
      ◆Control Variables:#0010 Bezuna Score += 1
      ◆Break Loop
      ◆
    :Else
      ◆Break Loop
      ◆
    :End
    ◆
  :End
  ◆Control Variables:#0007 Bezuna Timer -= 1
  ◆If:Bezuna Timer = 0
    ◆Break Loop
    ◆
  :End
  ◆Wait:1 frame
  ◆
:Repeat Above
◆If:Timer ≤ 0 min 0 sec
  ◆Break Loop
  ◆Control Timer:Stop
  ◆Text:felicity(3), Window, Bottom
  :    :Time's up!
  :    :
  :    :You caught \v[10] of \v[9] cats!
  ◆Transfer Player:Orchard (9,7) (Direction: Down)
  ◆
:End
I was wrong the Timer Conditional Branch needs to be outside of the Loop, at the end of the Code.
Sorry my mistake.

The Break Loop in your Timer Conditional Branch will most likely do that the rest of the code is not executed.

Code:
◆If:Timer ≤ 0 min 0 sec
  ◆Break Loop <--- The Code below will never be executed.
  ◆Control Timer:Stop
  ◆Text:felicity(3), Window, Bottom
  :    :Time's up!
  :    :
  :    :You caught \v[10] of \v[9] cats!
  ◆Transfer Player:Orchard (9,7) (Direction: Down)

Edit:
As soon as the Basic Code works, the Community can assist you in adding the missing Features, like the Balloon Icon, Animations and other stuff you might want.
Thank you so much, that was it! Now the game works as it should and it ends as it should. Before I'm working on adding animations and stuff, I have a timing related question.

This part:
Code:
◆Control Variables:#0007 Bezuna Timer = 30
seems to be setting the time the player has to touch the correct button, not the time it takes until a new cat spawns. What am I misunderstanding? How can I make the cats switch positions quicker?
Fun fact, you solved it yourself XD, i totally oversaw that wrong assigned Variable.

The Bezuna Timer time is also the Time until a new Cat can spawn, because this setup only allows 1 single cat at a time, not multiple ones, but there could be reasons for a unwanted Delay.

Edit:
I would try to keep the Bezuna Timer on 30-60 than, and try to uncheck the Wait Boxes in the Moveroute Commands that turn the Player. The Timer will not run down while the Movecommand Waits, which results in next Cat appearing later than it could.
Code:
    ◆Set Movement Route:Player (Wait) <--- I ment that Wait Boxes
    :                  :◇Turn Left

Edit:
Maybe you can also remove the 5 Frames Wait in here. At the moment I cant see a reason why they could be needed.
Code:
     ◆Flash Screen:(119,0,0,51), 5 frames <---In here also make sure Wait Box is NOT Checked.
      ◆Wait:5 frames <-----try to remove that.
      ◆Play SE:Wind4 (50, 100, 0)
All those Waits will stop your Eventcode Loop from running in circles for smal periods of Time, which will result in the Cats appearing later as possible.

Original thread: https://forums.rpgmakerweb.com/threads/whack-a-mole-minigame-bug.158309/