# --------- Next Sound ----------------
execute if entity @s[tag=!hidden] if predicate entity/hurt run playsound custom.hermit_crab.hurt hostile @a ~ ~ ~
execute if entity @s[tag=hidden] if predicate entity/hurt run playsound custom.hermit_crab.hurt_hidden hostile @a ~ ~ ~
execute if predicate entity/hurt run function 0_enemy_boss:sound_cooldown/reset_by_hurt

execute if score @s EB_next_sound matches ..0 run function 0_enemy_boss:sound_cooldown/generic
execute if score @s EB_next_sound matches 1 run playsound custom.hermit_crab.ambient hostile @a ~ ~ ~

# ------------ Hide ------------------
function olink:ch1/find_linked
execute if entity @s[tag=hidden] if predicate entity/hurt run function enemies:hermit_crab/hide
execute if entity @s[tag=hidden,scores={EB_next_attack=1}] run function enemies:hermit_crab/unhide
execute if entity @s[tag=!hidden] if predicate entity/hurt run function enemies:hermit_crab/pre_hide

# --------- Visual ----------------
# Tp
execute rotated ~ 0 run tp @e[type=marker,limit=1,tag=ch1_olinked,tag=aj,distance=0.02..] ^ ^ ^.2 ~ ~

# Hurt
execute if predicate entity/hurt as @e[type=marker,limit=1,tag=ch1_olinked,tag=aj] run function hermit_crab:set_variant/hurt
execute if predicate entity/not/hurt as @e[type=marker,limit=1,tag=ch1_olinked,tag=aj] run function hermit_crab:set_variant/default

# Animation
execute if entity @s[tag=!hidden] if predicate entity/moving as @e[type=marker,limit=1,tag=ch1_olinked,tag=!aj.hermit_crab.anim.walk] run function enemies:hermit_crab/aj/walk
execute if entity @s[tag=!hidden] if predicate entity/not/moving as @e[type=marker,limit=1,tag=ch1_olinked,tag=!aj.hermit_crab.anim.idle] run function enemies:hermit_crab/aj/idle