script_enemy_main {
   let time = -150;
   let phase = 3;
   let sephase = 3;
   let rate = 0;
   let kaku = 50;
   let score = 0;
   let lv = 0;
   let life = 15120;
   let angle = GetAngle();
   let rank = GetSpeed();
   let arg = GetArgument();
   let ex = GetCommonData("ex");
   SetCommonData("bossx",GetX);
   SetCommonData("bossy",GetY);
   SetCommonData("bossphase",3);
   SetCommonData("bossparts1",0);
   SetCommonData("bossparts2",0);
   SetCommonData("bossatack",0);
   let imgEnemy = GetCurrentScriptDirectory~"img\st1boss.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
   let se6 = GetCurrentScriptDirectory~"wav\se6.wav";
   let seshot1 = GetCurrentScriptDirectory~"wav\shot1.wav";
   let seshot2 = GetCurrentScriptDirectory~"wav\shot2.wav";
   @Initialize(){
       SetLife( 15120 );
       SetInvincibility( 0 );
       SetTimer(240);
       LoadGraphic( imgEnemy );
       LoadUserShotData( tama );
       Tmain1;Tmove;
       SetMovePositionHermite(224, 150, 100, 90, 100, 270, 150);
   }
   @MainLoop {
       SetCommonData("bossx",GetX);
       SetCommonData("bossy",GetY);
       if(phase==3&&GetLife<=9020){
          phase-=1;
          time=-120;
          score=40000;
          SetCommonData("bossphase",2);
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 500);}
          PlaySE(se2);
          Tdeath(15,80,2,0);
          Tmain2;
          sephase=2;
       }
       if(phase==2&&GetLife<=3020){
          phase-=1;
          time=-120;
          score=45000;
          SetCommonData("bossphase",1);
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 500);}
          PlaySE(se2);
          Tdeath(15,80,2,0);
          Tshot3;
          sephase=1;
       }
       if(phase==1&&GetLife<=20){
          phase-=1;
          score=60000;
          SetCommonData("bossphase",0);
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 500);}
          PlaySE(se2);
          Tdeath(0,80,2,0);
          Tbaku;
          Tbossbaku;
       }
       if(phase>=1&&time>=0){
          SetCollisionA(GetX+120, GetY, 40);
          SetCollisionA(GetX-120, GetY, 40);
          SetCollisionA(GetX+50, GetY, 40);
          SetCollisionA(GetX-50, GetY, 40);

          SetCollisionA(GetX, GetY, 40);
          SetCollisionB(GetX, GetY, 30);

       }
       if(sephase==3&&GetLife<=9420){PlaySE(se6);sephase=2;}
       if(sephase==2&&GetLife<=3420){PlaySE(se6);sephase=1;}
       if(sephase==1&&GetLife<=420){PlaySE(se6);sephase=0;}
       if(GetCommonData("kakusei")>0){lv=1}
       else{lv=0}
       time++;
       yield;
   }
   @Finalize() {
   }
   @DrawLoop {
       if(time%5==0){
          if(life==GetLife){SetColor(255,255,255);}
          else{SetColor(210,210,255);}
          life=GetLife;
          if(phase==0||(time%30<5&&GetLife<920)){SetColor(255,200,200);}
       }

   	SetTexture( imgEnemy );

   	SetGraphicRect( 0, 0, 448, 192 );
   	SetGraphicAngle(0,0,0);
		DrawGraphic( GetX(), GetY() );
		SetGraphicRect( 64, 192, 128, 320 );
		SetGraphicAngle(0,0,0);
		DrawGraphic( GetX(), GetY() );
   }

   task Tmain1{
       yield;
       wait(150);

       loop{
       if(phase<=2){return;}
       SetCommonData("bossatack",1);
       Tshot11a;
       Tshot11b;
       wait(450);
       if(phase<=2){return;}
       SetCommonData("bossatack",0);
       wait(50-lv*35);

       if(phase<=2){return;}
       Fshot12;
       wait(180-lv*100);

       if(phase<=2){return;}
       SetCommonData("bossatack",3);
       Tshot13;
       wait(200);
       if(phase<=2){return;}
       SetCommonData("bossatack",0);
       wait(20-lv*20);

       if(phase<=2){return;}
       Fshot12;
       wait(180-lv*100);

       if(phase<=2){return;}
       SetCommonData("bossatack",4);
       Tshot14a;
       Tshot14b;
       wait(450);
       if(phase<=2){return;}
       SetCommonData("bossatack",0);
       wait(80-lv*55);

       }

   }
   task Tmain2{
       yield;
       wait(120);
       loop{
       if(phase<=1){return;}
       SetCommonData("bossatack",1);
       Tshot21a;//Tshot21b;
       wait(350);
       if(phase<=1){return;}
       SetCommonData("bossatack",0);
       wait(60-lv*40);

       if(phase<=1){return;}
       Fshot22;
       wait(100-lv*50);

       if(phase<=1){return;}
       SetCommonData("bossatack",1);
       Tshot23a;Tshot23b;
       wait(450);
       if(phase<=1){return;}
       SetCommonData("bossatack",0);
       wait(130-lv*40);

       }

   }

   task Tshot11a{
       yield;
       wait(60);
       let a=rand(0,10);
       while(GetCommonData("bossatack")==1){
          let p=GetAngleToPlayer+sin(a*71)*40;
          if(phase<=2){return;}
          PlaySE(seshot2);
          loop(5){
             if(phase<=2){return;}
             let b=-3-ex*2;
             loop(7+ex*4){
                CreateShotFromScript( "shot1",GetX(), GetY(), 3+ex, p+b*(13-ex*3), 0, 07);
                b++;
             }
          wait(3);
          }
       wait(20-lv*14);
       a++;
       }
   }
   task Tshot11b{
       yield;
       while(GetCommonData("bossatack")==1){
          let a=0;
          let p=GetAngleToPlayer;
          loop(5){
             let b=0;
             loop(3+ex){
                if(phase<=2){return;}
                CreateShotFromScript( "shot4",GetX(), GetY(), 3+a/2+ex*0.5, p+15+b*(15+a), 0, 13);
                CreateShotFromScript( "shot4",GetX(), GetY(), 3+a/2+ex*0.5, p-15-b*(15+a), 0, 13);
                PlaySE(seshot1);
                b++;
             }
             wait(3);
             a++;
          }
       wait(26-lv*13);
       }
   }

   function Fshot12{
      yield;
      let a=-1.5;
      loop(4){
         CreateShotFromScript( "shot5",GetX()-1.5*a, GetY(), 4, 90+a*2.5, 0, 05);
       	if(ex==1){
         	CreateShotFromScript( "shot5",GetX()-1.5*a, GetY(), 4, 90+70+a*2.5, 0, 05);
         	CreateShotFromScript( "shot5",GetX()-1.5*a, GetY(), 4, 90-70+a*2.5, 0, 05);
       	}
         PlaySE(seshot2);
         a++;
      }
   }

   task Tshot13{
       yield;
       let a=0;
       while(GetCommonData("bossatack")==3){
          if(phase<=2){return;}
          let p=GetAngleToPlayer;
          let b=-1;
          loop(3){
             CreateShotFromScript( "shot5",GetX(), GetY(), 2.8+ex, genteikaku(p,32)+b*4, 0, 6);
             b++;
          }
          PlaySE(seshot2);
          wait(36-lv*18);
          a++;
       }
   }

   task Tshot14a{
       yield;
       wait(60);
       let a=rand(0,10);
       while(GetCommonData("bossatack")==4){
          let p=GetAngleToPlayer+sin(a*71)*30+rand(10,-10);
          let b=-1-ex*1;
          loop(3+ex*2){
             let c=-1-ex*0.5;
             loop(3+ex){
                if(phase<=2){return;}
                CreateShotFromScript( "shot1",GetX(), GetY(), 3.5+ex, p+c*3+b*22, 0, 05);
                c++;
             }
             b++;
          }
       PlaySE(seshot2);
       wait(18-lv*9);
       a++;
       }
   }
   task Tshot14b{
       yield;
       let a=rand(0,10);
       while(GetCommonData("bossatack")==4){
          let p=GetAngleToPlayer+sin(a*167)*40+rand(10,-10);
          let b=-1.5-ex*0.5;
          loop(4+ex*1){
             if(phase<=2){return;}
             CreateShotFromScript( "shot1",GetX(), GetY(), 2.5+ex, p+b*(17-ex*4), 0, 06);
             b++;
          }
       PlaySE(seshot1);
       wait(12-lv*6);
       a++;
       }
   }

   task Tshot21a{
       yield;
       let a=0;
       while(GetCommonData("bossatack")==1){
          if(phase<=1){return;}
          let b=0;
          loop(3){
             CreateShotFromScript( "shota",GetX(), GetY(), 2.5+ex, a*7.9+b*120, 0, -a*12);
             CreateShotFromScript( "shota",GetX(), GetY(), 3.5+ex, -a*11.3+b*120, 0, a*18);
             b++;
          }
          PlaySE(seshot2);
          wait(2-lv*1);
          a++;
       }
   }
   function Fshot22{
       yield;
       let a=-8;
       loop(17+ex*10){
          if(phase<=1){return;}
          let b=0;
          loop(2){
             CreateShotFromScript( "shot5",GetX(), GetY(), 4.5-ex, 45+b*90-a*3, 0, 7);
             b++;
          }
          PlaySE(seshot1);
          wait(4-lv*2);
          a++;
       }
       wait(100-lv*50);
       let a=0;
       loop(4){
          if(phase<=1){return;}
          let p=genteikaku(GetAngleToPlayer,12);
          loop(80+ex*30){
             CreateShotFromScript( "shot1",GetX(), GetY(), 1.3+a%7*0.5+rand(0.5,0)+ex, p+sin(a*157)*70+rand(10,-10), 0, 13);
             a++;
          }
          PlaySE(seshot2);
          wait(20-lv*10);
          a++;
       }
       wait(50-lv*25);
       let a=-8;
       loop(17+ex*10){
          if(phase<=1){return;}
          let b=0;
          loop(2){
             CreateShotFromScript( "shot5",GetX(), GetY(), 4.5-ex, 45+b*90+a*3, 0, -7);
             b++;
          }
          PlaySE(seshot1);
          wait(4-lv*2);
          a++;
       }
   }

   task Tshot23a{
       yield;
       let a=1;
       while(GetCommonData("bossatack")==1){
          if(phase<=1){return;}
          CreateEnemyFromScript("bit", GetX+a*110, GetY, 0, 0, a);
          wait(24-lv*12);
          a*=-1;
       }
   }
   task Tshot23b{
       yield;
       let a=1;
       while(GetCommonData("bossatack")==1){
          if(phase<=1){return;}
          let p=GetAngleToPlayer;
          let a=0-ex;
          loop(1+ex*2){
             CreateShotFromScript( "shot1",GetX(), GetY(), 3.2+ex, p+a*20+rand(5,-5), 0, 02);
             a++;
          }
          wait(16-lv*8);
          a*=-1;
       }
   }

   task Tshot3{
       yield;
       wait(120);
       let a=0;
       loop{
          if(phase<=0){return;}
          let b=-3;
          loop(7){
             CreateShotFromScript( "shotc",GetX()+(a%3+2)*35, GetY()-20, 4+ex*0.5, 90+b*8, 0, 0);
             CreateShotFromScript( "shotc",GetX()-(a%3+2)*35, GetY()-20, 4+ex*0.5, 90+b*8, 0, 0);
             b++;
          }
          PlaySE(seshot2);
          wait(20-lv*10);
          a++;
       }
   }
