"Beam Struggle" system

Hi everyone,

     Well on my game I would like to include a sort of struggle mini-game. Lets say an enemy magician casts a mind control spell. I would like a bar to appear that fills up as you press the 'Z' button. But decreases as the enemy magician presses an imaginary space bar.

Something like this:
yo6Q2.png


    If you succeed then the bar gets full and you fend them off. If you fail then the event runs as it would. It would also be nice if one of the player's parameters had an impact on the game. For example, a higher Magic Attack Power would mean your button pushing impacts the bar more.

     I've tried many of the button mashing tutorials and even some different scripts, but none function how I would like this one to. I imagine this is could be accomplished with eventing. But I'm confused on how to do it. Any help would be greatly appreciated!
Does anyone have any suggestions?
My first instinct is to do a simple recursive method:

Button input; update values; draw new bar -> win/lose: yes? end script; no? call again on next button press.

You'd have the 'opponent' calling the same method, so it would probably be a bit trickier than that, but shouldn't be too bad.

Make it a destructive method and you shouldn't have to worry about stack issues.
My first instinct is to do a simple recursive method:

Button input; update values; draw new bar -> win/lose: yes? end script; no? call again on next button press.

You'd have the 'opponent' calling the same method, so it would probably be a bit trickier than that, but shouldn't be too bad.

Make it a destructive method and you shouldn't have to worry about stack issues.
Are you talking about eventing or scripting? I managed to get the result I wanted through eventing, but I'm always open to more suggestions.

Original thread: https://forums.rpgmakerweb.com/threads/beam-struggle-system.25324/