Timed Button Input

Hey everyone!


So for my current project, I'm substituting any sort of battle system for one that instead depends on the player inputting the correct button at the correct time in order to create conditional branches which would stem from their response. For example, the down arrow flashes on the screen and the player has three seconds to press that button on their keyboard to move out of the way of an arrow flying towards their head. This, of course would happen on the map, as opposed to within battles. So for anyone who's played games like The Wolf Among Us or A Game of Thrones: A Telltale Series, it would work similar to their combat mechanics.


I posted a similar question in the Plugin Request forums without success, so I'm hoping a very skilled eventer might be able to walk me through this!
It is better if you don't post multiple requests for the same thing - that's just confusing and makes everyone do extra work.  Also, you need to allow a few days for responses.  The forum rules is no bumping until 3 days have passed, and reposting the same request in a new thread is just another form of bumping.  Give people time.
It's quite easily eventable with a loop and a conditionnal in it's basic form.


Loop


  Conditionnal Button Input


    Do thing


  End conditional


  Wait 1 frame


End loop


If you want something more advanced  have you tried my plugin ?
Thank you for your answer!


Oddly enough, I tried your method of eventing without much success. For example, say I have the button input be the 'left' button, if the character is already speaking with an event and pushing any other button, the event will fail. Also, I'm unable to set a time limit using this method. It was my first instinct as well though! And thank you for trying!


Additionally, you wouldn't happen to have a demo for your script would you? I'm more of a hands-on learner as far as figuring out how to use it.
From a thread I answered last week, how to event a QTE:


For a basic QTE: (Accounting for multiple player inputs)

  • Set a variable to 0.
  • Make a loop.
  • In this loop check for a player button press via a conditionnal branch.
  • Each time the button is pressed add 1 to the variable and do whatever, play sound, shake the screen...
  • Then, with another conditional branch, check if the variable is >= to the number of times you want the player to press that button. If it is break loop.
  • Don't forget to add a small wait of 1 or 2 frames inside that loop.

To add a time limit:

  • Set another variable to 0 before the loop.
  • Inside the loop add 1 to the variable.
  • Check if that variable has reached a suitable number that would be too log. The number itself depends on how much the wait inside the loop is. If you have a 1 frame wait, 60 would be one second.
  • If it has reached that number it means the player didn't complete the QTE in time so do whatever you want (trigger game over in your case).



I don't really understand what you mean by if the player is speaking with another event the QTE will fail. In what I described there is no fail condition, it will loop until the button is pressed. Since I have no screenshot of what you've tried I can't help you more with your eventing.


There is no demo for my plugin. I'll get to it when I have more time. It would be as easy as 2 lines of code though, which you could find in the plugin's help file:

Code:
$gameMap.QTE(["normal"],300,["ok"],true) //start the QTE, duration 300 frames, waits for OK input.
$gameMap.getQTEResult() === "success" //in a conditional: script to check if the QTE was a success, "failure" for failure.
I must be misunderstanding something here. I've attached my event page. I don't possess a ">=" button, only the "=" or the ">" ones, separately. Strangely enough, simply upon talking to the event it adds five points to the variable as opposed to one which I ordered it to. I have another event which sets my variable to 0 at the start of the game.


What I meant by the event failing automatically is that say the player approaches from the left of the event. They'll be pushing the right button as they speak to the event and if the event is looking for the player to be pressing any other direction, it'll fail automatically.

Event Page.png
That's intended behaviour. If you hold the ok button, the condition is true so it'll trigger multiple times in one go.


One way to fix it is to add a wait on succcesfull button inputs (something like 10/20 frames) then it will trigger only once every 20 frames when the button is held down.


If you want it to only trigger on actual button presses and not when the button is held down then you'll have to use a script call:


Condition: Script:


Input.isTriggered("ok")




I understand what you mean with your second phrase but I don't get where it comes into play. We have not talked about a fail condition yet, in our example the qte simply won't respond if you press any other button. It won't fail. Or is it what you want to do but can't manage to?
I believe I figured out the basics on Ace, thanks to your help. I've attached my event page and will attempt to replicate it in MV. Please let me know if this looks accurate. It seems to be working just as I'd like it to.


I have a separate event which sets Var 1 and Var 2 to zero. Var 1 being my button press input counter and Var 2 being the timer. It looks a little messy, but if that's my only complaint then it's irrelevant! Do you have any suggestion for improving the current setup? Thank you so very much for all of the help! I really appreciate it!

Finished event.png
That's great, I'm glad you have figured out a working solution.


I don't have anything to add as for the event setup. It's how I do it. Even my plugin is just a more complex version of this.


You don't need the exit event processing command btw.


If you use the ok button, I suggest adding a small wait (5 frames) at the end of the QTE so that the game doesn't register the last ok trigger as a "speak to the event again" command.


Just know that's it's all fun and games until you try to have a sequence of button presses, then the conditionnals can really get messy.


It's also not straightforward to properly implement a fail condition other than a time limit.


Those two reasons and the graphical aspect are why I made the plugin cited earlier.

Original thread: https://forums.rpgmakerweb.com/threads/timed-button-input.71527/