#reset when no entities are alive
execute unless entity @e[type=marker,tag=KyuFlareGun,tag=!KillMeNow] run execute unless entity @e[type=marker,tag=KyuFlareGunLight] run data merge block ~ ~ ~ {auto:0b}
scoreboard players add @e[type=marker,tag=KyuFlareGun,tag=!KillMeNow] KyuDummy 1
scoreboard players add @e[type=marker,tag=KyuFlareGunLight] KyuDummy 1

#move the entity, and place lights as it moves
execute as @e[type=marker,tag=KyuFlareGun,tag=!NoMove,tag=!DeadMarker] run function zzzzdonotuse:weapons/flaregun/flaregunmove

#after the entity hits a solid block, place a torch
execute as @e[type=marker,tag=KyuFlareGun,tag=!KillMeNow,tag=!DeadMarker] run scoreboard players set @s KyuDummy2 0
execute as @e[type=marker,tag=KyuFlareGun,tag=NoMove,tag=!DeadMarker] run execute at @s run function zzzzdonotuse:weapons/flaregun/placetorch

#remove the moving light blocks, kill entities after a set time alive
execute as @e[type=marker,tag=KyuFlareGun,scores={KyuDummy=15..}] run execute at @s run function zzzzdonotuse:weapons/flaregun/explode
execute as @e[type=marker,tag=KyuFlareGunLight,scores={KyuDummy=2..}] run execute at @s run fill ~ ~ ~ ~ ~ ~ air replace light
kill @e[type=marker,tag=KyuFlareGunLight,scores={KyuDummy=2..}] 

