# © Spark Universe, 2023
# authors: destruc7i0n
# description: part 1 loop, run as the player
# called by: ../loop

scoreboard players add @s[scores={tut_timer=..300}] tut_timer 1
scoreboard players add @s[scores={tut_timer=400..}] tut_timer 1

execute if score @s tut_timer matches 1 run title @p[tag=instance_player] actionbar hud:loading
execute if score @s tut_timer matches 110 run playsound spark.zombies2.gamestate.show_logo @p[tag=instance_player]
execute if score @s tut_timer matches 1..240 run tp @p[tag=instance_player] ~ ~ ~ 0 0

# clear title
execute if score @s tut_timer matches 260 run title @p[tag=instance_player] title §2
execute if score @s tut_timer matches 260 run playsound spark.zombies2.tutorial.start @p[tag=instance_player]
execute if score @s tut_timer matches 260 run music play spark.zombies2.tutorial.music 1.0 0.0 loop

# spawn and tag zombies
execute if score @s tut_timer matches 300 run function spark/tutorial/p1/spawn_zombies
execute if score @s tut_timer matches 300 run scoreboard players set @p[tag=instance_player] SS_ui_tutorial 1
# execute if score @s tut_timer matches 300 run playsound mob.villager.haggle @p[tag=instance_player]

# check if zombies are dead
execute if score @s tut_timer matches 301 if score .target_count tut matches 0 run scoreboard players set @s tut_timer 400
execute if score @s tut_timer matches 400 run clear @p[tag=instance_player] spark:baseball_bat
execute if score @s tut_timer matches 400 run scoreboard players set @p[tag=instance_player] SS_ui_tutorial 0
execute if score @s tut_timer matches 400 run playsound spark.zombies2.tutorial.success_minor @p[tag=instance_player]

execute if score @s tut_timer matches 440 run function spark/tutorial/p1/next
