execute as @e[c=1] at @s run scriptevent attribute:check
scoreboard players random @e[scores={petID=0},type=!item,family=custom_mob] petID 0 10000

tag @e[family=custom_mob] remove rank:special
tag @e[family=custom_mob] remove rank:first
tag @e[family=custom_mob] remove rank:second
tag @e[family=custom_mob] remove rank:third
tag @e[family=custom_mob] remove rank:fourth
tag @e[family=custom_mob] remove rank:fifth
tag @e[family=custom_mob] remove rank:sixth
tag @e[family=custom_mob] remove rank:sixth

tag @e[family=custom_mob,scores={hunterRank=-1}] add rank:special
tag @e[family=custom_mob,scores={hunterRank=1}] add rank:first
tag @e[family=custom_mob,scores={hunterRank=2}] add rank:second
tag @e[family=custom_mob,scores={hunterRank=3}] add rank:third
tag @e[family=custom_mob,scores={hunterRank=4}] add rank:fourth
tag @e[family=custom_mob,scores={hunterRank=5}] add rank:fifth
tag @e[family=custom_mob,scores={hunterRank=6}] add rank:sixth
tag @e[family=custom_mob,scores={hunterRank=0}] add rank:sixth

event entity @e[family=custom_mob,scores={hunterRank=-1}] rank:special
event entity @e[family=custom_mob,scores={hunterRank=1}] rank:first
event entity @e[family=custom_mob,scores={hunterRank=2}] rank:second
event entity @e[family=custom_mob,scores={hunterRank=3}] rank:third
event entity @e[family=custom_mob,scores={hunterRank=4}] rank:fourth
event entity @e[family=custom_mob,scores={hunterRank=5}] rank:fifth
event entity @e[family=custom_mob,scores={hunterRank=6}] rank:sixth
event entity @e[family=custom_mob,scores={hunterRank=0}] rank:sixth

execute as @e[type=zombie,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=husk,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=drowned,tag=!filtered] at @s run function misc/zombietransform

execute as @e[type=skeleton,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=bogged,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=wither_skeleton,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=stray,tag=!filtered] at @s run function misc/zombietransform

execute as @e[type=iron_golem,tag=!filtered] at @s run function misc/zombietransform
tag @e[type=neutral:irongolem] add team:ally

execute as @e[type=ravager,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=pillager,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=vindicator,tag=!filtered] at @s run function misc/zombietransform
execute as @e[type=evocation_illager,tag=!filtered] at @s run function misc/zombietransform