# Spawns boss rig
execute positioned ~ ~ ~ rotated ~ 0 run function animated_java:withered_knight/summon/default
# Animates boss
execute as @e[tag=ssz_boss_rig,limit=1,distance=..10,type=item_display] run function animated_java:withered_knight/animations/walk/play

# Summons an AI entity
summon zombie ~ ~ ~ {Silent:1b,PersistenceRequired:1b,active_effects:[{id:"minecraft:invisibility",amplifier:1b,duration:1000000000,show_particles:0b}],Tags:["ssz_boss_ai","ai_knight"],Motion:[0.0d,0.3d,0.0d],ArmorItems:[{},{},{},{id:"minecraft:stick",count:1b,components:{"minecraft:custom_model_data":1000}}],Health:1024f,attributes:[{id:"minecraft:generic.max_health",base:1024},{id:"minecraft:generic.knockback_resistance",base:1.0},{id:"minecraft:generic.movement_speed",base:0.18},{id:"minecraft:generic.attack_damage",base:14.0},{id:"minecraft:generic.scale",base:1.5}],ArmorDropChances:[0.000F,0.000F,0.000F,0.000F],DeathLootTable:"ss:entities/empty"}
team join ssz_enemy @e[type=zombie,limit=1,tag=ssz_boss_ai]

execute as @e[type=minecraft:item_display,tag=aj.withered_knight.bone] run data modify entity @s Glowing set value 1b
execute as @e[type=minecraft:item_display,tag=aj.withered_knight.bone] run team join ssz_enemy @s

# Sets zombie boss health
scoreboard players set boss_health zombData 4000
scoreboard players set boss_attack_timer zombData 120

# Sets up boss bar
bossbar set zomb_boss name {"text":"Withered Knight","color":"#f0f04c"}
bossbar set zomb_boss visible true
bossbar set zomb_boss color red
bossbar set zomb_boss value 4000
bossbar set zomb_boss max 4000

tellraw @a[scores={location=3}] [{"text":"\n The","color":"gray"},{"text":" Withered Knight","color":"#f0f04c"},{"text":" has arrived!\n"}]

# Mansion kick
execute in ss:zombies run function ss:zomb/boss/mansion_kick