# Пока игрока нет поблизости - функция не сработает
schedule function lbdm:quest3/gooners/gotcha 1t
execute if entity @e[tag=quest3_gooner1_ai,nbt={NoAI:1b}] run return fail
execute if entity @e[tag=quest3_gooner2_ai,nbt={NoAI:1b}] run return fail
execute as @a at @s if entity @e[tag=quest3_gooner,distance=..7] run worldborder warning distance 100000000
execute as @a[tag=!cooldown] at @s if entity @e[tag=quest3_gooner,distance=..7] run playsound lbdm:quest3.heartbeat master @a ~ ~ ~ 0.5 1
execute as @a[tag=!cooldown] at @s if entity @e[tag=quest3_gooner,distance=..7] run schedule function lbdm:quest3/gooners/gotcha_cooldown 1s
execute as @a[tag=!cooldown] at @s if entity @e[tag=quest3_gooner,distance=..7] run tag @a add cooldown
execute as @a at @s unless entity @e[tag=quest3_gooner,distance=..7] run worldborder warning distance 3
execute as @e[tag=quest3_gooner,tag=!screamer,sort=random,limit=1] at @s unless entity @a[distance=..2] run return 0

# Функция
#execute as @a at @s run tag @e[tag=quest3_gooner,limit=1,tag=!screamer,sort=nearest] add screamer_cam
execute as @e[tag=quest3_gooner,tag=!screamer] at @s if entity @a[distance=..2] run function lbdm:quest3/gooners/punch
execute as @e[tag=quest3_gooner,tag=!screamer] at @s if entity @a[distance=..2] run tag @s add screamer
execute as @e[tag=quest3_gooner,tag=!screamer] at @s if entity @a[distance=..2] run schedule clear lbdm:quest3/gooners/gotcha