###Prepare central entity and set bossbar stats###
tag @s add nitRaid
tag @s add nitRaidPiglin
bossbar add nitk:town_square_raid {"text":"Town Square Raid"}
bossbar set nitk:town_square_raid name {"text":"Piglin Posse Attack","color":"dark_red"}
bossbar set nitk:town_square_raid color red
bossbar set nitk:town_square_raid style notched_12
bossbar set nitk:town_square_raid visible true
bossbar set nitk:town_square_raid players @a[tag=nitCitizen,distance=..100]
scoreboard players add @s nitRaidProg 0
team add nitRaidMobs {"text":"Settlement Raid Mobs","color":"dark_red"}
team modify nitRaidMobs color dark_red

###Summon enemy mobs###
execute as @e[tag=nitSite,limit=24,sort=nearest,distance=..100] run summon piglin_brute ~ ~ ~ {IsImmuneToZombification:1b,Tags:[nitEntity,smithed.entity,smithed.strict,nitRaidMob],CustomName:'{"text":"Piglin Ruffian","color":"dark_red"}',Attributes:[{Name:"minecraft:generic.max_health",Base:30.0}],Health:30.0f,Team:"nitRaidMobs",ActiveEffects:[{Id:24,Duration:999999}],HandItems:[{id:"minecraft:golden_axe",Count:1b},{}],HandDropChances:[-1.0f,0.0f],PersistenceRequired:1b}
execute store result score @s nitRaidProg run execute if entity @e[tag=nitRaidMob,distance=..100]
execute store result bossbar nitk:town_square_raid max run scoreboard players get @s nitRaidProg
execute store result bossbar nitk:town_square_raid value run scoreboard players get @s nitRaidProg
spreadplayers ~ ~ 5 40 false @e[tag=nitRaidMob]