#tp prisoners out of chunk range
execute @e[tag=controller,score_boss_min=9] ~ ~ ~ tp @e[tag=michael] 1309 4 -746
execute @e[tag=controller,score_boss_min=9] ~ ~ ~ tp @e[tag=dipper] 1307 4 -740
execute @e[tag=controller,score_boss_min=9] ~ ~ ~ tp @e[tag=toby] 1313 4 -742
execute @e[tag=controller,score_boss_min=9] ~ ~ ~ tp @e[tag=ethan] 1305 4 -743

#destroy cave, yes or no?
execute @e[tag=controller,score_cave_min=1,score_cave=1] ~ ~ ~ tellraw @a [{"text":"Wizard: ","color":"dark_purple","bold":"true"},{"text":"Good choice. If I go, the cave must go too...","color":"dark_purple","bold":"false"}]
execute @e[tag=controller,score_cave_min=1,score_cave=1] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000

execute @e[tag=controller,score_cave_min=2,score_cave=2] ~ ~ ~ tellraw @a [{"text":"Wizard: ","color":"dark_purple","bold":"true"},{"text":"Interesting choice... it's too bad that both buttons lead to the same conclusion...","color":"dark_purple","bold":"false"}]
execute @e[tag=controller,score_cave_min=2,score_cave=2] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000

execute @e[tag=controller,score_cave_min=1] ~ ~ ~ scoreboard players set @e[tag=controller] timer 1
execute @e[tag=controller,score_cave_min=1] ~ ~ ~ scoreboard players set @e[tag=controller] boss 9
execute @e[tag=controller,score_cave_min=1] ~ ~ ~ fill 1171 16 -881 1171 16 -883 air 0 destroy
execute @e[tag=controller,score_cave_min=1] ~ ~ ~ scoreboard teams option game seeFriendlyInvisibles false
execute @e[tag=controller,score_cave_min=1] ~ ~ ~ scoreboard players reset * cave

execute @e[tag=controller,score_boss_min=9,score_time_min=200] ~ ~ ~ effect @a[score_playing_min=1] invisibility 99999 255 true

#spectate1
execute @e[tag=controller,score_boss_min=9,score_time_min=200] ~ ~ ~ clear @a[score_playing_min=1] wooden_hoe

execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=200] ~ ~ ~ scoreboard players reset @a[score_playing_min=1] music

execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=500] ~ ~ ~ execute @e[tag=spectate1] ~ ~ ~ teleport @e[tag=p1] ~ ~ ~ -180 35
execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=500] ~ ~ ~ execute @e[tag=spectate1] ~ ~ ~ teleport @e[tag=p2] ~ ~ ~ -180 35
execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=500] ~ ~ ~ execute @e[tag=spectate1] ~ ~ ~ teleport @a[score_playing_min=1] ~ ~ ~ -180 35
execute @e[tag=controller,score_boss_min=9,score_time_min=300,score_time=300] ~ ~ ~ tellraw @a [{"text":"Cook: ","color":"light_purple","bold":"true"},{"text":"Oh no... what's happened...?","color":"light_purple","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=300,score_time=300] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=400,score_time=400] ~ ~ ~ tellraw @a [{"text":"Train Conductor: ","color":"blue","bold":"true"},{"text":"...","color":"blue","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=400,score_time=400] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=500] ~ ~ ~ execute @r[c=1,tag=specExplode,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ particle largeexplode ~ ~ ~ 1.5 0.5 1.5 0 20
execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=500] ~ ~ ~ execute @r[c=1,tag=specExplode,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ execute @a ~ ~ ~ playsound entity.generic.explode master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=200,score_time=500] ~ ~ ~ execute @r[c=1,tag=specExplode,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ scoreboard players reset @e[tag=specExplode] time

#spectate2
execute @e[tag=controller,score_boss_min=9,score_time_min=501,score_time=800] ~ ~ ~ execute @e[tag=spectate2] ~ ~ ~ teleport @e[tag=p1] ~ ~ ~ 37 17
execute @e[tag=controller,score_boss_min=9,score_time_min=501,score_time=800] ~ ~ ~ execute @e[tag=spectate2] ~ ~ ~ teleport @e[tag=p2] ~ ~ ~ 37 17
execute @e[tag=controller,score_boss_min=9,score_time_min=501,score_time=800] ~ ~ ~ execute @e[tag=spectate2] ~ ~ ~ teleport @a[score_playing_min=1] ~ ~ ~ 37 17
execute @e[tag=controller,score_boss_min=9,score_time_min=550,score_time=550] ~ ~ ~ tellraw @a [{"text":"Barry: ","color":"blue","bold":"true"},{"text":"Yo, what's going on?","color":"blue","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=550,score_time=550] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=650,score_time=650] ~ ~ ~ tellraw @a [{"text":"Hazel: ","color":"blue","bold":"true"},{"text":"I think the cave is collapsing.","color":"blue","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=650,score_time=650] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=501,score_time=800] ~ ~ ~ execute @r[c=1,tag=specExplode2,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ particle largeexplode ~ ~ ~ 1.5 0.5 1.5 0 20
execute @e[tag=controller,score_boss_min=9,score_time_min=501,score_time=800] ~ ~ ~ execute @r[c=1,tag=specExplode2,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ execute @a ~ ~ ~ playsound entity.generic.explode master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=501,score_time=800] ~ ~ ~ execute @r[c=1,tag=specExplode2,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ scoreboard players reset @e[tag=specExplode2] time

#spectate3
execute @e[tag=controller,score_boss_min=9,score_time_min=801,score_time=1100] ~ ~ ~ execute @e[tag=spectate3] ~ ~ ~ teleport @e[tag=p1] ~ ~ ~ 51 20
execute @e[tag=controller,score_boss_min=9,score_time_min=801,score_time=1100] ~ ~ ~ execute @e[tag=spectate3] ~ ~ ~ teleport @e[tag=p2] ~ ~ ~ 51 20
execute @e[tag=controller,score_boss_min=9,score_time_min=801,score_time=1100] ~ ~ ~ execute @e[tag=spectate3] ~ ~ ~ teleport @a[score_playing_min=1] ~ ~ ~ 51 20
execute @e[tag=controller,score_boss_min=9,score_time_min=850,score_time=850] ~ ~ ~ tellraw @a [{"text":"Nubby: ","color":"white","bold":"true"},{"text":"Hay.....","color":"white","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=850,score_time=850] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=950,score_time=950] ~ ~ ~ tellraw @a [{"text":"Nubby: ","color":"white","bold":"true"},{"text":"...I Nubby...","color":"white","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=950,score_time=950] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=801,score_time=1100] ~ ~ ~ execute @r[c=1,tag=specExplode3,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ particle largeexplode ~ ~ ~ 1.5 0.5 1.5 0 20
execute @e[tag=controller,score_boss_min=9,score_time_min=801,score_time=1100] ~ ~ ~ execute @r[c=1,tag=specExplode3,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ execute @a ~ ~ ~ playsound entity.generic.explode master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=801,score_time=1100] ~ ~ ~ execute @r[c=1,tag=specExplode3,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ scoreboard players reset @e[tag=specExplode3] time

#spectate4
execute @e[tag=controller,score_boss_min=9,score_time_min=1101,score_time=1400] ~ ~ ~ execute @e[tag=spectate4] ~ ~ ~ teleport @e[tag=p1] ~ ~ ~ -35 18
execute @e[tag=controller,score_boss_min=9,score_time_min=1101,score_time=1400] ~ ~ ~ execute @e[tag=spectate4] ~ ~ ~ teleport @e[tag=p2] ~ ~ ~ -35 18
execute @e[tag=controller,score_boss_min=9,score_time_min=1101,score_time=1400] ~ ~ ~ execute @e[tag=spectate4] ~ ~ ~ teleport @a[score_playing_min=1] ~ ~ ~ -35 18
execute @e[tag=controller,score_boss_min=9,score_time_min=1150,score_time=1150] ~ ~ ~ tellraw @a [{"text":"Dipper: ","color":"gold","bold":"true"},{"text":"Oh no... it's finally happened...","color":"gold","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=1150,score_time=1150] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=1250,score_time=1250] ~ ~ ~ tellraw @a [{"text":"Toby: ","color":"gold","bold":"true"},{"text":"Looks like it...","color":"gold","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=1250,score_time=1250] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=1101,score_time=1400] ~ ~ ~ execute @r[c=1,tag=specExplode4,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ particle largeexplode ~ ~ ~ 1.5 0.5 1.5 0 20
execute @e[tag=controller,score_boss_min=9,score_time_min=1101,score_time=1400] ~ ~ ~ execute @r[c=1,tag=specExplode4,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ execute @a ~ ~ ~ playsound entity.generic.explode master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=1101,score_time=1400] ~ ~ ~ execute @r[c=1,tag=specExplode4,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ scoreboard players reset @e[tag=specExplode4] time

#spectate5
execute @e[tag=controller,score_boss_min=9,score_time_min=1401,score_time=1600] ~ ~ ~ execute @e[tag=spectate5] ~ ~ ~ teleport @e[tag=p1] ~ ~ ~ 90 15
execute @e[tag=controller,score_boss_min=9,score_time_min=1401,score_time=1600] ~ ~ ~ execute @e[tag=spectate5] ~ ~ ~ teleport @e[tag=p2] ~ ~ ~ 90 15
execute @e[tag=controller,score_boss_min=9,score_time_min=1401,score_time=1600] ~ ~ ~ execute @e[tag=spectate5] ~ ~ ~ teleport @a[score_playing_min=1] ~ ~ ~ 90 15
execute @e[tag=controller,score_boss_min=9,score_time_min=1500,score_time=1500] ~ ~ ~ tellraw @a [{"text":"Wizard: ","color":"dark_purple","bold":"true"},{"text":"...","color":"dark_purple","bold":"false"}]
execute @e[tag=controller,score_boss_min=9,score_time_min=1500,score_time=1500] ~ ~ ~ execute @a ~ ~ ~ playsound entity.chicken.egg master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=1401,score_time=1600] ~ ~ ~ execute @r[c=1,tag=specExplode5,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ particle largeexplode ~ ~ ~ 1.5 0.5 1.5 0 20
execute @e[tag=controller,score_boss_min=9,score_time_min=1401,score_time=1600] ~ ~ ~ execute @r[c=1,tag=specExplode5,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ execute @a ~ ~ ~ playsound entity.generic.explode master @p ~ ~ ~ 1000
execute @e[tag=controller,score_boss_min=9,score_time_min=1401,score_time=1600] ~ ~ ~ execute @r[c=1,tag=specExplode5,type=area_effect_cloud,score_time_min=20,score_time=20] ~ ~ ~ scoreboard players reset @e[tag=specExplode5] time

execute @e[tag=controller,score_boss_min=9,score_time_min=1600] ~ ~ ~ scoreboard players reset @a[score_playing_min=1] music
execute @e[tag=controller,score_boss_min=9,score_time_min=1600] ~ ~ ~ function always:creditstransition
execute @e[tag=controller,score_scene_min=17,score_boss_min=9,score_time_min=1599] ~ ~ ~ kill @e[tag=bossBattle]

#outro
execute @e[tag=controller,score_scene_min=18] ~ ~ ~ effect @a[score_playing_min=1] invisibility 99999 255 true

execute @e[tag=controller,score_scene_min=18,score_time_min=0,score_time=350] ~ ~ ~ tp @e[tag=p1] 1167 38 -781
execute @e[tag=controller,score_scene_min=18,score_time_min=0,score_time=350] ~ ~ ~ tp @e[tag=p2] 1165 38 -781
execute @e[tag=controller,score_scene_min=18,score_time_min=0,score_time=350] ~ ~ ~ tp @a[score_playing_min=1,score_playing=1] 1167 38 -781
execute @e[tag=controller,score_scene_min=18,score_time_min=0,score_time=350] ~ ~ ~ tp @a[score_playing_min=2,score_playing=2] 1165 38 -781
execute @e[tag=controller,score_scene_min=18,score_time_min=50,score_time=70] ~ ~ ~ execute @a ~ ~ ~ playsound entity.generic.explode master @p ~ ~ ~ 1000
execute @e[tag=controller,score_scene_min=18,score_time_min=50,score_time=70] ~ ~ ~ execute @a[score_playing_min=1] ~ ~ ~ particle largeexplode ~ ~ ~ 1.5 0.5 1.5 0 20

execute @e[tag=controller,score_scene_min=18,score_time_min=200,score_time=200] ~ ~ ~ execute @a ~ ~ ~ playsound effects.chapterintro master @p ~ ~ ~ 1000
execute @e[tag=controller,score_scene_min=18,score_time_min=200,score_time=200] ~ ~ ~ title @a title [{"text":"The Cave","color":"dark_gray","bold":"true","italic":"true"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=200,score_time=200] ~ ~ ~ title @a times 20 100 20

#credits
execute @e[tag=controller,score_scene_min=18,score_time_min=351] ~ ~ ~ tp @e[tag=p1] 1168 9 -761 -136 14
execute @e[tag=controller,score_scene_min=18,score_time_min=351] ~ ~ ~ tp @e[tag=p2] 1168 9 -761 -136 14
execute @e[tag=controller,score_scene_min=18,score_time_min=351] ~ ~ ~ tp @a[score_playing_min=1] 1168 9 -761 -136 14

execute @e[tag=controller,score_scene_min=18,score_time_min=351,score_time=351] ~ ~ ~ title @a title [{"text":"The End","color":"dark_gray"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=351,score_time=351] ~ ~ ~ title @a times 0 200 0
execute @e[tag=controller,score_scene_min=18,score_time_min=351,score_time=351] ~ ~ ~ execute @a ~ ~ ~ playsound entity.lightning.thunder master @p ~ ~ ~ 1000

execute @e[tag=controller,score_scene_min=18,score_time_min=552,score_time=552] ~ ~ ~ title @a title [{"text":"Created by","color":"gold"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=552,score_time=552] ~ ~ ~ title @a subtitle [{"text":"LetzTaco","color":"yellow"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=552,score_time=552] ~ ~ ~ title @a times 0 200 0
execute @e[tag=controller,score_scene_min=18,score_time_min=552,score_time=552] ~ ~ ~ execute @a ~ ~ ~ playsound entity.experience_orb.pickup master @p ~ ~ ~ 1000

execute @e[tag=controller,score_scene_min=18,score_time_min=753,score_time=753] ~ ~ ~ title @a title [{"text":"Youtube","color":"dark_red"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=753,score_time=753] ~ ~ ~ title @a subtitle [{"text":"LetzTaco","color":"white"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=753,score_time=753] ~ ~ ~ title @a times 0 200 0
execute @e[tag=controller,score_scene_min=18,score_time_min=753,score_time=753] ~ ~ ~ execute @a ~ ~ ~ playsound entity.experience_orb.pickup master @p ~ ~ ~ 1000

execute @e[tag=controller,score_scene_min=18,score_time_min=954,score_time=954] ~ ~ ~ title @a title [{"text":"Resources by","color":"dark_green"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=954,score_time=954] ~ ~ ~ title @a subtitle [{"text":"EliMe5","color":"green"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=954,score_time=954] ~ ~ ~ title @a times 0 200 0
execute @e[tag=controller,score_scene_min=18,score_time_min=954,score_time=954] ~ ~ ~ execute @a ~ ~ ~ playsound entity.experience_orb.pickup master @p ~ ~ ~ 1000

execute @e[tag=controller,score_scene_min=18,score_time_min=1155,score_time=1155] ~ ~ ~ title @a title [{"text":"Music by","color":"dark_blue"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=1155,score_time=1155] ~ ~ ~ title @a subtitle [{"text":"Craftmazter2000","color":"blue"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=1155,score_time=1155] ~ ~ ~ title @a times 0 200 0
execute @e[tag=controller,score_scene_min=18,score_time_min=1155,score_time=1155] ~ ~ ~ execute @a ~ ~ ~ playsound entity.experience_orb.pickup master @p ~ ~ ~ 1000

execute @e[tag=controller,score_scene_min=18,score_time_min=1356] ~ ~ ~ title @a title [{"text":"Thanks For Playing","color":"dark_gray"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=1356] ~ ~ ~ title @a subtitle [{"text":"The Cave","color":"gray"}]
execute @e[tag=controller,score_scene_min=18,score_time_min=1356,score_time=1356] ~ ~ ~ execute @a ~ ~ ~ playsound entity.experience_orb.pickup master @p ~ ~ ~ 1000
