# $execute as @e[type=item_display,tag=$(id)_$(character)_$(type)_projectile_particle,tag=spin] run tp @s ~ ~ ~ ~ ~5
# $execute as @s[ at @s on passengers as @s[tag=spin] at @s run rotate @s ~10 ~
$scoreboard players set @s projectile_speed $(speed)
$scoreboard players operation @s projectile_speed *= @a[tag=$(character)] projectile_speed

$execute store result storage projectile $(id)_$(character)_$(type).speed float 0.001 run scoreboard players get @s projectile_speed

$execute at @s run particle $(particle_1) force
$execute at @s run particle $(particle_2) force
$execute at @s run playsound $(sound) master @a ~ ~ ~ 0.25 2

$execute if score .$(gravity) number matches 1 at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/start {"id":"$(id)","type":"$(type)","character":"$(character)","gravity":"$(gravity_strength)"}

$execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

$execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)

$execute if entity @s$(special)
$execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)

$execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
$execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


$execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

$execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)


$execute if entity @s$(special)
$execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)
$execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
$execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


$execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

$execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)


$execute if entity @s$(special)
$execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)
$execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
$execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


$execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

$execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)


# $execute if entity @s$(special)
# $execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)
# $execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
# $execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


# $execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

# $execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)

# $execute if entity @s$(special)
# $execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)
# $execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
# $execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


# $execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

# $execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)

# $execute if entity @s$(special)
# $execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)
# $execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
# $execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


# $execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

# $execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)

# $execute if entity @s$(special)
# $execute at @s positioned $(hitbox) if entity $(target)[type=#main:enemies,tag=enemy,tag=!fake,$(dx)] at @s run function main:mechanics/projectile/projectile_hit with storage projectile_data $(id)_$(character)_$(type)
# $execute at @s unless block $(block_dx) #main:raycast_pass run return run function main:$(folder_location)/block_hit
# $execute at @s if entity @e[type=shulker,distance=..1] run return run function main:$(folder_location)/block_hit


# $execute at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/gravity/apply with storage gravity $(id)_$(type)_$(character)

# $execute as @s[scores={projectile=1..},tag=!stop] at @s if block $(block_dx) #main:raycast_pass run function main:mechanics/projectile/flight with storage projectile $(id)_$(character)_$(type)