#TouhouDanmakufu[Stage]
#Title["Aunn Komano Boss Battle"]
#Text["Made this in 2 days[r]after the release of TH16.[r]Difficulty: DOGE"]
#ScriptVersion[3]
//#System["./default_system/Default_SystemFullScreen.txt"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

@Initialize{
SetPlayerLife(3);
SetCommonData("IsStage", true);
STAGE;
BGM;
StageBackground;
}

@MainLoop{
yield;
}

@Finalize{}

task BGM{
	let obj	= ObjSound_Create();
	ObjSound_Load(obj,GetCurrentScriptDirectory ~ "Default_System/se/bgm.ogg");
	ObjSound_SetSoundDivision(obj,SOUND_BGM);
	ObjSound_SetVolumeRate(obj,100);
	ObjSound_SetLoopEnable(obj,true); 
	ObjSound_SetLoopTime(obj, 5.874, 60*2+12.177);
	ObjSound_Play(obj);
	
while(GetCommonData("musicswap",0) < 1){yield;}
let volume = ObjSound_GetVolumeRate(obj);
while(volume>0){
	volume--;
	ObjSound_SetVolumeRate(obj,volume);
	wait(2);
}

}

task STAGE{
    let obj=ObjEnemyBossScene_Create();
    ObjEnemyBossScene_Add(obj,0,GetCurrentScriptDirectory ~ "./NS1.txt");
	ObjEnemyBossScene_Add(obj,0,GetCurrentScriptDirectory ~ "./SP1.txt");
	ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "./NS2.txt");
	ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "./SP2.txt");
	ObjEnemyBossScene_Add(obj,2,GetCurrentScriptDirectory ~ "./NS3.txt");
	ObjEnemyBossScene_Add(obj,2,GetCurrentScriptDirectory ~ "./SP3.txt");
	ObjEnemyBossScene_Add(obj,3,GetCurrentScriptDirectory ~ "./SP4.txt");
	ObjEnemyBossScene_Add(obj,3,GetCurrentScriptDirectory ~ "./End.txt");
    ObjEnemyBossScene_LoadInThread(obj);
	ObjEnemyBossScene_Regist(obj);
	TimerCountdown(obj);
	DeathSoundLoop;
    while(!Obj_IsDeleted(obj)){
        yield;
    }
}

task DeathSoundLoop{
	loop{
	while(GetCommonData("deathsound",0) < 1){yield;}
	PlaySound(GetCurrentScriptDirectory ~ "default_system/se/death2.wav", 100);
	SetCommonData("deathsound",0);
	yield;
	}
}