$execute if entity @a[tag=headshot_raycast] positioned ~ ~0.35 ~ if entity @s[tag=!boss,tag=!no_headshots] unless entity @s[tag=!$(id)_$(character)_$(type)_raycast_hit,dx=0] positioned ~ ~-0.3 ~ run tag @s add headshot
$execute if entity @a[tag=headshot_raycast] positioned ~ ~1.5 ~ if entity @s[tag=boss,tag=!id14_mob,tag=!no_headshots] unless entity @s[tag=!$(id)_$(character)_$(type)_raycast_hit,dx=0] positioned ~ ~-1 ~ run tag @s add headshot
$execute positioned ~ ~2 ~ if entity @s[tag=id14_mob,tag=!no_headshots] unless entity @s[tag=!$(id)_$(character)_$(type)_raycast_hit,dx=0] positioned ~ ~-2.1 ~ run tag @s add headshot
execute if entity @s[tag=all_headshots] run tag @s add headshot

#send result back
$execute unless entity @s[tag=$(id)_$(character)_$(type)_raycast_hit] at @s run function main:$(folder_location)/hit {"character":"$(character)"}

$execute if entity @s[tag=!$(id)_$(character)_$(type)_raycast_hit,tag=!ally] run function main:mechanics/raycast/pierce
execute unless score .pierce raycast matches 1.. run scoreboard players set .distance raycast 9999

$tag @s add $(id)_$(character)_$(type)_raycast_hit