###Trigger attack if it's your turn###
tag @s[scores={nitHellAttacks=1..},tag=nitHellSite1] add nitAttackTrigger
tag @s[scores={nitHellAttacks=2..},tag=nitHellSite2] add nitAttackTrigger
tag @s[scores={nitHellAttacks=4..},tag=nitHellSite3] add nitAttackTrigger
tag @s[scores={nitHellAttacks=6..},tag=nitHellSite4] add nitAttackTrigger
tag @s[scores={nitHellAttacks=7..},tag=nitHellSite5] add nitAttackTrigger
tag @s[scores={nitHellAttacks=9..},tag=nitHellSite6] add nitAttackTrigger

###Confirm that it is actually your turn###
scoreboard players operation #nitID nitTemp = @s nitID
execute as @e[tag=nitHellSite,limit=6,sort=nearest] if score @s nitID = #nitID nitTemp run tag @s add nitID_match
execute if entity @e[tag=nitHellSite5,tag=nitID_match] run tag @s[tag=nitHellSite6] remove nitAttackTrigger
execute if entity @e[tag=nitHellSite4,tag=nitID_match] run tag @s[tag=nitHellSite5] remove nitAttackTrigger
execute if entity @e[tag=nitHellSite3,tag=nitID_match] run tag @s[tag=nitHellSite4] remove nitAttackTrigger
execute if entity @e[tag=nitHellSite2,tag=nitID_match] run tag @s[tag=nitHellSite3] remove nitAttackTrigger
execute if entity @e[tag=nitHellSite1,tag=nitID_match] run tag @s[tag=nitHellSite2] remove nitAttackTrigger
tag @e[tag=nitHellSite,tag=nitID_match] remove nitID_match


###Scout Portal on 1st structure###
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite1] run place template nitk:attacks/scout_portal ~-4 ~-1 ~-4
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite1] run tellraw @a[distance=..200] ["",{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"A Nether Portal has opened nearby!","color":"dark_red"},{"text":" Put out the Soul Fires to stop the Scouts from coming through!","color":"white"}]


###Double Portals on 2nd structure###
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite2] run place template nitk:attacks/dual_portal ~-6 ~-1 ~-7
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite2] run tellraw @a[distance=..200] ["",{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"Two Nether Portals have opened nearby!","color":"dark_red"},{"text":" Put out the Soul Fires to halt the Tyrant's Scouts!","color":"white"}]


###Sky Portals on 4th structure###
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite3] run execute at @e[tag=nitSite,distance=..140,limit=2,sort=random] run place template nitk:attacks/sky_portal ~-5 ~32 ~-9
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite3] run tellraw @a[distance=..200] ["",{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"Two Nether Portals have opened in the sky above your town!","color":"dark_red"},{"text":" Kill the Ghasts that guard them to thwart the attack!","color":"white"}]


###Dark Beacon on 6th structure###
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite4] run place template nitk:attacks/dark_beacon ~-9 ~-1 ~-9
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite4] run tellraw @a[distance=..200] ["",{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"A Dark Beacon has come through a large Nether Portal!","color":"dark_red"},{"text":" Close the portal and destroy the Tyrant's Beacon!","color":"white"}]


###Grand Sky Portals on 7th structure###
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite5] at @e[tag=nitSite,distance=..140,limit=2,sort=random] run place template nitk:attacks/sky_portal ~-5 ~32 ~-9
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite5] at @e[tag=nitSite,distance=..140,limit=1,sort=random] run place template nitk:attacks/sky_portal_big ~-5 ~32 ~-9
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite5] run tellraw @a[distance=..200] ["",{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"Three Nether Portals have opened over your town!","color":"dark_red"},{"text":" Kill the Ghasts that guards them and defend the town!","color":"white"}]


###Tyrant Arena on 9th structure###
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite6] run place template nitk:attacks/tyrant_arena ~-12 ~-11 ~-12
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite6] run tellraw @a[distance=..200] ["",{"text":"[۩]","color":"green","bold":true},{"text":": ","color":"white","bold":false},{"text":"The Tyrant has sent an arena of Nether Portals!","color":"dark_red"},{"text":" He is preparing to enter the Overworld himself! Close the portals and push back his forces!","color":"white"}]


###Remove entity###
execute if entity @s[tag=nitAttackTrigger,tag=!nitHellSite3,tag=!nitHellSite5] run summon minecraft:lightning_bolt ~ ~ ~
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite3] at @e[tag=nitTyrantSkyPortal,limit=1,sort=random] run summon minecraft:lightning_bolt ~ ~15 ~
execute if entity @s[tag=nitAttackTrigger,tag=nitHellSite5] at @e[tag=nitTyrantSkyPortal,limit=1,sort=random] run summon minecraft:lightning_bolt ~ ~15 ~
kill @s[tag=nitAttackTrigger]