execute if entity @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run schedule function kiwi2:upgrades/classes/magus/spells/tier_4/flashfreeze/flashfreeze_ground_user 20t

execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run summon marker ~ ~ ~ {Tags:["magus_flashfreeze_marker"]}

execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run particle snowflake ~ ~ ~ 6 1 6 0.2 200
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] if predicate kiwi2:chance_random_50 run playsound entity.breeze.whirl player @a[distance=..18] ~ ~ ~ 1 2
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] run playsound entity.player.hurt_freeze player @a[distance=..18] ~ ~ ~ 1 0
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=160..200}] run spreadplayers ~ ~ 0 4 false @e[type=marker, tag=magus_flashfreeze_marker]
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=120..159}] run spreadplayers ~ ~ 0 6 false @e[type=marker, tag=magus_flashfreeze_marker]
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=80..119}] run spreadplayers ~ ~ 0 8 false @e[type=marker, tag=magus_flashfreeze_marker]
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=40..79}] run spreadplayers ~ ~ 0 10 false @e[type=marker, tag=magus_flashfreeze_marker]
execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=..39}] run spreadplayers ~ ~ 0 12 false @e[type=marker, tag=magus_flashfreeze_marker]

execute at @e[type=marker,tag=magus_flashfreeze_marker] run setblock ~ ~-1 ~ ice
execute if predicate kiwi2:chance_random_40 at @e[type=marker,tag=magus_flashfreeze_marker] run setblock ~ ~-1 ~ packed_ice
execute if predicate kiwi2:chance_random_20 at @e[type=marker,tag=magus_flashfreeze_marker] run setblock ~ ~-1 ~ blue_ice

execute at @a[tag=magus_flashfreeze_ongoing,scores={magus_flashfreeze_timer=1..}] as @e[type=#enemy_mobs_only,distance=..12] at @s run function kiwi2:upgrades/classes/magus/spells/tier_4/flashfreeze/flashfreeze_enemy
execute as @a[scores={magus_flashfreeze_timer=1..}] run scoreboard players remove @s magus_flashfreeze_timer 20
execute as @a[scores={magus_flashfreeze_timer=1..}] run effect give @s slowness 2 3 true
execute as @a[scores={magus_flashfreeze_timer=0},tag=magus_flashfreeze_ongoing] run tag @s remove magus_flashfreeze_ongoing

kill @e[type=marker,tag=magus_flashfreeze_marker]