1
0
This repository has been archived on 2025-06-02. You can view files and clone it, but cannot push or open issues or pull requests.

51 lines
1.4 KiB
GDScript3
Raw Normal View History

2025-03-21 18:18:34 -04:00
'''
Attempts to simulate human-esc responses.
green - good at subtraction
red - good at multiplication
blue - good at division
'''
2025-03-21 17:52:16 -04:00
extends Node
2025-03-21 18:18:34 -04:00
var currently_executing:bool = false
var faster_operand:String = ""
var wait_time:int
var is_correct:bool
var last_executed_player:int
2025-03-21 18:18:34 -04:00
var clock:int = 0
2025-03-21 18:18:34 -04:00
func _physics_process(_delta: float) -> void:
if GLOBALVARS.selected_player != 0:
if not currently_executing and GLOBALVARS.selected_player != last_executed_player:
2025-03-21 18:18:34 -04:00
if GLOBALVARS.selected_player == 1:
faster_operand = "-"
elif GLOBALVARS.selected_player == 2:
faster_operand = "*"
elif GLOBALVARS.selected_player == 3:
faster_operand = "/"
if GLOBALVARS.current_operand == faster_operand:
wait_time = randi_range(45,120)
2025-03-21 18:18:34 -04:00
is_correct = true if randf() > 0.05 else false
else:
wait_time = randi_range(60,350)
2025-03-21 18:43:29 -04:00
is_correct = true if randf() > 0.15 else false
2025-03-21 18:18:34 -04:00
currently_executing = true
last_executed_player = GLOBALVARS.selected_player
2025-03-21 18:18:34 -04:00
elif clock > wait_time and currently_executing:
2025-03-21 18:18:34 -04:00
if %ANSWER.text == "":
%ANSWER.text = str(GLOBALVARS.current_solution) if is_correct else str(GLOBALVARS.current_solution+(1 if randf() > .5 else -1))
2025-03-21 18:18:34 -04:00
elif clock > wait_time + 30:
%ANSWER.emit_signal("text_submitted",%ANSWER.text)
currently_executing = false
clock = 0
2025-03-21 18:18:34 -04:00
else:
clock+=1
else:
clock+=1
else:
last_executed_player = 0