# 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 drowned ~ ~ ~ {CustomName:'{"translate":"drowned_diver","color":"gold","italic":false}',CustomNameVisible:1,Health:210.00,Attributes:[{Name:"generic.max_health",Base:210.00},{Name:"generic.follow_range",Base:26.00},{Name:"generic.attack_damage",Base:6.20},{Name:"generic.movement_speed",Base:0.23}],HandItems:[{Unbreakable:1b,id:"slime_ball",Count:1,tag:{CustomModelData:7024}},{Unbreakable:1b,id:"slime_ball",Count:1,tag:{CustomModelData:7023}}],ArmorItems:[{Unbreakable:1b,id:"leather_boots",Count:1,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]}],display:{color:10186075}}},{id:"leather_leggings",Count:1,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]}],display:{color:13410661}}},{id:"leather_chestplate",Count:1,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]}],display:{color:15185517}}},{id:"slime_ball",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]}],CustomModelData:7022}}],ActiveEffects:[{Id:14b,Amplifier:1b,Duration:720000,ShowParticles:0b}],Passengers:[{id:'area_effect_cloud',CustomNameVisible:1b,Duration:2147483647,Tags:['unspellable','must_ride','iname','EB'],CustomName:'{"translate":"drowned_diver","color":"gold","italic":false}'}],Tags:['boss', 'drowned_diver', 'EB', 'init', 'water_speed_I', 'wm_inmune', '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 drowned ~ ~ ~ {CustomName:'{"translate":"drowned_diver","color":"gold","italic":false}',CustomNameVisible:1,Health:273.00,Attributes:[{Name:"generic.max_health",Base:273.00},{Name:"generic.follow_range",Base:28.60},{Name:"generic.attack_damage",Base:8.06},{Name:"generic.movement_speed",Base:0.23}],HandItems:[{Unbreakable:1b,id:"slime_ball",Count:1,tag:{CustomModelData:7024}},{Unbreakable:1b,id:"slime_ball",Count:1,tag:{CustomModelData:7023}}],ArmorItems:[{Unbreakable:1b,id:"leather_boots",Count:1,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]}],display:{color:10186075}}},{id:"leather_leggings",Count:1,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]}],display:{color:13410661}}},{id:"leather_chestplate",Count:1,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]}],display:{color:15185517}}},{id:"slime_ball",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]}],CustomModelData:7022}}],ActiveEffects:[{Id:14b,Amplifier:1b,Duration:720000,ShowParticles:0b}],Passengers:[{id:'area_effect_cloud',CustomNameVisible:1b,Duration:2147483647,Tags:['unspellable','must_ride','iname','EB'],CustomName:'{"translate":"drowned_diver","color":"gold","italic":false}'}],Tags:['boss', 'drowned_diver', 'EB', 'init', 'water_speed_I', 'wm_inmune', '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=drowned_diver,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=drowned_diver,tag=init,sort=nearest,limit=1] remove init