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 = 10820;
    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( 10820 );
        SetInvincibility( 0 );
        SetTimer(210);
        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<=5420){
           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<=5820){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( 128, 192, 192, 320 );
        SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );

    }

    task Tmain1{
        yield;
        wait(150);

        loop{
        if(phase<=1){return;}
        SetCommonData("bossatack",1);
        Tshot11;
        wait(200);
        if(phase<=1){return;}
        SetCommonData("bossatack",0);
        wait(10-lv*10);

        if(phase<=1){return;}
        Fshot12;
        wait(120-lv*80);

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

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

        if(phase<=1){return;}
        Fshot15;
        wait(40-lv*30);

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

    }
    task Tmain2{
        yield;
        wait(120);
        loop(2){
        if(phase<=0){return;}
        SetCommonData("bossatack",3);
        Tshot23a;Tshot23b;
        wait(300);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(60-lv*40);

        if(phase<=0){return;}
        SetCommonData("bossatack",4);
        Tshot24;
        wait(120);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(40-lv*30);


        if(phase<=0){return;}
        SetCommonData("bossatack",1);
        Tshot20;
        wait(350);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(60-lv*40);

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


        }
        loop{

        if(phase<=0){return;}
        SetCommonData("bossatack",3);
        Tshot23a;Tshot23b;
        wait(300);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(60-lv*40);

        if(phase<=0){return;}
        SetCommonData("bossatack",4);
        Tshot24;
        wait(120);
        if(phase<=0){return;}
        SetCommonData("bossatack",0);
        wait(40-lv*30);
        }
    }

    task Tshot11{
        yield;
        let a=0;
        while(GetCommonData("bossatack")==1){
           let b=0;
           let p=GetAngleToPlayer;
           loop(1+ex){
              if(phase<=1){return;}
              CreateShotFromScript( "shot1",GetX(), GetY(), 3+b*0.5+ex, p+a%100-50, 0, 03);
              PlaySE(seshot1);
              b++;
           }
           wait(2-lv);
           a+=77+rand(-10,10);
        }
    }

    function Fshot12{
        yield;
        let a=rand_int(0,8);
        loop(3){
           let b=0;
           PlaySE(seshot2);
           loop(12+ex*6){
              if(phase<=1){return;}
              let c=0;
              loop(8){
                 CreateShotFromScript( "shota",GetX(), GetY(), 5.5+ex, c*45+b*4*(a%2-0.5)+a*10, 0, -40*(a%2-0.5));
                 c++;
              }
              b++;
              PlaySE(seshot1);
              wait(1);
           }
           wait(15-lv*15);
           a++;
        }
    }

    task Tshot13{
        yield;
        let a=0;
        while(GetCommonData("bossatack")==3){
           if(phase<=1){return;}
           let p=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+80*(a%2-0.5)));
           let b=-1.5-ex*1;
           loop(4+ex*2){
              CreateShotFromScript( "shot1",GetX()+80*(a%2-0.5), GetY(), 3.3+ex, genteikaku(p,32)+b*13, 0, 13);
              b++;
           }
           let b=-2-ex*1;
           loop(5+ex*2){
              CreateShotFromScript( "shot1",GetX()+80*(a%2-0.5), GetY(), 3.5+ex, genteikaku(p,32)+b*2, 0, 13);
              b++;
           }
           PlaySE(seshot2);
           wait(25-lv*12);
           a++;
        }
    }

    function Fshot14{
        yield;
        let a=0;
        let p1=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()+30));
        let p2=atan2( GetPlayerY()-(GetY()), GetPlayerX()-(GetX()-30));
        PlaySE(seshot2);
        loop(15){
           if(phase<=1){return;}
           let b=-2-ex*2;
           loop(5+ex*4){
              CreateShotFromScript( "shot1",GetX()+30, GetY(), 3+a*0.5, p1+b*(16-ex*5), 0, 02);
              CreateShotFromScript( "shot1",GetX()-30, GetY(), 3+a*0.5, p2+b*(16-ex*5), 0, 02);
              b++;
           }
           PlaySE(seshot1);
           wait(4-lv*2);
           a++;
        }
    }
    function Fshot15{
        yield;
        let a=0;
        loop(20){
           if(phase<=1){return;}
           let b=-2-ex*2;
           loop(6+ex*3){
              CreateShotFromScript( "shot1",GetX()+cos(a*10)*20, GetY()+sin(a*10)*20, 2.5+b*0.5+ex*1, a*9+b*15, 0, 06);
              b++;
           }
           PlaySE(seshot1);
           wait(2-lv*1);
           a++;
        }
    }
    function Fshot16{
        yield;
        let a=15+rand(-0.5,0.5);
        loop(16){
           if(phase<=1){return;}
           let b=0;
           loop(7){
              CreateShotFromScript( "shot1",GetX()+cos(a*12-90)*20, GetY()+sin(a*12-90)*20, 2.5+b*0.3+ex, a*12+3, 0, 13);
              CreateShotFromScript( "shot1",GetX()+cos(a*12+90)*20, GetY()+sin(a*12+90)*20, 2.5+b*0.3+ex, a*12-3, 0, 13);
              if(ex==1){
              CreateShotFromScript( "shot1",GetX()+cos(a*12-90)*20, GetY()+sin(a*12-90)*20, 2.5+b*0.3+ex, a*12+1, 0, 13);
              CreateShotFromScript( "shot1",GetX()+cos(a*12+90)*20, GetY()+sin(a*12+90)*20, 2.5+b*0.3+ex, a*12-1, 0, 13);
              }
              b++;
           }
           PlaySE(seshot2);
           wait(2-lv*1);
           a--;
        }
    }

    task Tshot20{
        yield;
        let a=0;
        loop(6){
           CreateEnemyFromScript("bit1", GetX, GetY, 0, 0, a);
           a++;
        }
    }
    task Tshot23a{
        yield;
        let a=0;
        while(GetCommonData("bossatack")==3){
           let b=0;
           let p=GetAngleToPlayer;
           loop(70-ex*30){
              if(phase<=0){return;}
              CreateShotFromScript( "shot1",GetX()+rand(20,-20), GetY()+rand(20,-20), 2.5+b*(0.1+ex*0.2), p, 0, 13);
              PlaySE(seshot1);
              wait(1);
              b++;
           }
           if(ex==0){wait(60-lv*50);}
           if(ex==1){wait(15-lv*15);}
           a++;
        }
    }
    task Tshot23b{
        yield;
        let c=0;
        while(GetCommonData("bossatack")==3){
           let a=0;
           let p1=atan2( GetPlayerY()-(GetY()-20), GetPlayerX()-(GetX()+100));
           let p2=atan2( GetPlayerY()-(GetY()-20), GetPlayerX()-(GetX()-100));
           loop(6+ex*4){
              if(phase<=0){return;}
              let b=0;
              loop(1){
                 CreateShotFromScript( "shot1",GetX()+100, GetY()-20, 3-a*0.03, p1+a*0.8+sin(c*73)*50, 0, 12);
                 CreateShotFromScript( "shot1",GetX()+100, GetY()-20, 3-a*0.03, p1-a*0.8+sin(c*73)*50, 0, 12);
                 CreateShotFromScript( "shot1",GetX()-100, GetY()-20, 3-a*0.03, p2+a*0.8+cos(c*113)*50, 0, 12);
                 CreateShotFromScript( "shot1",GetX()-100, GetY()-20, 3-a*0.03, p2-a*0.8+cos(c*113)*50, 0, 12);
                 b++;
              }
              wait(1);
              a++;
           }
           wait(10-lv*8);
           c++;
        }
    }
    task Tshot24{
        yield;
        let a=rand(0,10);
        while(GetCommonData("bossatack")==4){
           let b=0;
           let p=GetAngleToPlayer;
           loop(12){
              if(phase<=0){return;}
              CreateShotFromScript( "shot1",GetX()+90, GetY(), 5+ex-b*0.45, 90+sin(a*71)*20, 0, 13);
              CreateShotFromScript( "shot1",GetX()+60, GetY(), 5+ex-b*0.45, 90+sin(a*71+120)*20, 0, 13);
              CreateShotFromScript( "shot1",GetX()+30, GetY(), 5+ex-b*0.45, 90+sin(a*71+240)*20, 0, 13);
              CreateShotFromScript( "shot1",GetX()-30, GetY(), 5+ex-b*0.45, 90+sin(a*71+60)*20, 0, 13);
              CreateShotFromScript( "shot1",GetX()-60, GetY(), 5+ex-b*0.45, 90+sin(a*71+180)*20, 0, 13);
              CreateShotFromScript( "shot1",GetX()-90, GetY(), 5+ex-b*0.45, 90+sin(a*71+300)*20, 0, 13);
              PlaySE(seshot1);
              wait(2);
              if(ex==1){b++;}
           }
           wait(20-lv*20);
           a++;
        }
    }
    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 bit1 {
    let time = -60;
    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( 270 );
        SetInvincibility( 60 );
        LoadUserShotData( tama );
        Tmain;
    }
    @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(140,140,255);
        SetGraphicRect( 512, 96, 560, 144 );
        SetGraphicAngle( 0, 0, time*31);
	DrawGraphic( GetX(), GetY() );
    }
    task Tmain{
        yield;
        SetMovePosition02(GetCommonData("bossx")+cos(arg*60)*160, GetCommonData("bossy")+sin(arg*60)*80,60);
        wait(60);
        Tshot1;
        while(GetCommonData("bossatack")<2){
           SetX(GetCommonData("bossx")+cos(arg*60+time*1.6)*160);
           SetY(GetCommonData("bossy")+sin(arg*60+time*1.6)*80);
           yield;
        }
        Tshot2;
        while(GetCommonData("bossatack")==2){
           SetX(GetCommonData("bossx")+cos(arg*60+time*1.6)*160);
           SetY(GetCommonData("bossy")+sin(arg*60+time*1.6)*80);
           yield;
        }
        let r=arg*60+time*1.6;
        wait(40);
        SetAngle(90+cos(r)*70);
        SetSpeed(3);
        Tshot3(r);
        wait(300);
    }
    task Tshot1{
        yield;
        while(GetCommonData("bossatack")==1){
           if(phase==0||GetCommonData("bossphase")==0){return;}
           let p=atan2( GetPlayerY()-GetCommonData("bossy"), GetPlayerX()-GetCommonData("bossx"));
           let a=0;
           loop(1+ex){
              CreateShotFromScript( "shot1",GetX(), GetY(), 2.8+a*1.8-ex*0.9, p-sin(arg*60+time*1.6)*20, 0, 14);
              a++;
           }
           wait(10-lv*6);
        }
    }
    task Tshot2{
        yield;
        while(GetCommonData("bossatack")==2){
           let a=0;
           loop(55){
              if(phase==0||GetCommonData("bossphase")==0){return;}
              let p=GetAngleToPlayer;
              let b=0-ex;
              loop(1+ex*2){
                 CreateShotFromScript( "shot1",GetX(), GetY(), 4+a*0.09, p+b*23, 0, 02);
                 b++;
              }
              a++;
              PlaySE(seshot1);
              wait(1);
           }
           wait(20-lv*17);
        }
    }
    task Tshot3(let r){
        yield;
        while(GetY<480){
           if(phase==0||GetCommonData("bossphase")==0){return;}
           let p=atan2( GetPlayerY()-GetCommonData("bossy"), GetPlayerX()-GetCommonData("bossx"));
           let a=-ex;
           loop(1+ex*2){
              CreateShotFromScript( "shot3",GetX(), GetY(), 0.035, 90-cos(r)*40+a*20, 0, 06);
              a++;
           }
           wait(13-lv*8);
        }
    }

    #include_function".\efanction.txt"
}
    script_shot shota{
       let out=false;
       let gr=13;
       let arg=GetArgument;
       let lv=0;
       let time=0;
       let phase=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.02)}
          }
          else{lv=0}
          SetDefault(gr+lv*20);
          if(GetSpeed>0&&phase==0){SetSpeed(GetSpeed-0.1);}
          if(GetSpeed<=0){phase=1;SetAngle(GetAngle+arg)}
          if(phase==1){SetSpeed(GetSpeed+0.1);}
          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"