scoreboard players remove #distance raycast_time 1
execute if score #distance raycast_time matches ..264 run function pctf:logic/items/railgun/fx

execute positioned ~-0.2 ~-0.2 ~-0.2 as @a[dx=0.4,dy=0.4,dz=0.4,gamemode=!spectator,gamemode=!creative,sort=nearest,limit=1] unless score @s ctf_ID = @n[tag=raycaster] ctf_ID at @s run function pctf:logic/items/railgun/collide
execute positioned ~-0.2 ~-0.2 ~-0.2 as @n[type=!player,type=!#pctf:cannot_be_hit,dx=0.4,dy=0.4,dz=0.4] unless score @s ctf_ID = @n[tag=raycaster] ctf_ID at @s run function pctf:logic/items/railgun/collide

execute if score #distance raycast_time matches ..264 run scoreboard players add #fx raycast_time 1
execute if score #fx raycast_time matches 20 rotated ~ ~ run function pctf:logic/items/railgun/ring

execute if score #distance raycast_time matches 290 rotated ~ ~ run function pctf:logic/items/railgun/start_rings/1
execute if score #distance raycast_time matches 280 rotated ~ ~ run function pctf:logic/items/railgun/start_rings/2
execute if score #distance raycast_time matches 270 rotated ~ ~ run function pctf:logic/items/railgun/start_rings/3

execute if score #distance raycast_time matches 1.. positioned ^ ^ ^0.2 if block ~ ~ ~ #pctf:breakable_wools run function pctf:logic/items/railgun/destroy_block
execute if score #distance raycast_time matches 1.. positioned ^ ^ ^0.2 unless block ~ ~ ~ #pctf:projectile_pass run function pctf:logic/items/railgun/stop
execute if score #distance raycast_time matches 1.. positioned ^ ^ ^0.2 if block ~ ~ ~ #pctf:projectile_pass run function pctf:logic/items/railgun/loop_raycast