particle electric_spark ^ ^ ^-.25 .1 .1 .1 0 2 force
particle electric_spark ^ ^ ^ .1 .1 .1 0 2 force
particle electric_spark ^ ^ ^.25 .1 .1 .1 0 2 force
execute if block ~ ~ ~ lightning_rod run summon lightning_bolt
tag @s add chainlight
execute as @e[dx=0,type=!#survivalplus:notalive,tag=!chainlight] positioned ~-0.99 ~-0.99 ~-0.99 if entity @s[dx=0] run damage @s 5 minecraft:lightning_bolt

execute if entity @e[dx=0,type=!#survivalplus:notalive,nbt=!{HurtTime:0s},tag=!chainlight] run tag @s add hittarget
execute if entity @s[tag=!hittarget,distance=..6] if block ~ ~ ~ #survivalplus:nobounce positioned ^ ^ ^.5 run function survivalplus:tools/dealdmg/chainlightning
tag @s remove hittarget
execute as @n[type=!#survivalplus:notalive,tag=!chainlight,distance=..6] at @s run function survivalplus:tools/dealdmg/chainattack