task CAMEREON{  

                      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");}
loop(3){
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,30,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,30,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,30,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,30,0,0,0);
                   }Wait(30);
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,90,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,90,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,90,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,90,0,0,0);
                   }Wait(30);
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
                   }Wait(30);
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                   }Wait(30);
}
       Wait(360);
loop(3){                   
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO04.TXT",cx+120,-40,0,0,0);
                     Wait(150);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO04.TXT",cx-120,-40,0,0,0);
                      Wait(150);
                   }
WaitForZeroEnemy();
 Wait(60);
let hi=448;
loop(4){
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO05.TXT",cx+120,-40,0,0,hi);
                     Wait(60); hi=hi-60;
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO05.TXT",cx-120,-40,0,0,hi);
                     Wait(60); hi=hi-60;
}
hi=448;
Wait(120);
hi=448;
loop(4){
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO05.TXT",cx-120,-40,0,0,hi);
                     Wait(60); hi=hi-60;
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO05.TXT",cx+120,-40,0,0,hi);
                     Wait(60); hi=hi-60;
}
hi=448;
Wait(120);
loop(4){
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO05.TXT",cx+1,-40,0,0,hi);
                     Wait(60); hi=hi-60;
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO05.TXT",cx-1,-40,0,0,hi);
                     Wait(60); hi=hi-60;
}
WaitForZeroEnemy();
 Wait(60);
CreateEnemyFromFile("script\某カメレオン\Sカメレオンスティング.txt",cx,-30,0,0,0);
loop(3){
                    
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO03.TXT",cx,-40,0,0,0);
                     Wait(360);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO03.TXT",cx,-40,0,0,0);
                      Wait(360);
                   }Wait(30);

WaitForZeroEnemy();
loop(3){
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,40,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,150,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,40,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,150,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,40,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,150,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,40,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,150,0,0,0);
                   }Wait(30);
     
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                       Wait(75);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO01.TXT",GetClipMinX,120,0,0,0);
			CreateEnemyFromFile("script\某カメレオン\CAMEZAKO02.TXT",GetClipMaxX,60,0,0,0);
                   }




        
}

	
                 
   

WaitForZeroEnemy();
ExtendPlayer(1);
AddBomb(30);
Wait(60);
CreateEventFromScript("stage");
loop{yield;if(OnEvent()==false){break;}}
CreateEnemyBossFromFile("script\某カメレオン\BOSSカメレオン.TXT",GetCenterX,GetClipMinY,0,0,0);		
WaitForZeroEnemy();
DeleteEnemyShot(ALL);
  CreateEventFromScript("CMf");
loop{yield;  if(OnEvent()==false){break;}}
 SetCommonDataEx("gokusi",CM,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);


                   



}
