execute store result score @s KyuDummy run data get entity @s Potion
execute store result score @s KyuDummy2 run data get entity @s custom_potion_effects
tag @s[scores={KyuDummy=1..}] add IsPotionArrow
tag @s[scores={KyuDummy2=1..}] add IsPotionArrow

execute as @s[tag=IsPotionArrow] run function zzzzdonotuse:randomevent/thunderstruck/potionarrowtags

execute at @s[tag=!IsPotionArrow] run summon armor_stand ~ ~ ~ {Tags:["LightningStandMove"],HandItems:[{},{}],Invisible:1b,Silent:1b,NoGravity:1,Marker:0b}
execute at @s run tag @e[type=skeleton,limit=1,sort=nearest,distance=..2] add TpToMe
execute at @s run tag @e[type=wither_skeleton,limit=1,sort=nearest,distance=..2] add TpToMe
execute at @s run tag @e[type=stray,limit=1,sort=nearest,distance=..2] add TpToMe
execute at @s run tag @e[type=pillager,limit=1,sort=nearest,distance=..2] add TpToMe
execute at @s run tag @e[tag=TpToMe,limit=1,sort=nearest,distance=..2] add ClosestMob

execute at @s run execute if entity @e[tag=ClosestMob,limit=1,sort=nearest,distance=..2,type=stray] run tag @e[type=armor_stand,limit=1,sort=nearest,distance=..2,tag=LightningStandMove,tag=!GotTeled] add LightningStandStray
execute at @s run execute if entity @e[tag=ClosestMob,limit=1,sort=nearest,distance=..2,type=skeleton] run tag @e[type=armor_stand,limit=1,sort=nearest,distance=..2,tag=LightningStandMove,tag=!GotTeled] add LightningStandSkeleton
execute at @s run execute if entity @e[tag=ClosestMob,limit=1,sort=nearest,distance=..2,type=wither_skeleton] run tag @e[type=armor_stand,limit=1,sort=nearest,distance=..2,tag=LightningStandMove,tag=!GotTeled] add LightningStandWitherSkeleton
execute at @s run execute if entity @e[tag=ClosestMob,limit=1,sort=nearest,distance=..2,type=pillager] run tag @e[type=armor_stand,limit=1,sort=nearest,distance=..2,tag=LightningStandMove,tag=!GotTeled] add LightningStandPillager


execute at @s run execute at @e[tag=TpToMe,limit=1,sort=nearest,distance=..2] run tp @e[type=armor_stand,limit=1,sort=nearest,distance=..2,tag=LightningStandMove,tag=!GotTeled] ~ ~1.25 ~ ~ ~-7.5
execute at @s run tag @e[type=armor_stand,limit=1,sort=nearest,distance=..2,tag=LightningStandMove,tag=!GotTeled] add GotTeled

execute at @s run tag @e[distance=..3] remove TpToMe
execute at @s run tag @e[distance=..3] remove ClosestMob

execute at @s run effect give @e[type=skeleton,distance=..4] fire_resistance 15 15
execute at @s run effect give @e[type=stray,distance=..4] fire_resistance 15 15
kill @s
