# © Spark Universe, 2023
# authors: destruc7i0n
# description: done final stage
# called by: 

scoreboard players reset @s tut_timer
clear @p[tag=instance_player] spark:sweet

function spark/tutorial/p7/cleanup

# TODO: send to cutscene

# execute unless score .spawn_house triggers matches 1.. run fill -40 2 -28 -40 3 -28 barrier
tp @p[tag=instance_player] -53 2 -31 90 4
tp @e[tag=instance_pet] -53 2 -27
spawnpoint @p[tag=instance_player] -53 2 -31

effect @p[tag=instance_player] night_vision 0
function spark/player/book/setup
scoreboard players set @p[tag=instance_player] book_weapon 1
replaceitem entity @p[tag=instance_player] slot.hotbar 8 spark:weapon_book 1 0 {"minecraft:item_lock": { "mode": "lock_in_inventory" }} 
execute unless score .spawn_house triggers matches 1.. if score .house_sound triggers matches 1.. run scoreboard players set @p[tag=instance_player] SS_ui_task 1
execute if score .spawn_house triggers matches 1.. run replaceitem entity @p[tag=instance_player] slot.hotbar 0 spark:frying_pan 1 0 {"minecraft:item_lock":{"mode":"lock_in_inventory"}}
execute if score .spawn_house triggers matches 1.. run tp @p[tag=instance_player] @p[tag=!in_tutorial,tag=!current_instance]

# execute as @p[tag=instance_player] at @s run playsound spark.zombies2.gamestate.start_gameplay @s
tag @p[tag=instance_player] remove in_tutorial

execute unless score .spawn_house triggers matches 1.. if entity @p[tag=in_tutorial] as @p[tag=instance_player] run scoreboard players set @s SS_ui_tutorial 9
execute unless score .spawn_house triggers matches 1.. run scoreboard players set .house_door triggers 0
execute unless score .spawn_house triggers matches 1.. unless entity @p[tag=in_tutorial] as @p[tag=instance_player] run scoreboard players set @a SS_ui_tutorial 0