execute unless score .start dialog matches 1.. as @s[tag=!classless,tag=!camera_spectate,tag=tutorial_finished] run function main:mechanics/combo/text_tick

execute as @s[scores={combo_timer=1..}] run scoreboard players remove @s combo_timer 1
execute as @s[scores={combo_reset=1..}] run scoreboard players remove @s combo_reset 1
execute as @s[scores={combo_timer=81..}] run scoreboard players set @s combo_timer 60
execute as @s[scores={combo=1601..}] run scoreboard players set @s combo 1600

#remove
execute as @s[scores={combo_timer=..0,combo=..0}] run function main:mechanics/combo/reset
execute as @s[tag=!rest,scores={combo_timer=..0,combo=1..}] if score .remove combo matches 0 run function main:mechanics/combo/decay
execute as @s[scores={combo_timer=..0,combo=1..}] if score .remove combo matches 1.. run scoreboard players remove .remove combo 1

#triggers
execute if score .hits combo matches 5.. run function main:mechanics/combo/actions/hits
execute if score .hits_midair combo matches 5.. run function main:mechanics/combo/actions/hits_midair
execute if score .hits_skills combo matches 3.. run function main:mechanics/combo/actions/hits_skills
execute if score .multihit combo matches 3.. run function main:mechanics/combo/actions/multihit
execute as @s if score .multihit_timer combo matches 1 run scoreboard players set .multihit combo 0
execute as @s if score .multihit_timer combo matches 1.. run scoreboard players remove .multihit_timer combo 1

execute as @s if score .multikill_timer combo matches 1.. run function main:mechanics/combo/actions/multikill
execute as @s if score .multikill_timer combo matches 1 run function main:mechanics/combo/actions/multikill_reset
execute as @s if score .multikill_timer combo matches 1.. run scoreboard players remove .multikill_timer combo 1

#cooldown
execute as @s if score .hits_cd combo matches 1.. run scoreboard players remove .hits_cd combo 1
execute as @s if score .hits_midair_cd combo matches 1.. run scoreboard players remove .hits_midair_cd combo 1
execute as @s if score .hits_skills_cd combo matches 1.. run scoreboard players remove .hits_skills_cd combo 1
execute as @s if score .kill_cd combo matches 1.. run scoreboard players remove .kill_cd combo 1
execute as @s if score .stunned_cd combo matches 1.. run scoreboard players remove .stunned_cd combo 1
execute as @s if score .effect_cd combo matches 1.. run scoreboard players remove .effect_cd combo 1
execute as @s if score .pierce_cd combo matches 1.. run scoreboard players remove .pierce_cd combo 1
execute as @s if score .airshot_cd combo matches 1.. run scoreboard players remove .airshot_cd combo 1
execute as @s if score .damage_cd combo matches 1.. run scoreboard players remove .damage_cd combo 1
execute as @s if score .multihit_cd combo matches 1.. run scoreboard players remove .multihit_cd combo 1
execute as @s if score .perfect_sheath_cd combo matches 1.. run scoreboard players remove .perfect_sheath_cd combo 1

# execute as @s[tag=assassin] run function main:mechanics/combo/actions/characters/assassin
# execute as @s[tag=gunner] run function main:mechanics/combo/actions/characters/gunner
# execute as @s[tag=knight] run function main:mechanics/combo/actions/characters/knight

execute if score .current combo matches 0 at @s run tag @s add combo_1
execute if score @s combo matches 1.. if score .current combo matches 1 at @s run function main:mechanics/combo/vfx/sound {"pitch":"0.9","level":1,"next":2}
execute if score @s combo matches 1.. if score .current combo matches 2 at @s run function main:mechanics/combo/vfx/sound {"pitch":"0.95","level":2,"next":3}
execute if score @s combo matches 1.. if score .current combo matches 3 at @s run function main:mechanics/combo/vfx/sound {"pitch":"1.0","level":3,"next":4}
execute if score @s combo matches 1.. if score .current combo matches 4 at @s run function main:mechanics/combo/vfx/sound {"pitch":"1.05","level":4,"next":5}
execute if score @s combo matches 1.. if score .current combo matches 5 at @s run function main:mechanics/combo/vfx/max

function main:mechanics/combo/check

execute as @s[scores={combo_vfx=1..}] run function main:mechanics/combo/vfx/screen_tick

execute as @s anchored eyes at @s positioned ^1.5 ^ ^1.5 rotated ~ ~ as @e[type=text_display,tag=combo] run tp @s ~ ~ ~ ~ ~

execute if score .text_timer combo matches 1.. run scoreboard players remove .text_timer combo 1
execute if score .text_timer combo matches ..0 run function main:mechanics/combo/actions/remove

# execute as @e[type=text_display,tag=combo,scores={particle_lifetime=15}] run data merge entity @s {start_interpolation:0,interpolation_duration:10,transformation:[-0.1000f,0.0000f,-0.0000f,0.0000f,0.0000f,0.1000f,0.0000f,2.6875f,0.0000f,0.0000f,-0.1000f,0.0000f,0.0000f,0.0000f,0.0000f,1.0000f]}


# execute as @e[type=text_display,tag=combo] at @s run ride @s mount @e[type=text_display,tag=combo,limit=1,sort=furthest]