# Find if it will be cursed (luck based)
execute if score summon_cursed EB_generic matches -1 run function 0_enemy_boss:is_summon_cursed

# Summon if not cursed
execute if score summon_cursed EB_generic matches 0 run summon skeleton ~ ~ ~ {CustomName:'{"translate":"zeldia_king","color":"gold","italic":false}',CustomNameVisible:1,Health:160.00,Attributes:[{Name:"generic.max_health",Base:160.00},{Name:"generic.follow_range",Base:26.00},{Name:"generic.attack_damage",Base:5.10},{Name:"generic.movement_speed",Base:0.23}],HandItems:[{Unbreakable:1b,id:diamond_sword,Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{Unbreakable:1b,id:"shield",Count:1b,tag:{BlockEntityTag:{Patterns:[{Color:3,Pattern:"sc"},{Color:11,Pattern:"mc"},{Color:11,Pattern:"flo"},{Color:4,Pattern:"flo"}]}}}],ArmorItems:[{Unbreakable:1b,id:"iron_boots",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.armor",Name:"generic.armor",Amount:0,Operation:0,UUID:[I;1,1,1,1]},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{id:"iron_leggings",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.armor",Name:"generic.armor",Amount:0,Operation:0,UUID:[I;1,1,1,1]},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{id:"golden_chestplate",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.armor",Name:"generic.armor",Amount:0,Operation:0,UUID:[I;1,1,1,1]},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{id:"player_head",Count:1b,tag:{SkullOwner:{Id:[I;1002,1002,1002,1002],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTNhMzI5OTk2ODMyN2YwNWQ1Y2ZlN2NjNDMxNDk2MGFjNTYzNjZlYWVhMTg4Mzc0OWNmN2E3MzI4YTE3MCJ9fX0="}]}}}}],Tags:['boss', 'zeldia_king', 'EB', 'init', 'zeldian', 'custom_attack'],DeathLootTable:"mdd:drop_marker",HandDropChances:[0.0F,0.0F],ArmorDropChances:[0.0F,0.0F,0.0F,0.0F]}

# Summon if cursed
execute if score summon_cursed EB_generic matches 1 run summon skeleton ~ ~ ~ {CustomName:'{"translate":"zeldia_king","color":"gold","italic":false}',CustomNameVisible:1,Health:208.00,Attributes:[{Name:"generic.max_health",Base:208.00},{Name:"generic.follow_range",Base:28.60},{Name:"generic.attack_damage",Base:6.63},{Name:"generic.movement_speed",Base:0.23}],HandItems:[{Unbreakable:1b,id:diamond_sword,Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.attack_damage",Name:"generic.attack_damage",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{Unbreakable:1b,id:"shield",Count:1b,tag:{BlockEntityTag:{Patterns:[{Color:3,Pattern:"sc"},{Color:11,Pattern:"mc"},{Color:11,Pattern:"flo"},{Color:4,Pattern:"flo"}]}}}],ArmorItems:[{Unbreakable:1b,id:"iron_boots",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.armor",Name:"generic.armor",Amount:0,Operation:0,UUID:[I;1,1,1,1]},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{id:"iron_leggings",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.armor",Name:"generic.armor",Amount:0,Operation:0,UUID:[I;1,1,1,1]},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{id:"golden_chestplate",Count:1b,tag:{AttributeModifiers:[{AttributeName:"generic.armor",Name:"generic.armor",Amount:0,Operation:0,UUID:[I;1,1,1,1]},{AttributeName:"generic.armor_toughness",Name:"generic.armor_toughness",Amount:0,Operation:0,UUID:[I;1,1,1,1]}]}},{id:"player_head",Count:1b,tag:{SkullOwner:{Id:[I;1002,1002,1002,1002],Properties:{textures:[{Value:"eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvNTNhMzI5OTk2ODMyN2YwNWQ1Y2ZlN2NjNDMxNDk2MGFjNTYzNjZlYWVhMTg4Mzc0OWNmN2E3MzI4YTE3MCJ9fX0="}]}}}}],Tags:['boss', 'zeldia_king', 'EB', 'init', 'zeldian', 'cursed', 'custom_attack'],DeathLootTable:"mdd:drop_marker",HandDropChances:[0.0F,0.0F],ArmorDropChances:[0.0F,0.0F,0.0F,0.0F]}

# Mark if it's a boss spawn
execute if score boss_spawn EB_generic matches 1 run tag @e[tag=zeldia_king,tag=init,sort=nearest,limit=1] add boss_spawn

# Spawn count
execute if score spawn_count EB_generic matches 1 run scoreboard players add #bosses_spawned EB_generic 1

# Reset flags
scoreboard players set summon_cursed EB_generic -1
scoreboard players set boss_spawn EB_generic 0
scoreboard players set spawn_count EB_generic 1

# Custom commands
# Clear Init tag
tag @e[tag=zeldia_king,tag=init,sort=nearest,limit=1] remove init