MV Help with battle action sequences

Hello, so I'm trying to make a battle system that will let your character dodge if they hit a button when prompted to, but I'm having trouble getting it to work the way I want.
The problem I'm having is adding a timing function to the button prompt so that the player has a certain amount of time to hit the button and avoid the attack. I've tried all sorts of things and I just can't get this function to work.
Currently I'm using SRD Timer Upgrade, and Yanflys action sequences.
I have the event set up so that when the timer runs out it calls on a common event that will activate a switch which will activate the rest of the action sequence for the enemy battler.
So basically it goes timer starts, button prompt, player has 60 frames to hit a button, if player hits button he gets a buff to nullify damage, timer end activates a common event (plugin command SetExpireCommonEvent 2), common event activates a switch which should prompt the enemy battler to perform their attack.
The problem is that the enemy always attacks as soon as the timer starts. This is the action sequence:

<setup action>
common event: 1
common event: 3
if $gameSwitches.value(4, true)
move user: forward, 200, 60
wait for movement
change switch 4: off
change variable 4 = 0
end
</setup action>
This is just one of several attempts I've made trying to do this and they all have the same problem where I can't make a timer for the input. I know what I've got works to some degree because there is a brief moment where I can input the button and get the status effect to trigger, but the battle system always skips any timing event I try and implement.
Thanks
Yes, the action sequence won't wait for the built-in timer to expire. The timer is designed to run in the background, after all. Instead, you can write your common event as a QTE sequence, e.g.
  • Turn off a "success" switch
  • Set a "time" variable = 60 (frames)
  • Loop
    • Is "time" variable <= 0?
      • If yes: Break Loop
      • If no: -1 from "time"
    • Is input pressed?
      • If yes: turn on "success" switch and Break Loop
    • Wait 1 frame
  • Check "success" switch and react accordingly
You can add stuff like pictures/prompts as needed. You may find this tutorial helpful~
Alternatively you could look around for a plugin that does all the input checks etc for you. I think SRD has some that are designed for use with Yanfly's Action Sequences:
[Edit: this Timed Attacks link might be titled "MZ plugins", but the page is definitely for MV.]
Just a sidenote:

$gameSwitches.value(4, true) will error as value only takes one parameter. What your condition should be is

$gameSwitches.value(4) === true
@Trihan - technically it should be OK here since the value method returns a Boolean and only references the first argument. Good to clarify the usage, though~ ^_^
True, but like you said best to get into the habit of doing the calls and clauses correctly.
Thanks, I think I got it to work now.
Yes, the action sequence won't wait for the built-in timer to expire. The timer is designed to run in the background, after all. Instead, you can write your common event as a QTE sequence, e.g.
  • Turn off a "success" switch
  • Set a "time" variable = 60 (frames)
  • Loop
    • Is "time" variable <= 0?
      • If yes: Break Loop
      • If no: -1 from "time"
    • Is input pressed?
      • If yes: turn on "success" switch and Break Loop
    • Wait 1 frame
  • Check "success" switch and react accordingly
You can add stuff like pictures/prompts as needed. You may find this tutorial helpful~
Alternatively you could look around for a plugin that does all the input checks etc for you. I think SRD has some that are designed for use with Yanfly's Action Sequences:
[Edit: this Timed Attacks link might be titled "MZ plugins", but the page is definitely for MV.]
Moved to: Plugin Support

$gameSwitches.value(4) === true

or just

$gameSwitches.value(4)

since === true will be true if the switch is true, and false if the switch is false.

Original thread: https://forums.rpgmakerweb.com/threads/help-with-battle-action-sequences.137205/