#TouhouDanmakufu[Stage]
#Title["An uncomplete script"]
#Text["Lost motivation, here you go.[r]No music warning, grab a remix.[r]Difficulty: [r]ew"]
#ScriptVersion[3]
#System["./default_system/Default_System.txt"]

#include "./EverythingElse/Functions/Index.txt"
#include "./EverythingElse/Functions/BGStage.txt"
let objBoss; //Because errors.
let PlayX;
let PlayY;

@Initialize{
SetPlayerLife(3);
SetCommonData("fade",0);
SetCommonData("deathsound",0);//SET ALL OF THEM COMMON DATAS!!!!!
SetCommonData("musicswap",0);
SetCommonData("Downwards", 0);
SetCommonData("Fade", 0);
SetCommonData("Fade2", 0);
SetCommonData("Midboss", 0);
SetCommonData("Speedup", 0);
SetCommonData("Fade3", 0);
SetCommonData("IsStage", true);
STAGE;
}

@MainLoop{
if(GetPlayerState()==STATE_END){
	wait(120);
	CloseStgScene();
}

yield;
}

@Finalize{}

task DeathSoundLoop{
	loop{
	while(GetCommonData("deathsound",0) < 1){yield;}
	SE_Play(GetCurrentScriptDirectory ~ "EverythingElse/Functions/sfx/death2.wav", 100);
	SetCommonData("deathsound",0);
	yield;
	}
}

task DeathEffect{
	loop{
	while(GetCommonData("Died",0) < 1){yield;}
	loop(3){
	SpellBurstA1(GetCommonData("BossX", 1),GetCommonData("BossY", 1),"Cherry",[255,255,255]);
	SpellBurstB1(GetCommonData("BossX", 1),GetCommonData("BossY", 1),10,[255,255,255]);
	}
	yield;
	SE_Play(GetCurrentScriptDirectory ~ "EverythingElse/Functions/sfx/death.wav", 100);
	SetCommonData("Died",0);
	yield;
	}
}

task STAGE{
AddLives;
    let dir=GetCurrentScriptDirectory();
    let obj=ObjEnemyBossScene_Create();
	PlaytestInvincibility;
    ObjEnemyBossScene_Add(obj,0,dir~"./EverythingElse/NS1.txt");
	ObjEnemyBossScene_Add(obj,0,dir~"./EverythingElse/SP1.txt");
    ObjEnemyBossScene_Add(obj,1,dir~"./EverythingElse/NS2.txt");
	ObjEnemyBossScene_Add(obj,1,dir~"./EverythingElse/SP2.txt");
    ObjEnemyBossScene_Add(obj,2,dir~"./EverythingElse/NS3.txt");
	ObjEnemyBossScene_Add(obj,2,dir~"./EverythingElse/SP3.txt");
    ObjEnemyBossScene_Add(obj,3,dir~"./EverythingElse/NS4.txt");
	ObjEnemyBossScene_Add(obj,3,dir~"./EverythingElse/SP4.txt");
    ObjEnemyBossScene_Add(obj,4,dir~"./EverythingElse/NS5.txt");
	ObjEnemyBossScene_Add(obj,4,dir~"./EverythingElse/SP5.txt");
    ObjEnemyBossScene_Add(obj,5,dir~"./EverythingElse/NS6.txt");
	ObjEnemyBossScene_Add(obj,5,dir~"./EverythingElse/SP6.txt");
	ObjEnemyBossScene_Add(obj,6,dir~"./EverythingElse/NS7.txt");
	ObjEnemyBossScene_Add(obj,6,dir~"./EverythingElse/SP7.txt");
	ObjEnemyBossScene_Add(obj,7,dir~"./EverythingElse/NS8.txt");
	ObjEnemyBossScene_Add(obj,7,dir~"./EverythingElse/SP8.txt");
	ObjEnemyBossScene_Add(obj,8,dir~"./EverythingElse/SP9.txt");
    ObjEnemyBossScene_LoadInThread(obj);
	DeathSoundLoop;
	DeathEffect;
	
	wait(120);
	
ObjEnemyBossScene_Regist(obj);
	TimerCountdown(obj);
    while(!Obj_IsDeleted(obj)){
        yield;
    }
	SetCommonData("fade",1);
	SetCommonData("musicswap",2);
wait(350);
CloseStgScene;
}