#main
$execute as @s[scores={q_special_1=..0},tag=!idle] at @s unless entity @n[type=#main:enemies,tag=enemy,distance=..$(distance)] run function main:characters/engineer/q/id1/idle

execute as @s[scores={q_cooldown_t=1..}] run scoreboard players remove @s q_cooldown_t 1
execute as @s[scores={q_duration_t=1..}] run scoreboard players remove @s q_duration_t 1
execute as @s[scores={q_special_1=1..}] run scoreboard players remove @s q_special_1 1

$execute unless entity @e[type=#main:enemies,tag=enemy,tag=upgrade_5_target] rotated ~ 0 at @s facing entity @e[type=#main:enemies,tag=enemy,sort=nearest,distance=..$(distance),limit=1] feet run rotate @s ~ ~

$execute if score .mode engineer matches 1 if entity @e[type=#main:enemies,tag=enemy,tag=upgrade_5_target] rotated ~ 0 at @s facing entity @e[type=#main:enemies,tag=enemy,tag=upgrade_5_target,sort=nearest,distance=..$(distance),limit=1] feet run rotate @s ~ ~

$execute unless score .mode engineer matches 1 if entity @e[type=#main:enemies,tag=enemy,tag=upgrade_5_target] rotated ~ 0 at @s facing entity @e[type=#main:enemies,tag=enemy,sort=nearest,distance=..$(distance),limit=1] feet run rotate @s ~ ~

$execute as @s[scores={q_cooldown_t=0,q_special_1=..0}] at @s if entity @n[type=#main:enemies,tag=enemy,distance=..$(distance)] anchored eyes positioned ^ ^ ^ run function main:characters/engineer/q/id1/shoot with storage player_data 1

execute as @s[scores={q_special_1=1..}] at @s at @n[type=armor_stand,tag=engineer_q] run tp @s ~ ~ ~

execute as @s[scores={id=..0}] on passengers run scoreboard players set @s health 0

execute as @s[scores={engineer=1..}] at @s run function main:characters/engineer/q/id1/tick_2