#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#Title["Range Contest Entry: Momiji!!"]
#Text["Enjoy this little entry!"]

@Initialize
{
	StartScript(LoadScriptInThread(GetCurrentScriptDirectory ~ "BG.txt"));
	StartScript(LoadScriptInThread(GetCurrentScriptDirectory ~ "ManageBGM.txt"));
	TPlural();
	SetPlayerLife(100);
	SetCommonData("trigger",0);
}

@MainLoop
{
	yield;
}

task TPlural
{
	let obj = ObjEnemyBossScene_Create();
	ObjEnemyBossScene_Add(obj,0,GetCurrentScriptDirectory ~ "Nonspell1.txt");
	ObjEnemyBossScene_Add(obj,0,GetCurrentScriptDirectory ~ "Spell1.txt");
	ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "Nonspell2.txt");
	ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "Spell2.txt");
	ObjEnemyBossScene_LoadInThread(obj);
	ObjEnemyBossScene_Regist(obj);
	
	while(!Obj_IsDeleted(obj))
	{
		yield;
	}

	let obj2 = ObjEnemyBossScene_Create;
	if(GetPlayerLife>=96){
		ObjEnemyBossScene_Add(obj2,0,GetCurrentScriptDirectory ~ "Spell3_Yam.txt");
		SetCommonData("musicswap",1);
		SetCommonData("trigger",1);
	}
	else{
		ObjEnemyBossScene_Add(obj2,0,GetCurrentScriptDirectory ~ "Spell3_Uninteresting.txt");
	}
	
	ObjEnemyBossScene_LoadInThread(obj2);
	ObjEnemyBossScene_Regist(obj2);

	while(!Obj_IsDeleted(obj2)){yield;}

	loop(60*2){yield;}
	StartScript(LoadScriptInThread(GetCurrentScriptDirectory ~ "EndText.txt"));
	loop(60*8){yield;}

	CloseStgScene();
}