/*   task Tshot3{
       yield;
       wait(120);
       let a=1;
       loop{
          if(phase<=0){return;}
          let p=GetAngleToPlayer;
          let b=0;
          loop(1+ex){
             CreateShotFromScript( "shotb",GetX(), GetY(), 0, p+a*(75-b*15), 0, a);
             b++;
          }
          PlaySE(seshot2);
          wait(20-lv*10);
          a*=-1;
       }
   }*/
   task Tmove {
       wait(150);
       loop{
          SetMovePosition02(224+rand(20,-20), 130+rand(20,-20),90);
          wait(90);
          SetMovePosition02(224+rand(20,-20), 130+rand(20,-20),90);
          wait(90);
       }
   }

   #include_function".\efanction.txt"
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
script_enemy bit {
   let time = 0;
   let phase = 1;
   let rate = 10;
   let kaku = 10;
   let score = 0;
   let lv = 0;
   let size = 30;
   let bitangle = 0;
   let angle = GetAngle();
   let rank = GetSpeed();
   let arg = GetArgument();
   let ex = GetCommonData("ex");
   let imgEnemy = GetCurrentScriptDirectory~"img\st1boss.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
   let seshot1 = GetCurrentScriptDirectory~"wav\shot1.wav";
   @Initialize(){
       SetLife( 110 );
       SetInvincibility( 20 );
       LoadGraphic( imgEnemy );
       LoadUserShotData( tama );
       Tshot1;
   }
   @MainLoop {
       if(phase==1&&GetLife<=100){
          phase-=1;
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 30);}
          PlaySE(se3);
          Tdeath(2,30,2,1);
       }
       if(phase>=1){
          SetCollisionA(GetX, GetY, 20);
          SetCollisionB(GetX, GetY, 20);
       }
       if(GetCommonData("bossphase")<=1){VanishEnemy;}
       if(GetCommonData("kakusei")>0){lv=1}
       else{lv=0}
       time++;
       yield;
   }
   @Finalize() {
   }
   @DrawLoop {
	SetTexture( imgEnemy );
       SetColor(100,255,0);
       SetGraphicRect( 512, 96, 560, 144 );
       SetGraphicAngle( 0, 0, time*31);
	DrawGraphic( GetX(), GetY() );
   }
   task Tshot1{
       yield;
       SetAngle(90+rand(-10,10));
       SetSpeed(1.7);
       wait(40);
       let a=rand(0,73);
       while(time<120){
          if(phase==0||GetCommonData("bossphase")==0){return;}
          let b=0;
          loop(1){
             CreateShotFromScript( "shot1",GetX(), GetY(), 2.5+ex, 90+arg*90+a*19*arg, 0, 13);
             b++;
          }
          wait(2-lv*0);
          a++;
       }
       while(time<240){wait(1);}
       VanishEnemy;
   }

   #include_function".\efanction.txt"
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
   script_shot shota{
      let out=false;
      let gr=12;
      let lv=0;
      let time=0;
      let angle=GetAngle;
      let arg=GetArgument;
      @Initialize{
         SetDefault(gr+lv*20);
         SetAngle(GetAngleToPlayer+angle);
      }
      @MainLoop {
         if(GetX<20||GetX>428||GetY<20||GetY>460){
            out=true;
            End;
         }
         if(GetCommonData("kakusei")>0){
            lv=1;
            if(GetPoint==0){lv=2;SetSpeed(GetSpeed+0.04)}
         }
         else{lv=0}
         SetDefault(gr+lv*20);
         if((GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2<=4){SetCommonData("gekitui",1);}
         if(time==25){SetAngle(arg);}
         time++;
      }
      @DrawLoop {
         DrawGraphicDefault();
      }
      @Finalize{
         if(out==false&&OnBomb==false){
            if(GetCommonData("kakusei")>0){
               CreateShotFromScript( "kinka",GetX(), GetY(), 0, 270, 0, 0);
            }
            if(OnBomb==false&&GetCommonData("kakusei")==0){
               CreateShotFromScript( "isi",GetX(), GetY(), 0, 270, 0, 0);
            }
         }
      }
   }    
   script_shot shotb{
      let out=false;
      let gr=01;
      let lv=0;
      let time=0;
      let angle=GetAngle;
      let arg=GetArgument;
      @Initialize{
         SetDefault(gr+lv*20);
      }
      @MainLoop {
         if(GetX<20||GetX>428||GetY<20||GetY>460){
            out=true;
            End;
         }
         if(GetCommonData("kakusei")>0){
            lv=1;
            if(GetPoint==0){lv=2;SetSpeed(GetSpeed+0.04)}
         }
         else{lv=0}
         SetDefault(gr+lv*20);
         if((GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2<=4){SetCommonData("gekitui",1);}

         SetSpeed(GetSpeed+0.12);
         if(time%2==0&&time<50){CreateShotFromScript( "shot1",GetX(), GetY(), 4.5, GetAngle-75*arg-time*0.65*arg, 0, 13);}
         time++;
      }
      @DrawLoop {
         DrawGraphicDefault();
      }
      @Finalize{
         if(out==false&&OnBomb==false){
            if(GetCommonData("kakusei")>0){
               CreateShotFromScript( "kinka",GetX(), GetY(), 0, 270, 0, 0);
            }
            if(OnBomb==false&&GetCommonData("kakusei")==0){
               CreateShotFromScript( "isi",GetX(), GetY(), 0, 270, 0, 0);
            }
         }
      }
   }    
   script_shot shotc{
      let out=false;
      let gr=13;
      let lv=0;
      let time=0;
      let spd = GetSpeed;
      let angle=GetAngle;
      let arg=GetArgument;
      @Initialize{
         SetDefault(gr+lv*20);
      }
      @MainLoop {
         if(GetX<20||GetX>428||GetY<20||GetY>460||time>490){
            out=true;
            End;
         }
         if(GetCommonData("kakusei")>0){
            lv=1;
            if(GetPoint==0){lv=2;SetSpeed(GetSpeed+0.04)}
         }
         else{lv=0}
         SetDefault(gr+lv*20);
         if((GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2<=4){SetCommonData("gekitui",1);}

         if(time%50==49 && time<490){SetAngle(GetAngleToPlayer);SetSpeed(spd);}
         if(time>=300){
            out=true;
            End;
         }
         SetSpeed(GetSpeed-0.08);
         time++;
      }
      @DrawLoop {
         DrawGraphicDefault();
      }
      @Finalize{
         if(out==false&&OnBomb==false){
            if(GetCommonData("kakusei")>0){
               CreateShotFromScript( "kinka",GetX(), GetY(), 0, 270, 0, 0);
            }
            if(OnBomb==false&&GetCommonData("kakusei")==0){
               CreateShotFromScript( "isi",GetX(), GetY(), 0, 270, 0, 0);
            }
         }
      }
   }
#include_script".\escript.txt"