task KUWAGATA{  

                      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",myu)==1){PlayMusic("\bgm\x4introx.mid");}
if(GetCommonDataEx("gokusi",myu)==2){PlayMusic("\bgm\zerox4.mid");}
Wait(300);
loop(1){
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);
Wait(120);
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(240);
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);
Wait(120);
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);
Wait(240);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX,90,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX-60,90,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX-120,90,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX-180,90,0,0,0);
Wait(120);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX,30,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX+60,30,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX+120,30,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX+180,30,0,0,0);
Wait(240);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX,210,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX-60,210,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX-120,210,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO01.TXT",GetClipMinX-180,210,0,0,0);
Wait(120);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX,150,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX+60,150,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX+120,150,0,0,0);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO02.TXT",GetClipMaxX+180,150,0,0,0);
Wait(240);

loop(4){
         loop(4){
                    
			CreateEnemyFromFile("script\某クワガタ\KUWAZAKO03.TXT",GetClipMaxX-30,GetClipMinY-30,0,0,0);
                      Wait(30);
                  }
         Wait(120);}Wait(720);}
WaitForZeroEnemy();
Wait(60);
loop(1){
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,30,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,210,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,90,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,150,0,0,0);
Wait(60);

CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,310,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,270,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,190,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,90,0,0,0);
Wait(60);

CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,60,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,270,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,90,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,30,0,0,0);
Wait(60);

CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,30,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,210,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO05.TXT",GetClipMinX,90,0,0,0);
Wait(60);
CreateEnemyFromFile("script\某クワガタ\KUWAZAKO06.TXT",GetClipMaxX,150,0,0,0);
Wait(60);
}

WaitForZeroEnemy();
        Wait(180);
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(360);
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(720);
loop(8){
PlaySE("seExplode01.wav");
Wait(30);}
loop(1){
PlaySE("sePlayerCollision.wav");
Wait(60);}
PlayMusic("\bgm\BattleIntro.mid");
loop(40){ CreateEnemyFromFile("script\某クワガタ\KUWAZAKO04.TXT",rand(GetClipMinX,GetClipMaxX),GetClipMinY,0,0,0);
 CreateEnemyFromFile("script\某クワガタ\KUWAZAKO04.TXT",rand(GetClipMinX,GetClipMaxX),GetClipMinY,0,0,0);
 CreateEnemyFromFile("script\某クワガタ\KUWAZAKO04a.TXT",rand(GetClipMinX,GetClipMaxX),GetClipMinY,0,0,0);
Wait(60);
}
WaitForZeroEnemy();
CreateEventFromScript("stage");
loop{yield;if(OnEvent()==false){break;}}
loop(4){
PlaySE("seExplode01.wav");
Wait(30);}
loop(1){
PlaySE("sePlayerCollision.wav");
Wait(60);}
loop(60){ CreateEnemyFromFile("script\某クワガタ\KUWAZAKO04.TXT",rand(GetClipMinX,GetClipMaxX),GetClipMinY,0,0,0);
 CreateEnemyFromFile("script\某クワガタ\KUWAZAKO04.TXT",rand(GetClipMinX,GetClipMaxX),GetClipMinY,0,0,0);
 CreateEnemyFromFile("script\某クワガタ\KUWAZAKO04a.TXT",rand(GetClipMinX,GetClipMaxX),GetClipMinY,0,0,0);
Wait(30);
}

WaitForZeroEnemy();
ExtendPlayer(1);
AddBomb(30);
Wait(300);
CreateEnemyBossFromFile("script\某クワガタ\BOSSクワガタ.TXT",GetClipMinX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
DeleteEnemyShot(ALL);
  CreateEventFromScript("BMf");
loop{yield;  if(OnEvent()==false){break;}}
              SetCommonDataEx("gokusi",BM,1);
CreateEventFromScript("Get");
loop{yield;   if(OnEvent()==false){break;}}  
if(GetCommonDataEx("gokusi",ST)+GetCommonDataEx("gokusi",FA)+GetCommonDataEx("gokusi",CM)+GetCommonDataEx("gokusi",OC)+GetCommonDataEx("gokusi",BM)+GetCommonDataEx("gokusi",IC)+GetCommonDataEx("gokusi",EL)+GetCommonDataEx("gokusi",AM)==4){
WaitForZeroEnemy();
ExtendPlayer(1);
AddBomb(30);
Wait(300);
if(GetCommonDataEx("gokusi",50)==1){
CreateEnemyBossFromFile("script\vava\BOSSVAVA1.TXT",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
CreateEventFromScript("VAf");
loop{yield;   if(OnEvent()==false){break;}}
}
else{
CreateEnemyBossFromFile("script\某犬\BOSS狼a.TXT",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
CreateEventFromScript("BELaf");
loop{yield;  if(OnEvent()==false){break;}}
}

}
WaitForZeroEnemy();
PlayMusic("\bgm\BattleFinish.mid");
Wait(1220);
SetCommonDataEx("gokusi",TEST,0); 
PlayMusic("\bgm\DrCain.mid");
if(GetCommonDataEx("gokusi",ST)+GetCommonDataEx("gokusi",FA)+GetCommonDataEx("gokusi",CM)+GetCommonDataEx("gokusi",OC)+GetCommonDataEx("gokusi",BM)+GetCommonDataEx("gokusi",IC)+GetCommonDataEx("gokusi",EL)+GetCommonDataEx("gokusi",AM)==4){
CreateEventFromScript("MID");
loop{yield;  if(OnEvent()==false){break;}}
}
if(GetCommonDataEx("gokusi",ST)+GetCommonDataEx("gokusi",FA)+GetCommonDataEx("gokusi",CM)+GetCommonDataEx("gokusi",OC)+GetCommonDataEx("gokusi",BM)+GetCommonDataEx("gokusi",IC)+GetCommonDataEx("gokusi",EL)+GetCommonDataEx("gokusi",AM)==8){
CreateEventFromScript("FINAL");
loop{yield;   if(OnEvent()==false){break;}}
}
ExtendPlayer(1);
AddBomb(-1*GetPlayerBomb);
AddBomb(100);

      



}
