scoreboard players add @s[scores={jjc_r3=..0}] jjc_707 1
execute as @s at @s unless score @s jjc_r1 matches 0..1000 run tag @s add jjc_reward_r
tag @s[scores={jjc_r3=..0,jjc_707=200..}] add jjc_reward_r

execute as @e[type=item,tag=jjc_reward0] at @s store result score @s jjc_x1 run data get entity @s Pos[0] 1000
execute as @e[type=item,tag=jjc_reward0] at @s store result score @s jjc_z1 run data get entity @s Pos[2] 1000
execute as @s at @s store result score @s jjc_x2 run data get entity @s Pos[0] 1000
execute as @s at @s store result score @s jjc_z2 run data get entity @s Pos[2] 1000
execute as @e[type=item,tag=jjc_reward0] at @s run scoreboard players operation @s jjc_x1 -= @n[distance=..200,tag=jjc_jjc,tag=jjc_reward] jjc_x2
execute as @e[type=item,tag=jjc_reward0] at @s run scoreboard players operation @s jjc_z1 -= @n[distance=..200,tag=jjc_jjc,tag=jjc_reward] jjc_z2
execute as @e[type=item,tag=jjc_reward0] at @s store result score @s jjc_random run random value -5000..5000
execute as @e[type=item,tag=jjc_reward0] at @s store result entity @s Motion[0] double -0.000025 run scoreboard players operation @s jjc_x1 += @s jjc_random
execute as @e[type=item,tag=jjc_reward0] at @s store result score @s jjc_random run random value -5000..5000
execute as @e[type=item,tag=jjc_reward0] at @s store result entity @s Motion[2] double -0.000025 run scoreboard players operation @s jjc_z1 += @s jjc_random
execute as @e[type=item,tag=jjc_reward0] at @s run data modify entity @s Motion[1] set value 1d
execute as @e[type=item,tag=jjc_reward0] at @s run tag @s remove jjc_reward0

execute as @s at @s run scoreboard players set @e[type=#colosseum_of_fools:guanzhong,tag=jjc_guanzhong,distance=..100] jjc_303 2
scoreboard players add @s jjc_r0 1
execute as @s[scores={jjc_r0=1}] at @s run fill ~-16 ~ ~-16 ~16 ~ ~16 air replace fire
execute as @s[scores={jjc_r0=1}] at @s run tp @e[type=#colosseum_of_fools:mob,tag=jjc_mob,distance=..100] ~ ~-1000 ~
execute as @s[scores={jjc_r0=1,jjc_ominous=1..}] at @s run scoreboard players operation @s jjc_r2 *= @s jjc_ominous
scoreboard players set @s[scores={jjc_r0=1}] jjc_r3 1
execute as @s[scores={jjc_r0=1}] at @s run scoreboard players operation @s jjc_r3 += @s jjc_ominous
execute as @s[scores={jjc_r0=1,jjc_ominous=1..}] at @s run scoreboard players operation @s jjc_r4 = @s jjc_ominous
execute as @s[scores={jjc_r3=1..}] at @s run summon item ^ ^9 ^16 {Tags:["jjc_reward0"],Item:{id:"stone",count:1}}
execute as @s[scores={jjc_r4=1..,jjc_r2=..0}] at @s run summon item ^ ^9 ^-16 {Tags:["jjc_reward0"],Item:{id:"stone",count:1}}
execute as @s[scores={jjc_r4=1..,jjc_r2=..0}] at @s positioned ^ ^9 ^-16 run loot replace entity @n[distance=..200,type=item,tag=jjc_reward0] container.0 loot colosseum_of_fools:reward/zejjc_ominous_unique
scoreboard players remove @s[scores={jjc_r3=1..,jjc_r2=..0}] jjc_r4 1
execute as @s[scores={jjc_r1=1..}] at @s run loot replace entity @n[distance=..200,type=item,tag=jjc_reward0] container.0 loot colosseum_of_fools:reward/zejjc_common
execute as @s[scores={jjc_r2=1..,jjc_r1=..0}] at @s run loot replace entity @n[distance=..200,type=item,tag=jjc_reward0] container.0 loot colosseum_of_fools:reward/zejjc_rare
execute as @s[scores={jjc_r3=1..,jjc_r2=..0}] at @s positioned ^ ^9 ^16 run loot replace entity @n[distance=..200,type=item,tag=jjc_reward0] container.0 loot colosseum_of_fools:reward/zejjc_unique

scoreboard players remove @s[scores={jjc_r3=1..,jjc_r2=..0}] jjc_r3 1
scoreboard players remove @s[scores={jjc_r2=1..,jjc_r1=..0}] jjc_r2 1
scoreboard players remove @s[scores={jjc_r1=1..}] jjc_r1 1
execute as @s at @s run tp @s ~ ~ ~ ~170 ~

tag @s[tag=jjc_reward_r,tag=!jjc_endless] add jjc_end
execute as @s[tag=jjc_reward_r] at @s run tag @e[type=armor_stand,tag=jjc_start,distance=..40] add jjc_start_load
execute as @s[tag=jjc_reward_r] at @s run tag @e[type=armor_stand,tag=jjc_start,distance=..40] add jjc_start_down
scoreboard players reset @s[tag=jjc_reward_r] jjc_707
scoreboard players reset @s[tag=jjc_reward_r] jjc_r0
tag @s[tag=jjc_reward_r] remove jjc_reward
tag @s[tag=jjc_reward_r] remove jjc_reward_r
schedule function colosseum_of_fools:e/start/tick 1t replace