task last{  

                      let gokusi=49;
                      let aaaaa=0;
   
		let cx=GetCenterX();


			function Wait(let frame)
			{//待機関数
				loop(frame){yield};
			}
			function WaitForZeroEnemy()
			{//敵数が0になるまで待機する関数
				while(GetEnemyNum() != 0){yield;}
			}
yield;


Wait(60);


if(GetCommonDataEx("gokusi",CM)==1){
CreateEventFromScript("FINALSTART");
loop{yield;   if(OnEvent()==false){break;}}
PlayMusic("\bgm\IntroductionStage.mid");
loop(4){
       loop(3){
                    
		CreateEnemyFromFile("script\某アゴ\KUWAZAKO03.TXT",GetClipMaxX-30,GetClipMinY-30,0,0,0);
                    Wait(40);
                  }
        Wait(150);}
Wait(360);

loop(8){
	CreateEnemyFromFile("script\某アゴ\MANMOZAKO01.TXT",GetClipMinX,30,0,0,0);
	CreateEnemyFromFile("script\某アゴ\MANMOZAKO02.TXT",GetClipMaxX,30,0,0,0);
  Wait(30);
} 
 Wait(360);
loop(3){
             loop(4){
                    
			CreateEnemyFromFile("script\某アゴ\WASIZAKO02L.TXT",GetClipMaxX-30,GetClipMinY-30,0,0,0);

                      Wait(30);
                  }
         Wait(180);
             loop(4){
                    
			CreateEnemyFromFile("script\某アゴ\WASIZAKO02R.TXT",GetClipMinX+30,GetClipMinY-30,0,0,0);

                      Wait(30);
                  }
         Wait(180);

}
 Wait(150);
loop(2){
 
	CreateEnemyFromFile("script\某アゴ\armzako05.TXT",cx,GetClipMaxY,0,0,0);

}
 Wait(360);

CreateEnemyBossFromFile("script\某アゴ\TAKOZAKO05.TXT",GetCenterX,GetClipMinY,0,0,0);

WaitForZeroEnemy();
	CreateEnemyFromFile("script\某アゴ\MANDOZAKO01.TXT",cx+150,-250,0,0,0);
 Wait(300);
	CreateEnemyFromFile("script\某アゴ\MANDOZAKO01.TXT",cx+75,-250,0,0,0);
             Wait(300);
	CreateEnemyFromFile("script\某アゴ\MANDOZAKO01.TXT",cx-150,-250,0,0,0);
 Wait(300);
	CreateEnemyFromFile("script\某アゴ\MANDOZAKO01.TXT",cx-75,-250,0,0,0);
                   Wait(300);
	CreateEnemyFromFile("script\某アゴ\MANDOZAKO01.TXT",cx+30,-250,0,0,0);
 Wait(300);
	CreateEnemyFromFile("script\某アゴ\MANDOZAKO01.TXT",cx-30,-250,0,0,0);
WaitForZeroEnemy();
 Wait(300);
  
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX,30,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX-60,30,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX-120,30,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX-180,30,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX,90,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX+60,90,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX+120,90,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX+180,90,0,0,0);
        Wait(120);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX,150,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX-60,150,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX-120,150,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO01.TXT",GetClipMinX-180,150,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX,210,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX+60,210,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX+120,210,0,0,0);
CreateEnemyFromFile("script\某アゴ\KUWAZAKO02.TXT",GetClipMaxX+180,210,0,0,0);
 
WaitForZeroEnemy();
 Wait(300);
ExtendPlayer(1);
CreateEnemyBossFromFile("script\VAVA\BOSSVAVA2.TXT",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
CreateEventFromScript("VA2f");
loop{yield;  if(OnEvent()==false){break;}}
Wait(300);
}
SetCommonDataEx("gokusi",TEST,0);
SetCommonDataEx("gokusi",CM,2); 
SaveCommonDataEx("gokusi","script\ロククロ\中断.txt");
SetCommonDataEx("gokusi",TEST,9);
Wait(300); 

if(GetCommonDataEx("gokusi",CM)==2&&GetCommonDataEx("gokusi",BM)==1){

if(GetCommonDataEx("gokusi",FA)==1){
PlayMusic("\bgm\IntroductionStage.mid");
CreateEventFromScript("FINALSTART2");
loop{yield;  if(OnEvent()==false){break;}}
SetCommonDataEx("gokusi",TEST,10);

PlayMusic("\bgm\Intro_Stage-1.mid");
WaitForZeroEnemy();
CreateEnemyBossFromFile("script\某犬\BOSSクワガタR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\BOSSペンギンR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\BOSS鷲R.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\BOSSアルマジロR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\midBOSS1.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
AddBomb(50);
SetCommonDataEx("gokusi",TEST,0);
SetCommonDataEx("gokusi",FA,2); 
SaveCommonDataEx("gokusi","script\ロククロ\中断.txt");

}
SetCommonDataEx("gokusi",TEST,10);
PlayMusic("\bgm\Intro_Stage-1.mid");
Wait(60); 


CreateEnemyBossFromFile("script\某犬\BOSSカメレオンR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\BOSSマンドリルR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\BOSSタコR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\BOSSマンモスR.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某犬\midBOSS2.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
ExtendPlayer(1);
AddBomb(50);

PlayMusic("\bgm\Intro_Stage-1.mid");
CreateEnemyBossFromFile("script\某犬\BOSS狼.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
CreateEventFromScript("BELf");
loop{yield;   if(OnEvent()==false){break;}}
SetCommonDataEx("gokusi",TEST,0);
SetCommonDataEx("gokusi",BM,2); 
SaveCommonDataEx("gokusi","script\ロククロ\中断.txt");

}
if(GetCommonDataEx("gokusi",BM)==2){
SetCommonDataEx("gokusi",TEST,10);
ExtendPlayer(1);
CreateEnemyBossFromFile("script\某アゴ\アゴ連続.txt",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
CreateEventFromScript("sigmaf");
loop{yield;   if(OnEvent()==false){break;}}
Wait(60);
SetCommonDataEx("gokusi",TEST,9);
CreateEventFromScript("END");
loop{yield;  if(OnEvent()==false){break;}}
Wait(60);
ClearStage();
}
}
