script_enemy_main {
    let time = -150;
    let phase = 2;
    let sephase = 2;
    let rate = 0;
    let kaku = 50;
    let score = 0;
    let lv = 0;
    let life = 8420;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    SetCommonData("bossx",GetX);
    SetCommonData("bossy",GetY);
    SetCommonData("bossphase",2);
    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( 8420 );
        SetInvincibility( 0 );
        SetTimer(180);
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tmain1;Tmove;
        SetMovePositionHermite(224, 150, 100, 90, 100, 270, 150);
    }
    @MainLoop {
        SetCommonData("bossx",GetX);
        SetCommonData("bossy",GetY);
        if(phase==2&&GetLife<=3620){
           phase-=1;
           time=-120;
           score=40000;
           SetCommonData("bossphase",1);
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 500);}
           PlaySE(se2);
           Tdeath(15,80,2,0);
           Tmain2;
           sephase=1;
        }
        if(phase==1&&GetLife<=20){
           phase-=1;
           score=50000;
           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==2&&GetLife<=4020){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( 0, 192, 64, 320 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );

    }

    task Tmain1{
        yield;
        wait(150);
        let n=1.5;
        loop(1){
           CreateEnemyFromScript("bit1", GetX, GetY, 0, 0, n);
           CreateEnemyFromScript("bit1", GetX, GetY, 0, 0, -n);
           n++;
        }
        wait(60);

        loop{
        if(phase<=1){return;}
        SetCommonData("bossatack",1);
        /*Tshot11a;*/Tshot11b;
        wait(300);
        if(phase<=1){return;}
        SetCommonData("bossatack",0);
        wait(100-lv*60);

        if(phase<=1){return;}
        SetCommonData("bossatack",2);
        Tshot12a;Tshot12b;
        wait(400);
        if(phase<=1){return;}
        SetCommonData("bossatack",0);
        wait(20-lv*20);

        if(phase<=1){return;}
        SetCommonData("bossatack",3);
        Tshot13;
        wait(400);
        if(phase<=1){return;}
        SetCommonData("bossatack",0);
        wait(180-lv*100);
        }

    }
    task Tmain2{
        yield;
        wait(120);
        loop(2){

        if(phase<=0){return;}
        SetCommonData("bossatack",1);
        Tshot21a;Tshot21b;
        wait(400);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(180-lv*130);

        if(phase<=0){return;}
        SetCommonData("bossatack",2);
        Tshot22a;
        wait(450);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(100-lv*60);

        }
        loop{

        if(phase<=0){return;}
        SetCommonData("bossatack",2);
        Tshot22a;
        wait(450);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(100-lv*60);

        }
    }

    task Tshot11a{
        yield;
        let a=0;
        while(GetCommonData("bossatack")==1){
           let b=0;
           let p1=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+90));
           let p2=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-90));
           loop(6){
              if(phase<=1){return;}
              CreateShotFromScript( "shot1",GetX()+90, GetY(), 3.5+ex, genteikaku(p1,32), 0, 13);
              CreateShotFromScript( "shot1",GetX()-90, GetY(), 3.5+ex, genteikaku(p2,32), 0, 13);
              if(ex==1){
                 CreateShotFromScript( "shot1",GetX()+107, GetY(), 3.5+ex, genteikaku(p1,32), 0, 13);
                 CreateShotFromScript( "shot1",GetX()-107, GetY(), 3.5+ex, genteikaku(p2,32), 0, 13);
              }
              PlaySE(seshot1);
              wait(4);
              b++;
           }
           wait(35-lv*25-ex*25);
           a++;
        }
    }
    task Tshot11b{
        yield;
        let a=0;
        while(GetCommonData("bossatack")==1){
           let b=0;
           let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()));
           loop(1+ex*5){
              if(phase<=1){return;}
              let c=-2-a%2/2;
              loop(5+a%2){
                 CreateShotFromScript( "shot1",GetX(), GetY(), 3+ex, genteikaku(p,48)+c*18, 0, 07);
                 c++;
              }
              PlaySE(seshot2);
              wait(5);
              b++;
           }
           wait(35-lv*18-ex*10);
           a++;
        }
    }

    task Tshot12a{
        yield;
        let a=1;
        while(GetCommonData("bossatack")==2){
           loop(1){
              if(phase<=1){return;}
              let b=0;
              loop(2+ex*4){
                 CreateShotFromScript( "shot1",GetX()+120, GetY()-15, 2.5+ex, b*(180-ex*120)-a*(13.1-ex*4), 0, 12);
                 CreateShotFromScript( "shot1",GetX()-120, GetY()-15, 2.5+ex, b*(180-ex*120)+a*(13.1-ex*4)+90, 0, 12);
                 b++;
              }
           }
           wait(6-lv*4);
           a++;
        }
    }
    task Tshot12b{
        yield;
        let a=1;
        while(GetCommonData("bossatack")==2){
           let b=1;
           loop(7+ex*12){
              if(phase<=1){return;}
              let p=GetAngleToPlayer;
              let c=0;
              loop(1){
                 CreateShotFromScript( "shot1",GetX(), GetY(), 2.5+0.5*b+ex, p, 0, 01);
                 c++;
              }
              PlaySE(seshot2);
              wait(10-ex*4);
              b++;
           }
           wait(35-lv*22);
           a++;
        }
    }

    task Tshot13{
        yield;
        wait(60);
        let a=0;
        while(GetCommonData("bossatack")==3){
           if(phase<=1){return;}
           let p=GetAngleToPlayer+sin(a*73)*10;
           let b=-1-ex*2;
           loop(3+ex*4){
              CreateShotFromScript( "shot1",GetX(), GetY(), 2+ex, p+b*3, 0, 05);
              b++;
           }
           PlaySE(seshot2);
           wait(20-lv*10);
           a++;
        }
    }

    task Tshot21a{
        yield;
        let a=0;
        while(GetCommonData("bossatack")==1){
           if(phase<=0){return;}
           CreateEnemyFromScript("bit2", GetX, GetY, 0, 0, a%2-0.5);
           PlaySE(seshot2);
           wait(24-lv*12);
           a++;
        }
    }
    task Tshot21b{
        yield;
        wait(50);
        let a=0;
        while(GetCommonData("bossatack")==1){
           if(phase<=0){return;}
           let p=GetAngleToPlayer;
           let b=-2-ex*2;
           loop(5+ex*4){
              CreateShotFromScript( "shot1",GetX(), GetY(), 2.8+ex, genteikaku(p,32)+b*23+1.5, 0, 03);
              CreateShotFromScript( "shot1",GetX(), GetY(), 2.8+ex, genteikaku(p,32)+b*23-1.5, 0, 03);
              b++;
           }
           wait(45-lv*22);
           a++;
        }
    }
    task Tshot22a{
        yield;
        let a=0;
        let b=10;
        while(GetCommonData("bossatack")==2){
           if(phase<=0){return;}
           let c=0;
           let p=genteikaku(GetAngleToPlayer,4)-90;
           loop(1){
              CreateShotFromScript( "shota",GetX()+60+sin(a*100)*20, GetY()+cos(a*100)*20, 5, b+p+c*120, 0, 06);
              CreateShotFromScript( "shota",GetX()-60+sin(a*100)*20, GetY()+cos(a*100)*20, 5, b+p+c*120, 0, 06);
              if(ex==1){
                 CreateShotFromScript( "shota",GetX()+60+cos(a*100)*20, GetY()+sin(a*100)*20, 5+ex, b+p+c*120, 0, 06);
                 CreateShotFromScript( "shota",GetX()-60+cos(a*100)*20, GetY()+sin(a*100)*20, 5+ex, b+p+c*120, 0, 06);
              }
              c++;
           }
           a++;
           if(a%40<20){b+=8}
           else{b-=8}
           PlaySE(seshot1);
           wait(3-lv*2);
        }
    }

    task Tmove {
        wait(150);
        loop{
           SetMovePosition02(224+rand(10,-10), 130+rand(10,-10),90);
           wait(90);
           SetMovePosition02(224+rand(10,-10), 130+rand(10,-10),90);
           wait(90);
        }
    }


    #include_function".\efanction.txt"
}
//////////////////////////////////////////////////////////////////////////////////////////////////
script_enemy bit1 {
    let time = -60;
    let phase = 1;
    let rate = 10;
    let kaku = 10;
    let score = 0;
    let lv = 0;
    let size = 30;
    let stg= false;
    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( 500 );
        SetInvincibility( 60 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tmain;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           SetCommonData("bossparts1",GetCommonData("bossparts1")+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("bossatack")==1&&stg==false){Tshot1;}
        if(GetCommonData("bossatack")==3&&stg==false){Tshot3;}
        if(GetCommonData("bossphase")==1){VanishEnemy;}
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetColor(255,0,255);
        SetGraphicRect( 512, 96, 560, 144 );
        SetGraphicAngle( 0, 0, time*31);
	DrawGraphic( GetX(), GetY() );
    }
    task Tmain{
        yield;
        loop(60){
           SetX(GetCommonData("bossx")+arg*70*(60+time)/60);
           SetY(GetCommonData("bossy")+(60-(|arg*10|))*(60+time)/60);
           yield;
        }
        loop{
           SetX(GetCommonData("bossx")+arg*70);
           SetY(GetCommonData("bossy")+(60-(|arg*10|)));
           yield;
        }
    }
    task Tshot1{
        stg=true;
        yield;
        let a=0;
        while(GetCommonData("bossatack")==1){
           let b=0;
           let p=GetAngleToPlayer;
           loop(5){
              if(phase<=0){return;}
              CreateShotFromScript( "shot1",GetX(), GetY(), 3.5+ex, genteikaku(p,48), 0, 13);
              if(ex==1){
                 CreateShotFromScript( "shot1",GetX(), GetY(), 3.5+ex, genteikaku(p,48)+4, 0, 13);
                 CreateShotFromScript( "shot1",GetX(), GetY(), 3.5+ex, genteikaku(p,48)-4, 0, 13);
              }
              PlaySE(seshot1);
              wait(4);
              b++;
           }
           wait(45-lv*30);
           a++;
        }
        stg=false;
    }
    task Tshot3{
        stg=true;
        yield;
        let a=-50;
        while(GetCommonData("bossatack")==3){
           let b=0;
           loop(1){
              if(phase<=0){return;}
              CreateShotFromScript( "shot1",GetX(), GetY(), 4+ex, 90+arg*20+30-a*3, 0, 11);
              CreateShotFromScript( "shot1",GetX(), GetY(), 4+ex, 90+arg*20-30+a*3, 0, 11);
              b++;
           }
           wait(3-lv);
           if(a<0){a++;}
        }
        stg=false;
    }

    #include_function".\efanction.txt"
}
script_enemy bit2 {
    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( 60 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        Tshot1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           SetCommonData("bossparts2",GetCommonData("bossparts2")+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")==0){VanishEnemy;}
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
	SetTexture( imgEnemy );
        SetColor(255,0,255);
        SetGraphicRect( 512, 96, 560, 144 );
        SetGraphicAngle( 0, 0, time*31);
	DrawGraphic( GetX(), GetY() );
    }
    task Tshot1{
        yield;
        SetMovePosition02(GetX+rand(50,150)*arg*2, GetY+rand(60,-60),30);
        wait(40);
        let p=GetAngleToPlayer;
        SetAngle(p+rand(-5,5));
        SetSpeed(4);
        while(time<200){
           if(phase==0||GetCommonData("bossphase")==0){return;}
           let a=-ex;
           loop(1+ex*2){
              CreateShotFromScript( "shot3",GetX(), GetY(), 0.06+ex*0.04, genteikaku(p,32)+a*5, 0, 13);
              a++;
           }
           wait(4-lv*2);
        }
        while(time<240){wait(1);}
        VanishEnemy;
    }

    #include_function".\efanction.txt"
}
    script_shot shota{
       let out=false;
       let gr=GetArgument;
       let lv=0;
       let time=0;
       @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(time==25){SetSpeed(GetSpeed-3);}
          if((GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2<=4){SetCommonData("gekitui",1);}
          time++;
       }
       @DrawLoop {
          DrawGraphicDefault();
       }
       @Finalize{
          if(out==false&&OnBomb==false){
             if(GetCommonData("kakusei")>0){
                let a=(200+GetCommonData("kinkaiten")*100);
                CreateShotFromScript( "kinka",GetX(), GetY(), a, 270, 0, 99-GetCommonData("kinkaiten")/20);
             }
             if(OnBomb==false&&GetCommonData("kakusei")==0){
                CreateShotFromScript( "isi",GetX(), GetY(), 0, 270, 0, 0);
             }
          }
       }
    }    
#include_script".\escript.txt"