task MANDORILL{  

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

			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(500);
loop(4){

	CreateEnemyFromFile("script\某マンドリル\zako01.txt",cx,-30,0,0,0); 
	CreateEnemyFromFile("script\某マンドリル\zako01.txt",GetClipMaxX+30,cy,0,0,0); 
	CreateEnemyFromFile("script\某マンドリル\zako01.txt",GetClipMinX-30,cy,0,0,0); 
   Wait(150);}
                      Wait(300);


WaitForZeroEnemy();
Wait(180);
loop(1){
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,270);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,0);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,90);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMinY-30,0,0,180);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,270);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,90);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,0);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMinY-30,0,0,180);
Wait(180);

}
WaitForZeroEnemy();
Wait(120);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO01.TXT",cx+100,-250,0,0,0);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO01.TXT",cx-100,-250,0,0,0);
                   Wait(1200);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO01.TXT",cx+150,-200,0,0,0);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO01.TXT",cx-150,-200,0,0,0);
                   Wait(1200);
loop(4){
CreateEnemyFromFile("script\某マンドリル\MANDOZAKO02.txt",cx+45,-30,0,0,0); 
CreateEnemyFromFile("script\某マンドリル\MANDOZAKO02.txt",cx-45,-30,0,0,0); 
CreateEnemyFromFile("script\某マンドリル\MANDOZAKO02.txt",cx+135,-30,0,0,0); 
CreateEnemyFromFile("script\某マンドリル\MANDOZAKO02.txt",cx-135,-30,0,0,0); 
       Wait(240);
}
WaitForZeroEnemy();
Wait(120);
CreateEnemyBossFromFile("script\某マンドリル\mandomid1.TXT",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
Wait(180);
loop(1){
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,270);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMinY-30,0,0,0);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,90);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMinY-30,0,0,180);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,270);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,90);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,0);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,270);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,180);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,90);
Wait(180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,0);
Wait(180);
}
loop(3){
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,90);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,270);
Wait(220);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMinY-30,0,0,0);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,180);
Wait(220);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMinX-30,cy,0,0,270);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO05.txt",GetClipMaxX+30,cy,0,0,90);
Wait(220);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMinY-30,0,0,180);
	CreateEnemyFromFile("script\某マンドリル\MANDOZAKO04.txt",cx,GetClipMaxY+30,0,0,0);
Wait(220);
}
WaitForZeroEnemy();
ExtendPlayer(1);
AddBomb(30);
Wait(600);
CreateEnemyBossFromFile("script\某マンドリル\BOSSマンドリル.TXT",GetCenterX,GetClipMinY,0,0,0);
WaitForZeroEnemy();
DeleteEnemyShot(ALL);
  CreateEventFromScript("ELf");
loop{yield;  if(OnEvent()==false){break;}}
              SetCommonDataEx("gokusi",EL,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);
      


}
