#TouhouDanmakufu[Stage]
#Title["RE: Kana & Ellen Script: Ellen"]
#Text["Difficulty: Warm"]
#ScriptVersion[3]
//#System["./default_system/Default_SystemFullScreen.txt"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"

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

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

@Finalize{}


task BGM{
	SongName(0);
	let obj	= ObjSound_Create();
	ObjSound_Load(obj,GetCurrentScriptDirectory ~ "Default_System/se/bgm1.ogg");
	ObjSound_SetSoundDivision(obj,SOUND_BGM);
	ObjSound_SetVolumeRate(obj,255);
	ObjSound_SetLoopEnable(obj,true);
	ObjSound_SetLoopTime(obj, 11.711, 60+48.957);
	ObjSound_Play(obj);

}

task STAGE{
	let obj=ObjEnemyBossScene_Create();
	
    ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "./ENS1.txt");
	ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "./ESP1.txt");
	ObjEnemyBossScene_Add(obj,2,GetCurrentScriptDirectory ~ "./ENS2.txt");
	ObjEnemyBossScene_Add(obj,2,GetCurrentScriptDirectory ~ "./ESP2.txt");
	ObjEnemyBossScene_Add(obj,3,GetCurrentScriptDirectory ~ "./ENS3.txt");
	ObjEnemyBossScene_Add(obj,3,GetCurrentScriptDirectory ~ "./ESP3.txt");
	ObjEnemyBossScene_Add(obj,4,GetCurrentScriptDirectory ~ "./ENS4.txt");
	ObjEnemyBossScene_Add(obj,4,GetCurrentScriptDirectory ~ "./ESP4.txt");
	ObjEnemyBossScene_Add(obj,5,GetCurrentScriptDirectory ~ "./ENS5.txt");
	ObjEnemyBossScene_Add(obj,5,GetCurrentScriptDirectory ~ "./ESP5.txt");
	ObjEnemyBossScene_Add(obj,6,GetCurrentScriptDirectory ~ "./ENS6.txt");
	ObjEnemyBossScene_Add(obj,6,GetCurrentScriptDirectory ~ "./ESP6.txt");
	ObjEnemyBossScene_Add(obj,7,GetCurrentScriptDirectory ~ "./ENS7.txt");
	ObjEnemyBossScene_Add(obj,7,GetCurrentScriptDirectory ~ "./ESP7.txt");
	ObjEnemyBossScene_Add(obj,8,GetCurrentScriptDirectory ~ "./ESP8.txt");
    ObjEnemyBossScene_LoadInThread(obj);
	
	TimerCountdown(obj);
	EllenIsDed;
	ObjEnemyBossScene_Regist(obj);
	
    while(!Obj_IsDeleted(obj)){
        yield;
    }
	
	wait(60*4);
	CloseStgScene;
}

task EllenIsDed{
	loop{
	while(GetCommonData("EllenIsDed",0) < 1){yield;}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/death.wav", 90);
	loop(120){ExplodeEffectT(GetCommonData("BossX", 0), GetCommonData("BossY", 0), rand(0.5, 10), 0.6, "Cherry", [255, 10, 10], 4);}
	ascent(i in 0..6){ExplodeCircleT(GetCommonData("BossX", 0), GetCommonData("BossY", 0), 60, i*12, 0);}
	SetCommonData("EllenIsDed",0);
	yield;
	}
}