# 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 zombie ~ ~ ~ {CustomName:'{"translate":"mandragora","color":"green","italic":false}',CustomNameVisible:1,IsBaby:True,Health:8.00,Attributes:[{Name:"generic.max_health",Base:8.00},{Name:"generic.follow_range",Base:5.00},{Name:"generic.attack_damage",Base:2.50},{Name:"generic.movement_speed",Base:0.13}],HandItems:[{Unbreakable:1b,id:"slime_ball",Count:1b,tag:{CustomModelData:7002}},{Unbreakable:1b,id:"slime_ball",Count:1b,tag:{CustomModelData:7002}}],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:12814375}}},{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:14260786}}},{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:12814375}}},{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:7001}}],Silent:1b,ActiveEffects:[{Id:14b,Amplifier:1b,Duration:720000,ShowParticles:0b}],Tags:['enemy', 'mandragora', 'EB', 'init', 'death_trigger', 'custom_attack', 'custom_sound'],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 zombie ~ ~ ~ {CustomName:'{"translate":"mandragora","color":"green","italic":false}',CustomNameVisible:1,IsBaby:True,Health:10.40,Attributes:[{Name:"generic.max_health",Base:10.40},{Name:"generic.follow_range",Base:5.50},{Name:"generic.attack_damage",Base:3.25},{Name:"generic.movement_speed",Base:0.13}],HandItems:[{Unbreakable:1b,id:"slime_ball",Count:1b,tag:{CustomModelData:7002}},{Unbreakable:1b,id:"slime_ball",Count:1b,tag:{CustomModelData:7002}}],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:12814375}}},{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:14260786}}},{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:12814375}}},{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:7001}}],Silent:1b,ActiveEffects:[{Id:14b,Amplifier:1b,Duration:720000,ShowParticles:0b}],Tags:['enemy', 'mandragora', 'EB', 'init', 'cursed', 'death_trigger', 'custom_attack', 'custom_sound'],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=mandragora,tag=init,sort=nearest,limit=1] add boss_spawn

# Spawn count
execute if score spawn_count EB_generic matches 1 run scoreboard players add #enemies_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

# Start sound cooldown
execute as @e[tag=mandragora,tag=init,sort=nearest,limit=1] run function 0_enemy_boss:sound_cooldown/spawn

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