task PENGIN{  

                      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(4){
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(70);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(80);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(90);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                   Wait(270);
}} Wait(180);
             loop(5){
                     Wait(120);
			CreateEnemyFromFile("script\某ペンギン\zako02.txt",cx,-30,0,0,0);      
}
       Wait(360);
loop(3){
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02R.TXT",GetClipMinX,30,0,0,0);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02L.TXT",GetClipMaxX,200,0,0,0);
                       Wait(180);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02L.TXT",GetClipMaxX,60,0,0,0);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02R.TXT",GetClipMinX,150,0,0,0);
                       Wait(300);
}
            loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02R.TXT",GetClipMinX,140,0,0,0);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02L.TXT",GetClipMaxX,100,0,0,0);
                       Wait(180);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02L.TXT",GetClipMaxX,90,0,0,0);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO02R.TXT",GetClipMinX,240,0,0,0);
                       Wait(300);
}
}
WaitForZeroEnemy();

loop(3){
             loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(70);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(80);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(90);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                   
}
	
                 
             loop(1){
                     Wait(270);
			CreateEnemyFromFile("script\某ペンギン\zako01.txt",cx,-30,0,0,0);      
}
            loop(1){
                     Wait(60);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(70);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(80);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                       Wait(90);
			CreateEnemyFromFile("script\某ペンギン\PEZAKO01.TXT",cx,-30,0,0,0);
                   
}


}

WaitForZeroEnemy();
ExtendPlayer(1);
AddBomb(30);
CreateEventFromScript("stage");
loop{yield;if(OnEvent()==false){break;}}
Wait(300);
CreateEnemyBossFromFile("script\某ペンギン\BOSSペンギン.TXT",GetClipMinX+60,GetClipMinY,0,0,0);
WaitForZeroEnemy();
DeleteEnemyShot(ALL);
  CreateEventFromScript("ICf");
loop{yield;  if(OnEvent()==false){break;}}
              SetCommonDataEx("gokusi",IC,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);

      



}
