scoreboard players remove @s minigun_ammo 1
item modify entity @s weapon.mainhand pctf:minigun

execute store result storage pctf:angle input.x int 1 run random value -4..4
execute store result storage pctf:angle input.y int 1 run random value -4..4

tag @s add raycaster
execute anchored eyes run function pctf:logic/items/minigun/start_raycast with storage pctf:angle input
tag @s remove raycaster

playsound minecraft:block.iron_trapdoor.open player @a ~ ~ ~ 1 2
playsound minecraft:entity.firework_rocket.blast player @a ~ ~ ~ 2 1.5
execute if score @s minigun_ammo matches ..30 run playsound minecraft:ui.button.click player @a ~ ~ ~ 1 1.5

scoreboard players set @s item_cooldown 1

execute if score @s minigun_ammo matches 0 run function pctf:logic/items/minigun/break