execute as @e[tag=poly_sheep] at @s unless entity @p[tag=polyd,distance=..1] run data merge entity @s {Invulnerable:1b,NoAI:1b}
execute as @e[tag=poly_sheep] at @s if entity @p[tag=polyd,distance=..1] run data merge entity @s {Invulnerable:0b,NoAI:0b}