#東方弾幕風[Stage]
#Title[Revelation of Procella]
#Text[Normal Mode]
#Image[]
#BackGround[Default]
#Player[player\ProcellaPlayers\EmilyA\EmilyA.dnh, player\ProcellaPlayers\EmilyB\EmilyB.dnh, player\ProcellaPlayers\FeliciaA\FeliciaA.dnh, player\ProcellaPlayers\FeliciaB\FeliciaB.dnh]
#PlayLevel[Normal]
#ScriptVersion[2]

script_stage_main
{
	let cx=GetCenterX();
	let imgEnemy=GetCurrentScriptDirectory~"img\Enemy.png";//Enemy.pngへのパス
	let trig = 0;
	let frame = -240;
	let st1th = "bgm\Set Off ~ Rainbow Road.mp3";
	let st2th = "bgm\Flowing Water ~ White Water.mp3";
	let st3th = "bgm\Glory ~ Triumph Magus.mp3";
	let st4th = "bgm\Great Battle ~ Battle of the Heroes.mp3";
	let st6th = "bgm\Chokepoint ~ It All Comes Tumbling Down.mp3";
	#include_function "p_config.txt"
	function h {
		return GetCurrentScriptDirectory;
	}
	task StageTaskEX {
		function Wait(let f)
		{//待機関数
			loop(f){trig++; yield;}
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){trig++; yield;}
		}
		let trig = 0;
		SetCommonData("power", 0);
		Wait(120);
		Clear;
	}
	task StageTaskBR
	{
		function Wait(let frame)
		{
			loop(frame){yield};
		}
		function WaitForZeroEnemy()
		{
			while(GetEnemyNum() != 0){yield;}
		}	
		WaitForZeroEnemy;
		Wait(300);
		CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 1\nyokonormattack1.dnh",GetCenterX,0,0,0,0);
		WaitForZeroEnemy;
		Wait(300);
		CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 1\MoonbeamBossNormal.dnh",GetCenterX,0,0,0,0);
		WaitForZeroEnemy;
		Wait(300);
		CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 2\JohnMinibossNormal.dnh",GetCenterX,0,0,0,0);
		WaitForZeroEnemy;
		Wait(300);
		CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 2\AlexBossNormal.dnh",GetCenterX,0,0,0,0);
		WaitForZeroEnemy;
		Wait(300);
		if(GetPlayerScriptName == "FeliciaA" || GetPlayerScriptName == "FeliciaB") {
			CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 3F\VelonMinibossNormal.dnh", GetCenterX, 0, 0, 0, 0);
			WaitForZeroEnemy;
			Wait(300);
			CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 3F\CruzBossNormal.dnh",GetCenterX,0,0,0,0);
			WaitForZeroEnemy;
			Wait(300);
			CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 3F\EmilyMinibossNormal.dnh", GetCenterX, 0, 0, 0, 0);
			WaitForZeroEnemy;
			Wait(300);
			CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 4F\EmilyBossNormal.dnh",GetCenterX,0,0,0,0);
			WaitForZeroEnemy;
			Wait(300);
		}
		else {
			CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 3E\NyokoMinibossNormal.dnh", GetCenterX, 0, 0, 0, 0);
			WaitForZeroEnemy;
			Wait(300);
			CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 3E\JeaneBossNormal.dnh",GetCenterX,0,0,0,0);
			WaitForZeroEnemy;
			Wait(300);
			CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 4E\DendraMinibossNormal.dnh", GetCenterX, 0, 0, 0, 0);
			WaitForZeroEnemy;
			Wait(300);
			CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage 4E\FeliciaBossNormal.dnh",GetCenterX,0,0,0,0);
			WaitForZeroEnemy;
			Wait(300);
		}
		CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 5\selfdestruction.dnh", GetCenterX, 0, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(300);
		CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 5\DesdemonaBossNormal.dnh", GetCenterX, 0, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(300);
		CreateEnemyBossFromFile(GetCurrentScriptDirectory ~ "Stage 6\GennerBossNormal.dnh", GetCenterX, 0, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(300);
		Clear;
	}
	task StageTask1 {
		function Wait(let f)
		{//待機関数
			loop(f){trig++; yield;}
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){trig++; yield;}
		}
		let trig = 0;
		if(bgm_on) {
			LoadMusic(st1th);
			PlayMusic(st1th);
		}
		Wait(120);
		loop(9) {
			CreateEnemyFromFile(h ~ "e\e-downshooterh.dnh", GetClipMinX + 80, GetClipMinY, 0, 0, 0);
			Wait(20);
		}
		Wait(60);
		loop(9) {
			CreateEnemyFromFile(h ~ "e\e-downshooterh.dnh", GetClipMaxX - 80, GetClipMinY, 0, 0, 1);
			Wait(20);
		}
		Wait(60);
		loop(9) {
			CreateEnemyFromFile(h ~ "e\e-downshooterh.dnh", GetClipMinX + 80, GetClipMinY, 5, 90, 0);
			CreateEnemyFromFile(h ~ "e\e-downshooterh.dnh", GetClipMaxX - 80, GetClipMinY, 5, 90, 1);
			Wait(20);
		}
		Wait(240);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + (a - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, a);
			Wait(20);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + ((6 - a) - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, 6 - a);
			Wait(20);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + (a - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, a);
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + ((6 - a) - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, 6 - a);
			Wait(20);
		}
		WaitForZeroEnemy;
		Wait(180);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h ~ "Stage 1\nyokonormattack1.dnh", GetClipMinX, GetClipMinY, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(180);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetClipMinX, GetClipMinY + (a * 32) + 32, 3 + (6 - a) / 3.5, 0, a);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetClipMaxX, GetClipMinY + (a * 32) + 32, 3 + (6 - a) / 3.5, 180, a);
		}
		WaitForZeroEnemy;
		Wait(120);
		loop(24) {
			let randout = rand_int(0, 2);
			if(randout == 0) {
				CreateEnemyFromFile(h ~ "e\e-downshooter.dnh", GetClipMinX, GetClipMinY + 120 + sin(trig) * 60, 2 + cos(trig * -1), 0, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-shotless.dnh", GetClipMinX, GetClipMinY + 120 + sin(trig) * 60, 2 + cos(trig * -1), 0, 0);
			}
			randout = rand_int(0, 2);
			if(randout == 2) {
				CreateEnemyFromFile(h ~ "e\e-downshooter.dnh", GetClipMaxX, GetClipMinY + 120 + sin(trig * -1) * 60, 2 + cos(trig), 180, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-shotless.dnh", GetClipMaxX, GetClipMinY + 120 + sin(trig * -1) * 60, 2 + cos(trig), 180, 0);
			}
			Wait(30);
		}
		WaitForZeroEnemy;
		Wait(120);
		loop(36) {
			let randout = rand_int(0, 2);
			if(randout == 0) {
				CreateEnemyFromFile(h ~ "e\e-burstshotless.dnh", GetClipMinX, GetClipMinY + 120, 3 + cos(trig), trig%30, 0);
			}
			else if(randout == 1) {
				CreateEnemyFromFile(h ~ "e\e-burstshotless.dnh", GetClipMinX + 120, GetClipMinY, 3 + cos(trig), 75 + trig%30, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetClipMinX, GetClipMinY + 120, 3 + cos(trig), trig%30, trig%8);
			}
			randout = rand_int(0, 2);
			if(randout == 0) {
				CreateEnemyFromFile(h ~ "e\e-burstshotless.dnh", GetClipMaxX, GetClipMinY + 120, 2 + cos(trig), 180 - trig%30, 0);
			}
			else if(randout == 1) {
				CreateEnemyFromFile(h ~ "e\e-burstshotless.dnh", GetClipMaxX - 120, GetClipMinY, 3 + cos(trig), 75 + trig%30, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetClipMaxX, GetClipMinY + 120, 3 + cos(trig), 180 - trig%30, trig%8);
			}
			Wait(42);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + (a - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, a);
		}
		Wait(120);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + ((6 - a) - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, 6 - a);
		}
		Wait(150);
		ascent(a in 0..7) {
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + (a - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, a);
			CreateEnemyFromFile(h ~ "e\e-burstcircler1.dnh", GetCenterX + ((6 - a) - 3) * 50, GetClipMinY, 3 + a / 3.5, 90, 6 - a);
		}
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CollectItems;
		CreateEnemyBossFromFile(h ~ "Stage 1\MoonbeamBossNormal.dnh", GetClipMaxX, GetClipMinY, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(120);
		if(stage_select == 0) {
			StageTask2;
		}
		else {
			Clear;
		}
	}
	task StageTask2 {
		function Wait(let f)
		{//待機関数
			loop(f){yield};
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(bgm_on) {
			DeleteMusic(st1th);
			DeleteMusic("bgm\Sense and Sensibility ~ Lost Mind.mp3");
			LoadMusic(st2th);
			PlayMusic(st2th);
		}
		Wait(120);
		ascent(r in 0..12) {
			CreateEnemyFromFile(h ~ "e\e-sidewave.dnh", GetClipMinX + 100, GetClipMinY - 2, 0, 0, 0);
			CreateEnemyFromFile(h ~ "e\e-sidewave.dnh", GetClipMaxX - 100, GetClipMinY - 2, 0, 0, 1);
			Wait(10);
			CreateEnemyFromFile(h ~ "e\e-aimwave.dnh", GetClipMinX + 100, GetClipMinY - 2, 0, 0, 0);
			CreateEnemyFromFile(h ~ "e\e-aimwave.dnh", GetClipMaxX - 100, GetClipMinY - 2, 0, 0, 1);
			Wait(10);
		}
		Wait(180);
		ascent(r in 0..4) {
			if(r%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetClipMinX + 100 + cos(trig) * 50, GetClipMinY, 0, 0, r%2 + GetClipMinY + 150);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetClipMaxX - 100 + cos(trig) * 50, GetClipMinY, 0, 0, r%2 + GetClipMinY + 150);
			}
			WaitForZeroEnemy;
		}
		Wait(90);
		CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, GetClipMinY + 150);
		ascent(e in 0..10) {
			Wait(20);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMaxX - 100, GetClipMinY - 2, 0, 0, e%2);
		}
		WaitForZeroEnemy;
		Wait(120);
		CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, GetClipMinY + 150);
		ascent(e in 0..10) {
			Wait(20);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMinX + 100, GetClipMinY - 2, 0, 0, e%2);
		}
		WaitForZeroEnemy;
		Wait(120);
		CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetCenterX, GetClipMinY, 0, 0, GetClipMinY + 200);
		ascent(e in 0..10) {
			Wait(20);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMaxX - 100, GetClipMinY - 2, 0, 0, e%2);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMinX + 100, GetClipMinY - 2, 0, 0, e%2);
		}
		WaitForZeroEnemy;
		Wait(120);
		CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, GetClipMinY + 150);
		CreateEnemyFromFile(h ~ "e\e-bigwave.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, GetClipMinY + 150);
		Wait(360);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h ~ "Stage 2\meteor.dnh", GetClipMinX, GetClipMinY, 0, 0, 0);
		DeleteAllEnemyWithoutBoss;
		WaitForZeroEnemy;
		Wait(180);
		ascent(r in 0..30) {
			if(r%5 == 0) {
				if(r%2 == 0) {
					CreateEnemyFromFile(h ~ "e\e-bigwaveeasy.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, r%2 + GetClipMinY + 150);						}
				else {
					CreateEnemyFromFile(h ~ "e\e-bigwaveeasy.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, r%2 + GetClipMinY + 150);
				}
			}
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, 0);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, 1);
			Wait(45);
		}
		Wait(120);
		CreateEnemyFromFile(h ~ "e\e-seaweed.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, GetClipMinY + 150);
		ascent(i in 0..20) {
			Wait(5);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, 0);
		}
		WaitForZeroEnemy;
		Wait(60);
		CreateEnemyFromFile(h ~ "e\e-seaweed.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, GetClipMinY + 150);
		ascent(i in 0..20) {
			Wait(5);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, 0);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(i in 0..40) {
			Wait(5);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, 1);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(i in 0..40) {
			Wait(5);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, 1);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(i in 0..40) {
			Wait(5);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMaxX - 100, GetClipMinY, 0, 0, i%2);
			CreateEnemyFromFile(h ~ "e\e-crystalwave.dnh", GetClipMinX + 100, GetClipMinY, 0, 0, i%2);
		}
		WaitForZeroEnemy;
		Wait(120);
		ascent(r in 0..12) {
			CreateEnemyFromFile(h ~ "e\e-sidewave.dnh", GetClipMinX + 100, GetClipMinY - 2, 0, 0, 0);
			CreateEnemyFromFile(h ~ "e\e-sidewave.dnh", GetClipMaxX - 100, GetClipMinY - 2, 0, 0, 1);
			Wait(10);
			CreateEnemyFromFile(h ~ "e\e-aimwave.dnh", GetClipMinX + 100, GetClipMinY - 2, 0, 0, 0);
			CreateEnemyFromFile(h ~ "e\e-aimwave.dnh", GetClipMaxX - 100, GetClipMinY - 2, 0, 0, 1);
			Wait(10);
		}
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CollectItems;
		CreateEnemyBossFromFile(h ~ "Stage 2\AlexBossNormal.dnh", GetClipMaxX, GetClipMinY, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(120);
		if(stage_select == 0) {
			if(GetPlayerScriptName == "EmilyA.dnh" || GetPlayerScriptName == "EmilyB.dnh") {
				StageTask3E;
			}
			else {
				StageTask3F;
			}
		}
		else {
			Clear;
		}
	}
	task StageTask3E
	{
		function Wait(let f)
		{//待機関数
			loop(f){yield};
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(GetPlayerScriptName == "FeliciaA.dnh" || GetPlayerScriptName == "FeliciaB.dnh") {
			StageTask3F;
			return;
		}
		Wait(120);
		if(bgm_on) {
			DeleteMusic("bgm\White Whirlpool ~ Raging Sea.mp3");
			DeleteMusic(st2th);
			LoadMusic(st3th);
			PlayMusic(st3th);
		}
		CreateEnemyFromFile(h~"e\e-quadgrenadier.dnh", GetCenterX, GetClipMinY, 3, 90, 0);
		WaitForZeroEnemy;
		Wait(180);
		ascent(n in 0..12) {
			loop(6) {
				if(n%2 == 0) {
					CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMinX, GetClipMinY + 80 + n * 10, 3, 0, 1);
				}
				else {
					CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMaxX, GetClipMinY + 80 + n * 10, 3, 180, 7);
				}
				loop(8) { yield; }
			}
		}
		Wait(240);
		ascent(n in 0..12) {
			if(n%2 == 0) {
				CreateEnemyFromFile(h~"e\e-grenadier.dnh", GetClipMinX + 120, GetClipMinY, 2.5, 90, 0);
				CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMinX, GetClipMinY + 80 + n * 10, 3, 0, 1);
			}
			else {
				CreateEnemyFromFile(h~"e\e-grenadier.dnh", GetClipMaxX - 120, GetClipMinY, 2.5, 90, 0);
				CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMaxX, GetClipMinY + 80 + n * 10, 3, 180, 7);
			}
			loop(90) { yield; }
		}
		Wait(240);
		ascent(i in 0..10) {
			if(i%2 == 0) {
				CreateEnemyFromFile(h~"e\e-grenadier.dnh", GetClipMinX, GetClipMinY + 120 + i * 20, 2.5, 0, 0);
			}
			else {
				CreateEnemyFromFile(h~"e\e-grenadier.dnh", GetClipMaxX ,GetClipMinY + 120 + i * 20, 2.5, 180, 0);
			}
			loop(60) { yield; }
		}
		WaitForZeroEnemy;
		Wait(180);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h ~ "Stage 3E\NyokoMinibossNormal.dnh", GetClipMaxX, GetClipMinY + 120, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(180);
		CreateEnemyFromFile(h~"e\e-quadgrenadier.dnh", GetClipMinX + 110, GetClipMinY, 2.5, 90, 0);
		ascent(i in 0..12) {
			CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMaxX, GetClipMinY + 80 + i * 10, 3, 180, 7);
			loop(30) { yield; }
		}
		Wait(240);
		CreateEnemyFromFile(h~"e\e-quadgrenadier.dnh", GetClipMaxX - 110, GetClipMinY, 2.5, 90, 0);
		ascent(i in 0..12) {
			CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMinX, GetClipMinY + 80 + i * 10, 3, 0, 7);
			loop(30) { yield; }
		}
		Wait(240);
		CreateEnemyFromFile(h~"e\e-quadgrenadier.dnh", GetCenterX, GetClipMinY, 3, 90, 0);
		ascent(i in 0..6) {
			if(i%2 == 0) {
				CreateEnemyFromFile(h~"e\e-grenadier.dnh", GetClipMinX, GetClipMinY + 120 + i * 20, 2.5, 0, 0);
			}
			else {
				CreateEnemyFromFile(h~"e\e-grenadier.dnh", GetClipMaxX ,GetClipMinY + 120 + i * 20, 2.5, 180, 0);
			}
			loop(60) { yield; }
		}
		Wait(240);
		ascent(i in 0..3) {
			ascent(a in 0..2) {
				CreateEnemyFromFile(h~"e\e-burstripple.dnh", GetCenterX + (a%2 * 2 - 1) * 45 * i, GetClipMinY - 5, 2 + i, 90, 1);
			}
			Wait(60);
		}
		Wait(240);
		ascent(i in 0..3) {
			ascent(a in 0..2) {
				CreateEnemyFromFile(h~"e\e-burstripple.dnh", GetCenterX + (a%2 * 2 - 1) * 45 * i, GetClipMinY - 5, 2 + i, 90, 1);
			}
			Wait(60);
		}
		Wait(240);
		ascent(i in 0..12) {
			CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMinX, GetClipMinY + 80 + i * 10, 3, 0, 7);
			CreateEnemyFromFile(h~"e\e-downshooter3.dnh", GetClipMaxX, GetClipMinY + 80 + i * 10, 3, 180, 1);
			loop(30) { yield; }
		}
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CollectItems;
		CreateEnemyBossFromFile(h ~ "Stage 3E\JeaneBossNormal.dnh", GetClipMaxX, GetClipMinY + 120, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(240);
		if(stage_select == 0) {
			StageTask4E;
		}
		else {
			Clear;
		}
	}
	task StageTask3F
	{
		function Wait(let f)
		{//待機関数
			loop(f){yield};
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(GetPlayerScriptName == "EmilyA.dnh" || GetPlayerScriptName == "EmilyB.dnh") {
			StageTask3E;
			return;
		}
		if(bgm_on) {
			DeleteMusic("bgm\White Whirlpool ~ Raging Sea.mp3");
			DeleteMusic(st2th);
			LoadMusic(st3th);
			PlayMusic(st3th);
		}
		Wait(120);
		ascent(n in 0..20) {
			if(n%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-roperhl.dnh", GetClipMinX, GetClipMinY + 120, 0, 0, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-roperhr.dnh", GetClipMaxX, GetClipMinY + 120, 0, 0, 0);
			}
			loop(30 - n) { yield; }
		}
		WaitForZeroEnemy;
		Wait(180);
		ascent(n in 0..6) {
			if(n%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMinX + 100, GetClipMinY, 3, 100, 6);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMinX + 100, GetClipMaxY, 3, 260, 6);
			}
			Wait(90);
		}
		Wait(90);
		ascent(n in 0..6) {
			if(n%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMaxX - 100, GetClipMinY, 3, 80, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMaxX - 100, GetClipMaxY, 3, 280, 0);
			}
			Wait(90);
		}
		Wait(90);
		ascent(n in 0..6) {
			if(n%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMinX, GetClipMinY + 100, 3, -10, 0);
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMinX, GetClipMaxY - 100, 3, 10, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMaxX, GetClipMinY + 100, 3, 170, 6);
				CreateEnemyFromFile(h ~ "e\e-cranberrytrapper.dnh", GetClipMaxX, GetClipMaxY - 100, 3, 190, 6);
			}
			Wait(90);
		}
		Wait(90);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 3, 60, 1);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 3, 120, 0);
		Wait(90);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 4, 45, 1);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 4, 135, 0);
		Wait(90);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 3, 60, 1);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 3, 120, 0);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 4, 45, 1);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 4, 135, 0);
		WaitForZeroEnemy;
		Wait(180);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h ~ "Stage 3F\VelonMinibossNormal.dnh", GetClipMaxX, GetClipMinY + 120, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(180);
		ascent(n in 0..30) {
			ascent(o in 0..2) {
				if(n > 15) {
					if(o%2 == 0) {
						CreateEnemyFromFile(h ~ "e\e-cranberrytrappersmall.dnh", GetClipMaxX, GetClipMinY + 80, 2, 180, 5);
					}
					else {
						CreateEnemyFromFile(h ~ "e\e-cranberrytrappersmall.dnh", GetClipMinX, GetClipMinY + 80, 2, 0, 4);
					}
				}
				if(o%2 == 0) {
					CreateEnemyFromFile(h ~ "e\e-burstsoldier.dnh", GetClipMinX, GetClipMinY + 120, 4, 15 + n%4 * 5, 0);
				}
				else {
					CreateEnemyFromFile(h ~ "e\e-burstsoldier.dnh", GetClipMaxX, GetClipMinY + 120, 4, 165 - n%4 * 5, 0);
				}
				Wait(30);
			}
		}
		Wait(90);
		ascent(y in 0..5) {
			if(y%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-slasher.dnh", GetClipMinX, GetClipMinY + 40 + y * 40, 6, 0, 240 - y * 30);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-slasher.dnh", GetClipMaxX, GetClipMinY + 40 + y * 40, 6, 180, 240 - y * 30);
			}
			Wait(30);
		}
		Wait(120);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 3, 60, 0);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 3, 120, 1);
		Wait(90);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 5, 60, 0);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 5, 120, 1);
		Wait(90);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergac.dnh", GetClipMinX + 80, GetClipMinY, 4, 45, 0);
		CreateEnemyFromFile(h ~ "e\e-doubleexpandergacc.dnh", GetClipMaxX - 80, GetClipMinY, 4, 135, 1);
		WaitForZeroEnemy;
		Wait(120);
		ascent(n in 0..15) {
			if(n%2 == 0) {
				CreateEnemyFromFile(h ~ "e\e-roperhl.dnh", GetClipMinX, GetClipMinY + 180, 0, 0, 0);
			}
			else {
				CreateEnemyFromFile(h ~ "e\e-roperhr.dnh", GetClipMaxX, GetClipMinY + 180, 0, 0, 0);
			}
			Wait(30 - n);
		}
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CollectItems;
		CreateEnemyBossFromFile(h ~ "Stage 3F\CruzBossNormal.dnh", GetClipMaxX, GetClipMinY + 120, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(240);
		if(stage_select == 0) {
			StageTask4F;
		}
		else {
			Clear;
		}
	}
	task StageTask4E
	{
		function Wait(let f)
		{//待機関数
			loop(f){yield};
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(GetPlayerScriptName == "FeliciaA.dnh" || GetPlayerScriptName == "FeliciaB.dnh") {
			StageTask4F;
			return;
		}
		if(bgm_on) {
			DeleteMusic("bgm\Radiance ~ Brilliant Light.mp3");
			DeleteMusic(st3th);
			LoadMusic(st4th);
			PlayMusic(st4th);
		}
		Wait(120);
		loop(10) {
			Wait(12);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMinX - 5, GetClipMinY + 120, rand(4, 5), 0, 2);
		}
		Wait(180);
		loop(10) {
			Wait(12);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMaxX + 5, GetClipMinY + 120, rand(4, 5), 180, 2);
		}
		Wait(180);
		loop(10) {
			Wait(12);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMinX - 5, GetClipMinY, rand(4, 5), 30, 1);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMaxX + 5, GetClipMinY, rand(4, 5), 150, 1);
		}
		WaitForZeroEnemy;
		Wait(180);
		CreateEnemyFromFile(h~"e\e-leftfamiliar.dnh", GetClipMinX + 120, GetClipMinY - 5, 4, 90, 2);
		Wait(60);
		loop(5) {
			Wait(6);
			CreateEnemyFromFile(h~"e\e-faststreamer.dnh", GetClipMinX - 5, GetClipMinY + 80, 5, 0, 5);
		}
		Wait(300);
		CreateEnemyFromFile(h~"e\e-rightfamiliar.dnh", GetClipMaxX - 120, GetClipMinY - 5, 4, 90, 2);
		Wait(60);
		loop(5) {
			Wait(6);
			CreateEnemyFromFile(h~"e\e-faststreamer.dnh", GetClipMaxX + 5, GetClipMinY + 80, 5, 180, 5);
		}
		Wait(300);
		ascent(v in 0..3) {
			ascent(x in -2..3) {
				CreateEnemyFromFile(h~"e\e-burstshield.dnh", GetCenterX + x * 60, GetClipMinY - 5, 3 + v, 90, 7);
			}
			Wait(120);
			loop(10) {
				Wait(12);
				CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMinX - 5, GetClipMinY, rand(4, 5), 30, 1);
				CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMaxX + 5, GetClipMinY, rand(4, 5), 150, 1);
			}
			Wait(240);
		}
		ascent(x in -4..5) {
			CreateEnemyFromFile(h~"e\e-burstshield.dnh", GetCenterX + x * 42, GetClipMinY - 5, 3, 90, 7);
		}
		Wait(360);
		ascent(x in -2..3) {
			CreateEnemyFromFile(h~"e\e-burstshield.dnh", GetCenterX + x * 60, GetClipMinY - 5, 3, 90, 7);
		}
		Wait(120);
		CreateEnemyFromFile(h~"e\e-leftfamiliar.dnh", GetClipMinX + 120, GetClipMinY - 5, 2, 90, 2);
		CreateEnemyFromFile(h~"e\e-rightfamiliar.dnh", GetClipMaxX - 120, GetClipMinY - 5, 2, 90, 2);
		WaitForZeroEnemy;
		Wait(180);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h~"Stage 4E\DendraMinibossNormal.dnh",GetClipMinX,GetClipMinY,2,90,12);
		WaitForZeroEnemy;
		Wait(240);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMinX + 110, GetClipMinY - 5, 0, 0, 0);
		Wait(120);
		loop(10) {
			Wait(12);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMaxX + 5, GetClipMinY + 120, rand(4, 5), 180, 2);
		}
		Wait(240);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMaxX - 110, GetClipMinY - 5, 0, 0, 1);
		Wait(120);
		loop(10) {
			Wait(12);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMinX - 5, GetClipMinY + 120, rand(4, 5), 0, 2);
		}
		Wait(240);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMinX + 110, GetClipMinY - 5, 0, 0, 0);
		CreateEnemyFromFile(h~"e\e-leftfamiliar.dnh", GetClipMaxX - 110, GetClipMinY - 5, 3, 90, 2);
		Wait(360);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMaxX - 110, GetClipMinY - 5, 0, 0, 1);
		CreateEnemyFromFile(h~"e\e-rightfamiliar.dnh", GetClipMinX + 110, GetClipMinY - 5, 3, 90, 2);
		Wait(360);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMinX + 110, GetClipMinY - 5, 0, 0, 0);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMaxX - 110, GetClipMinY - 5, 0, 0, 1);
		Wait(120);
		loop(10) {
			Wait(12);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMinX - 5, GetClipMinY, rand(4, 5), 30, 2);
			CreateEnemyFromFile(h~"e\e-blockblaster.dnh", GetClipMaxX + 5, GetClipMinY, rand(4, 5), 150, 2);
		}
		Wait(300);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMinX + 110, GetClipMinY - 5, 0, 0, 0);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMaxX - 110, GetClipMinY - 5, 0, 0, 1);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetCenterX, GetClipMinY - 5, 0, 0, 0);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetCenterX, GetClipMinY - 5, 0, 0, 1);
		Wait(600);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMinX + 110, GetClipMinY - 5, 0, 0, 0);
		CreateEnemyFromFile(h~"e\e-laserspiral.dnh", GetClipMaxX - 110, GetClipMinY - 5, 0, 0, 1);
		CreateEnemyFromFile(h~"e\e-leftfamiliar.dnh", GetCenterX, GetClipMinY - 5, 2, 90, 2);
		CreateEnemyFromFile(h~"e\e-rightfamiliar.dnh", GetCenterX, GetClipMinY - 5, 2, 90, 2);
		WaitForZeroEnemy;
		Wait(180);
		CreateEnemyFromFile(h~"e\e-deathfairy4E.dnh", GetCenterX, GetClipMinY - 5, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h~"Stage 4E\FeliciaBossNormal.dnh",GetClipMinX,GetClipMinY,2,90,12);
		WaitForZeroEnemy;
		Wait(240);
		if(stage_select == 0) {
			StageTask5;
		}
		else {
			Clear;
		}
	}
	task StageTask4F
	{
		function Wait(let f)
		{//待機関数
			loop(f){yield};
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(GetPlayerScriptName == "EmilyA.dnh" || GetPlayerScriptName == "EmilyB.dnh") {
			StageTask4E;
			return;
		}
		if(bgm_on) {
			DeleteMusic(st3th);
			DeleteMusic("bgm\Dark Clouds ~ World of Darkness.mp3");
			LoadMusic(st4th);
			PlayMusic(st4th);
		}
		Wait(120);
		loop(2400) {
			trig += 1.82;
			frame++;
			if(frame%45 == 1) {
				CreateEnemyFromFile(h~"e\e-percussive.dnh",GetCenterX + cos(trig) * (GetCenterX - 40),GetClipMinY - 32 + sin(trig) * 32,2,90,8);
			}
			if(frame%60 == 1 && frame > 360) {
				CreateEnemyFromFile(h~"e\e-spew.dnh",GetCenterX + cos(trig * -1) * (GetCenterX - 40),GetClipMinY - 32 + sin(trig * -1) * 32,2,90,1);
			}
			if(frame%120 == 1 && frame > 1200) {
				CreateEnemyFromFile(h~"e\e-greenrounder.dnh",GetCenterX - 90,GetClipMinY,2,90,45);
				CreateEnemyFromFile(h~"e\e-greenrounder.dnh",GetCenterX + 90,GetClipMinY,2,90,-45);
			}
			yield;
		}
		WaitForZeroEnemy;
		Wait(180);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h~"Stage 4F\EmilyMinibossNormal.dnh",GetClipMinX,GetClipMinY,2,90,12);
		WaitForZeroEnemy;
		Wait(240);
		loop(1800) {
			trig += 1.82;
			frame++;
			if(frame%20 == 1) {
				CreateEnemyFromFile(h~"e\e-percussive.dnh",GetCenterX + cos(trig) * GetCenterX,GetClipMinY - 32 + sin(trig) * 32,2,90,12);
			}
			if(frame%135 == 1) {
				CreateEnemyFromFile(h~"e\e-amuleteer.dnh",GetCenterX, GetClipMinY, 3, 90, 12);
			}
			yield;
		}
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CreateEnemyBossFromFile(h~"Stage 4F\EmilyBossNormal.dnh",GetClipMinX,GetClipMinY,2,90,12);
		WaitForZeroEnemy;
		Wait(240);
		if(stage_select == 0) {
			StageTask5;
		}
		else {
			Clear;
		}
	}
	task StageTask5 {
		function Wait(let f)
		{//待機関数
			loop(f){yield;}
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(bgm_on) {
			DeleteMusic(st4th);
//			DeleteMusic("bgm\Lucky Star ~ The Odds.mp3");
//			LoadMusic(st5th);
//			PlayMusic(st5th);
		}
//		Wait(120);
		CreateEnemyBossFromFile(h ~ "Stage 5\selfdestruction.dnh", GetClipMaxX, GetClipMinY, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CollectItems;
		CreateEnemyBossFromFile(h ~ "Stage 5\DesdemonaBossNormal.dnh", GetClipMaxX, GetClipMinY, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(240);
		if(stage_select == 0) {
			StageTask6;
		}
		else {
			Clear;
		}
	}
	task StageTask6 {
		function Wait(let f)
		{//待機関数
			loop(f){yield;}
		}
		function WaitForZeroEnemy()
		{//敵数が0になるまで待機する関数
			while(GetEnemyNum() != 0){yield;}
		}
		if(bgm_on) {
			DeleteMusic("bgm\Temptation ~ Mind Poison.mp3");
			LoadMusic(st6th);
			PlayMusic(st6th);
		}
		Wait(120);
		ascent(i in 0..9) {
			CreateEnemyFromFile(h~"e\e-st6ripple.dnh", GetCenterX, GetClipMinY - 5, 2, 90, i);
			Wait(10);
		}
		Wait(180);
		CreateEnemyFromFile(h~"e\e-st6shield.dnh", GetClipMaxX, GetClipMinY + 120, 4, 180, 6);
		ascent(i in 0..9) {
			CreateEnemyFromFile(h~"e\e-st6ripple.dnh", GetClipMinX, GetClipMinY + 120, 4, i * 2.5, 30);
			Wait(10);
		}
		Wait(180);
		CreateEnemyFromFile(h~"e\e-st6shield.dnh", GetClipMinX, GetClipMinY + 120, 4, 0, 6);
		ascent(i in 0..9) {
			CreateEnemyFromFile(h~"e\e-st6ripple.dnh", GetClipMaxX, GetClipMinY + 120, 4, 180 - i * 2.5, 30);
			Wait(10);
		}
		Wait(240);
		CreateEnemyFromFile(h~"e\e-heavyfairym.dnh", GetClipMinX + 120, GetClipMinY - 5, 3, 90, 0);
		CreateEnemyFromFile(h~"e\e-heavyfairym.dnh", GetClipMaxX - 120, GetClipMinY - 5, 3, 90, 0);
		WaitForZeroEnemy;
		Wait(240);
		ascent(i in 0..3) {
			CreateEnemyFromFile(h~"e\e-heavyfairym.dnh", GetClipMinX, GetClipMinY + 120 + i * 30, 3, 0, 0);
			CreateEnemyFromFile(h~"e\e-heavyfairym.dnh", GetClipMaxX, GetClipMinY + 120 + i * 30, 3, 180, 0);
			Wait(240);
		}
		WaitForZeroEnemy;
		Wait(120);
		CreateEnemyFromFile(h~"e\e-heavyfairy.dnh", GetCenterX, GetClipMinY - 5, 3, 90, 0);
		WaitForZeroEnemy;
		Wait(240);
		DeleteEnemyShotToItem(ALL);
		CollectItems;
		CreateEnemyBossFromFile(h ~ "Stage 6\GennerBossNormal.dnh", GetClipMaxX, GetClipMinY, 0, 0, 0);
		WaitForZeroEnemy;
		Wait(240);
		if(stage_select == 0 && !Continued) {
			SetCommonData("extra", true);
			SaveCommonData;
		}
		Clear;
	}
	task PointToLife {
		yield;
		let pointThreshold0 = true;
		let pointThreshold1 = true;
		let pointThreshold2 = true;
		let pointThreshold3 = true;
		let pointThreshold4 = true;
		let pointThreshold5 = true;
		let pointThreshold6 = true;
		let pointThreshold7 = true;
		loop {
			if(GetPoint >= 200 && pointThreshold0) {
				ExtendPlayer(1);
				pointThreshold0 = false;
			}
			else if(GetPoint >= 400 && pointThreshold1) {
				ExtendPlayer(1);
				pointThreshold1 = false;
			}
			else if(GetPoint >= 600 && pointThreshold2) {
				ExtendPlayer(1);
				pointThreshold2 = false;
			}
			else if(GetPoint >= 800 && pointThreshold3) {
				ExtendPlayer(1);
				pointThreshold3 = false;
			}
			else if(GetPoint >= 1000 && pointThreshold4) {
				ExtendPlayer(1);
				pointThreshold4 = false;
			}
			else if(GetPoint >= 1200 && pointThreshold6) {
				ExtendPlayer(1);
				pointThreshold5 = false;
			}
			else if(GetPoint > 1400 && pointThreshold6) {
				ExtendPlayer(1);
				pointThreshold6 = false;
			}
			else if(GetPoint >= 9999 && pointThreshold7) {
				ExtendPlayer(1);
				pointThreshold7 = false;
			}
			yield;
		}
	}
	@Initialize()
	{
		LoadGraphic(imgEnemy);
		LoadCommonData;
		if(GetCommonDataDefault("firstrun", false) == false) {
			SetCommonData("firstrun", true);
			SetCommonData("extra", false);
			SaveCommonData;
		}
		if(stage_select < 0) {
			stage_select = 0;
		}
		else if(stage_select > 8) {
			stage_select = 8;
		}
		if(stage_select == 0) {
			ExpertEx(false, continues, lives);
			StageTask1;
			SetCommonData("power", 0);
		}
		else if(stage_select == 1) {
			ExpertEx(false, 0, 9);
			StageTask1;
			SetCommonData("power", 128);
		}
		else if(stage_select == 2) {
			ExpertEx(false, 0, 9);
			StageTask2;
		}
		else if(stage_select == 3) {
			ExpertEx(false, 0, 9);
			if(GetPlayerScriptName == "EmilyA.dnh" || GetPlayerScriptName == "EmilyB.dnh") {
				StageTask3E;
			}
			else {
				StageTask3F;
			}
		}
		else if(stage_select == 4) {
			ExpertEx(false, 0, 9);
			if(GetPlayerScriptName == "EmilyA.dnh" || GetPlayerScriptName == "EmilyB.dnh") {
				StageTask4E;
			}
			else {
				StageTask4F;
			}
		}
		else if(stage_select == 5) {
			ExpertEx(false, 0, 9);
			StageTask5;
		}
		else if(stage_select == 6) {
			ExpertEx(false, 0, 9);
			StageTask6;
		}
		else if(stage_select == 7) {
			LoadCommonData;
			if(GetCommonData("extra") == true) {
				ExpertEx(false, 0, 3);
				StageTaskEX;
			}
			else {
				ExpertEx(false, continues, lives);
				stage_select = 0;
				StageTask1;
				SetCommonData("power", 0);
			}
		}
		else if(stage_select == 8) {
			StageTaskBR;
			ExpertEx(false, 0, lives);
		}
		if(stage_select != 8) {
			PointToLife;
		}
	}
	
	@MainLoop()
	{
		yield;
	}
	
	@Finalize()
	{
		DeleteGraphic(imgEnemy);
		DeleteMusic(st6th);
		DeleteMusic("bgm\Soul Battle ~ Dark Master.dnh");
		DeleteMusic("bgm\Soul Battle ~ Clash of Souls.dnh");
	}
/*
	@BackGround()
	{
	 //@BackGroundが存在すると
	 //#BackGround[Default]より優先されて描画される
	}
*/	
}