#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Minoriko-Plural"]

let music2 = ObjSound_Create;
@Initialize{
	TPlural();
	TMusic();}
@Event{
	alternative(GetEventType())
	case(EV_PAUSE_ENTER){
		if(GetCommonData("Music",0) != 0){
		ObjSound_SetRestartEnable(music2,true);
		ObjSound_Stop(music2);}}
	case(EV_PAUSE_LEAVE){
		if(GetCommonData("Music",0) != 0){
		ObjSound_Play(music2);
		ObjSound_SetRestartEnable(music2,false);}}}
@MainLoop{yield;}
@Finalize{}

task TPlural{
	let dir = GetCurrentScriptDirectory();
	let obj = ObjEnemyBossScene_Create();
	ObjEnemyBossScene_Add(obj, 0, dir ~ "./Minoriko_Dialog.txt");
	ObjEnemyBossScene_Add(obj, 0, dir ~ "./Minoriko_Nonspell_01.txt");
	ObjEnemyBossScene_Add(obj, 0, dir ~ "./Minoriko_Spell_01.txt");
	ObjEnemyBossScene_Add(obj, 1, dir ~ "./Minoriko_Nonspell_02.txt");
	ObjEnemyBossScene_Add(obj, 1, dir ~ "./Minoriko_Spell_02.txt");
	ObjEnemyBossScene_Add(obj, 2, dir ~ "./Minoriko_Nonspell_03.txt");
	ObjEnemyBossScene_Add(obj, 2, dir ~ "./Minoriko_Spell_03.txt");
	ObjEnemyBossScene_Add(obj, 3, dir ~ "./Minoriko_Nonspell_04.txt");
	ObjEnemyBossScene_Add(obj, 3, dir ~ "./Minoriko_Spell_04.txt");
	ObjEnemyBossScene_Add(obj, 4, dir ~ "./Minoriko_Nonspell_05.txt");
	ObjEnemyBossScene_Add(obj, 5, dir ~ "./Minoriko_Spell_05.txt");
	ObjEnemyBossScene_Add(obj, 5, dir ~ "./Minoriko_EndScene.txt");
	ObjEnemyBossScene_LoadInThread(obj);
		while(GetCommonData("Boss",0) == 0){yield;}
		DeleteCommonData("Boss");
	ObjEnemyBossScene_Regist(obj);
	while(!Obj_IsDeleted(obj)){yield;}
	CloseScript(GetOwnScriptID());}

task TMusic{
	ObjSound_Load(music2,GetCurrentScriptDirectory ~ "./../Music/boss.mp3");
	ObjSound_SetSoundDivision(music2, SOUND_BGM);
	ObjSound_SetVolumeRate(music2, 100);
	ObjSound_SetLoopTime(music2, 0, 230);
	ObjSound_SetLoopEnable(music2, true);
		while(GetCommonData("Music",0) == 0){yield;}
		DeleteCommonData("Music");
	ObjSound_Play(music2);
	while(GetCommonData("EndMusic",0) == 0){yield;}
	DeleteCommonData("EndMusic");
	loop(180){
		ObjSound_SetVolumeRate(music2,ObjSound_GetVolumeRate(music2)-100/180);
		yield;}}