How to make a timed task during combat

Godot Version

Godot 4

Question

Hello, I’m making a combat system and I’d like to add a timed button press during combat. So essentially its a roguelike that when you press A to attack it triggers a gauge that you need to hit keys in succession for. (usually between 3 and five spelling different words)

How would I do something like this?

You use timers:

var timer_active: bool = false

@onready var timer: Timer = $Timer

func activate_timer() -> void:
    timer_active = true
    timer.start()
    await timer.timeout
    timer_active = false

Now you just have to check if the thing is being pressed during “time_active == true”

I’m a little new to this. So I know that that turns the timer on, and then it listens to a keypress. How do I set it up so that it randomizes what you need to press?

So say you use the enter key to swing a sword, it triggers the timer and then you are prompted to type the word ‘break’ within the time.

How would I set that up?

you may do process_frame increment and when it certain range - count as true

var condition_value:=0:
	set(value):
		condition_value=value
		wrapi(condition_value, 0, 999)
func _process(_d):
	condition_value+=1

make different script with _input check, when it certain range

if condition_value>333 and condition_value<666: return true

then your action
node with func _process should be toggled when needed with

node.process_mode=Node.PROCESS_MODE_DISABLED
node.process_mode=Node.PROCESS_MODE_INHERIT