execute as @e[type=wither_skeleton,tag=!plussed] run data merge entity @s {DeathLootTable:"survivalplus:entities/wither_skeleton"}

#execute unless entity @e[tag=witherskelmerchant] run execute as @e[type=wither_skeleton,predicate=survivalplus:2chance,tag=!plussed,limit=1] run data merge entity @s {CanPickUpLoot:0b,CustomName:{"text":"Wither Skeleton Merchant"},Tags:[merchant_face,rare,plussed,spawnmerchant,witherskelmerchant,withermerc,nopoly],equipment:{mainhand:{id:stone_pickaxe},feet:{id:diamond_boots},legs:{id:diamond_leggings},head:{id:iron_helmet}},drop_chances:{mainhand:0f,feet:0f,legs:0f,head:0f},DeathLootTable:"survivalplus:entities/merchant"}
#execute at @e[type=wither_skeleton,tag=spawnmerchant] run summon villager ~ ~ ~ {CustomName:"Wither Skeleton Merchant",VillagerData:{type:plains,profession:nitwit,level:99},Offers:{Recipes:[{maxUses:1,buy:{id:wither_skeleton_skull},sell:{id:stone_sword,components:{custom_data:{withersword:tag},damage:20,lore:[{"text":"Apply on Hit:","italic":false,"color":"light_purple"},{"text":"Wither II","italic":false,"color":"gray"}]}}},{buy:{id:quartz,count:8},sell:{id:blaze_powder,count:4}},{maxUses:16,buy:{id:quartz,count:16},sell:{id:gold_ingot,count:4}},{maxUses:2,buy:{id:quartz,count:26},sell:{id:wither_skeleton_skull}},{maxUses:16,buy:{id:quartz,count:5},sell:{id:ghast_tear}},{buy:{id:quartz,count:14},sell:{id:potion,components:{potion_contents:{potion:fire_resistance}}}},{maxUses:2,buy:{id:soul_soil,count:4},buyB:{id:nether_brick,count:4},sell:{id:wither_rose,count:4}},{maxUses:2,buy:{id:arrow,count:8},sell:{id:spectral_arrow,count:8}},{maxUses:10,buy:{id:quartz,count:20},sell:{id:barrel,components:{container_loot:{loot_table:"survivalplus:gameplay/crates/nether"},item_name:{"text":"Nether Crate","italic":false},enchantment_glint_override:1b}}}]},CustomName:{"text":"Wither Skeleton Merchant"},Invulnerable:1b,NoAI:1b,Silent:1b,Tags:[merchant,plussed,withermerchant,withermerc],Team:merchant,active_effects:[{id:invisibility,duration:-1,show_particles:0b}],equipment:{mainhand:{id:bundle}},drop_chances:{mainhand:0f}}
#execute as @e[tag=spawnmerchant,type=wither_skeleton] run tag @s remove spawnmerchant

execute if score hardmode hardmode matches 1 unless entity @e[tag=undead_king] run execute as @e[type=wither_skeleton,tag=!plussed,predicate=survivalplus:1chance,predicate=survivalplus:nether,limit=1] run data merge entity @s {CanPickUpLoot:0b,CustomName:{"text":"Undead King"},Health:100,PersistenceRequired:1b,Tags:[undead_king,boss,plussed,rare,upgradeable,nopoly,lowregen,special],equipment:{mainhand:{id:netherite_sword,components:{item_name:{"text":"Scorched Blade","italic":false},enchantments:{"survivalplus:beheading":1}}},feet:{id:netherite_boots,components:{trim:{pattern:rib,material:netherite},enchantments:{soul_speed:1}}},legs:{id:netherite_leggings,components:{trim:{pattern:rib,material:netherite},enchantments:{projectile_protection:3}}},chest:{id:netherite_chestplate,components:{trim:{pattern:silence,material:netherite},enchantments:{protection:2}}},head:{id:netherite_helmet,components:{trim:{pattern:rib,material:netherite}}}},drop_chances:{mainhand:1,feet:0f,legs:0f,chest:0f,head:0f},attributes:[{id:"max_health",base:100f},{id:"knockback_resistance",base:0.1f},{id:"attack_damage",base:-1f},{id:"armor",base:-4f},{id:"armor_thoughness",base:-8f},{id:"movement_efficiency",base:1f}]}
execute as @e[type=wither_skeleton,tag=!plussed,predicate=survivalplus:25chance] run data merge entity @s {CanPickUpLoot:0b,CustomName:{"text":"Elite Fortress Guard"},Health:40,Tags:[plussed,upgradeable,elite],equipment:{mainhand:{id:diamond_sword},feet:{id:diamond_boots,components:{enchantments:{protection:1}}},legs:{id:diamond_leggings},chest:{id:diamond_chestplate,components:{enchantments:{blast_protection:2}}},head:{id:diamond_helmet,components:{enchantments:{projectile_protection:3}}}},drop_chances:{mainhand:0f,feet:0f,legs:0f,chest:0f,head:0f},attributes:[{id:"max_health",base:40f},{id:"movement_speed",base:0.265f},{id:"knockback_resistance",base:0.6f},{id:"attack_damage",base:-1.5f}]}
execute as @e[type=wither_skeleton,tag=!plussed,predicate=survivalplus:10chance] run data merge entity @s {CanPickUpLoot:0b,CustomName:{"text":"Fortress Archer"},Health:30,Tags:[plussed,witherarcher],equipment:{mainhand:{id:bow,components:{enchantments:{power:4}}},feet:{id:golden_boots},legs:{id:iron_leggings},chest:{id:golden_chestplate,components:{enchantments:{projectile_protection:4}}},head:{id:golden_helmet}},attributes:[{id:"max_health",base:30f},{id:"knockback_resistance",base:0.5f},{id:"armor_toughness",base:8f},{id:"movement_speed",base:0.265f}],drop_chances:{mainhand:0f,feet:0f,legs:0f,chest:0f,head:0f}}
execute as @e[type=wither_skeleton,tag=!plussed] run data merge entity @s {CanPickUpLoot:0b,CustomName:{"text":"Fortress Guard"},Health:30,attributes:[{id:"knockback_resistance",base:0.5f},{id:"movement_speed",base:0.265f},{id:"max_health",base:30f},{id:"attack_damage",base:-1.5f}],equipment:{mainhand:{id:iron_sword},feet:{id:iron_boots},legs:{id:iron_leggings},chest:{id:iron_chestplate},head:{id:iron_helmet}},drop_chances:{mainhand:0f,feet:0f,legs:0f,chest:0f,head:0f}}
execute as @e[type=wither_skeleton,tag=!plussed] run tag @s add plussed