script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 10;
    let kaku = 40;
    let score = 5000;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\train.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 1100 );
        SetInvincibility( 60 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tgazou(1,1,144,288);
   	layer = 0;
    }
    @MainLoop {
        if(time==1){
           if(arg==1){
           CreateEnemyFromScript( "parts2", mapx, mapy-90, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx+24, mapy-30, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx-24, mapy-30, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx+24, mapy+30, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx-24, mapy+30, rank, 0, 1);
           CreateEnemyFromScript( "parts3", mapx, mapy+90, rank, 0, 1);
           }
           if(arg==2){
           CreateEnemyFromScript( "parts1", mapx+24, mapy-80, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx-24, mapy-80, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx+24, mapy-20, rank, 0, 1);
           CreateEnemyFromScript( "parts1", mapx-24, mapy-20, rank, 0, 1);
           CreateEnemyFromScript( "parts3", mapx, mapy+40, rank, 0, 1);
           }
           if(arg==3){
           CreateEnemyFromScript( "parts5", mapx, mapy+55, rank, 0, 1);
           CreateEnemyFromScript( "parts5", mapx, mapy-55, rank, 0, 1);
           }
           if(arg==4){
              let a=-1.5;
              loop(4){
              CreateEnemyFromScript( "parts4", mapx-22, mapy+a*60, rank, 0, 1);
              CreateEnemyFromScript( "parts4", mapx+22, mapy+a*60, rank, 0, 1);
              a++;
              }
           }
        }
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);}
           PlaySE(se2);
           Tdeath(16,70,2,0);
        }
        if(GetX-60<12||GetX-60>436||GetY<140){
           SetInvincibility( 5 );
        }
        if(time>1000){VanishEnemy;}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }


   task setmove(a,t) {
      loop(t) {
         mapx+=cos(a)*0.6;mapy-=sin(a)*0.6;
         yield;
      }
   }

    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}
script_enemy parts1 {
    let time = 0;
    let phase = 1;
    let rate = 2;
    let kaku = 10;
    let score = 180;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\train.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se8 = GetCurrentScriptDirectory~"wav\se8.wav";
    @Initialize(){
        SetLife( 115 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot;
		Tgazou3(144, 0, 208, 64,24);
   	layer = 1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 30);}
           PlaySE(se8);
           Tdeath(4,24,2,1);
        }
        if(GetX<12||GetX>436||GetY<40){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1600){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 24);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

    task Tshot{
        yield;
        SetCommonData("ransu",GetCommonData("ransu")+1);
        wait(40+GetCommonData("ransu")%4*10);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)&&(GetX-GetPlayerX)^2+(GetY-GetPlayerY)^2>150^2){
              let p=genteikaku(GetAngleToPlayer(),48);
              let a=0;
              loop(3+rank/2){
                 if(phase<=0){return;}
                 CreateShotFromScript( "shot1",GetX()+cos(p+9)*22, GetY()+sin(p+9)*22, 3-a*0.10+ex, p+(a*0.7)*ex, 0, 14);
                 CreateShotFromScript( "shot1",GetX()+cos(p-9)*22, GetY()+sin(p-9)*22, 3-a*0.10+ex, p-(a*0.7)*ex, 0, 14);
                 if(ex==1){
                    CreateShotFromScript( "shot1",GetX()+cos(p+9)*22, GetY()+sin(p+9)*22, 3.2-a*0.10+ex, p+a*0.7, 0, 14);
                    CreateShotFromScript( "shot1",GetX()+cos(p-9)*22, GetY()+sin(p-9)*22, 3.2-a*0.10+ex, p-a*0.7, 0, 14);
                 }
                 a++;
              }
           }
           if(lv==0){wait(45-rank*6);}
           wait(12);
        }
    }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}
script_enemy parts2 {
    let time = 0;
    let phase = 1;
    let rate = 4;
    let kaku = 10;
    let score = 180;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\train.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se8 = GetCurrentScriptDirectory~"wav\se8.wav";
    @Initialize(){
        SetLife( 200 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot;
		Tgazou(144, 64, 224, 96);
   	layer = 1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 40);}
           PlaySE(se8);
           Tdeath(6,24,2,1);
        }
        if(GetX<12||GetX>436||GetY<40){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1600){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX+22, GetY, 24);SetCollisionA(GetX-22, GetY, 24);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

    task Tshot{
        yield;
        wait(40+GetCommonData("ransu")%4*10);
        SetCommonData("ransu",GetCommonData("ransu")+1);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)){
              let a=0;
              loop(5+rank){
                 if(phase<=0){return;}
                 let b=-ex;
                 loop(1+ex*2){
                    CreateShotFromScript( "shot1",GetX()+25, GetY()+15, 2.6+ex, 90, 0, 13);
                    CreateShotFromScript( "shot1",GetX()-25, GetY()+15, 2.6+ex, 90, 0, 13);
                    b++;
                 }
                 a++;
                 wait(4);
              }
           }
           if(lv==0){wait(23-rank*4);}
           wait(15);
        }
    }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}
script_enemy parts3 {
    let time = 0;
    let phase = 1;
    let rate = 7;
    let kaku = 10;
    let score = 180;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\train.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 230 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot;
		Tgazou(144, 112, 208, 160);
   	layer = 1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 40);}
           PlaySE(se2);
           Tdeath(8,32,2,1);
        }
        if(GetX<12||GetX>436||GetY<40){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1600){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 40);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

    task Tshot{
        yield;
        SetCommonData("ransu",GetCommonData("ransu")+1);
        wait(40+GetCommonData("ransu")%4*10);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)){
              let a=3+ex*2;
              let p=genteikaku(GetAngleToPlayer(),32);
              loop(3){
                 if(phase<=0){return;}
                 let b=-a/2;
                 loop(a+1){
                    CreateShotFromScript( "shot1",GetX(), GetY(), 2.6+ex, p+b*(15.4-ex*5), 0, 06);
                    CreateShotFromScript( "shot1",GetX(), GetY(), 2.66+ex, p+b*(15.2-ex*5), 0, 06);
                    CreateShotFromScript( "shot1",GetX(), GetY(), 2.72+ex, p+b*(15-ex*5), 0, 06);
                    b++;
                 }
                 a++;
                 wait(28-lv*20);
              }
           }
           if(lv==0){wait(23-rank*4);}
           wait(15);
        }
    }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}
script_enemy parts4 {
    let time = 0;
    let phase = 1;
    let rate = 3;
    let kaku = 10;
    let score = 180;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\train.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
    @Initialize(){
        SetLife( 125 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
		Tgazou( 208, 0, 272, 64 );
   	layer = 1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 30);}
           PlaySE(se3);
           Tdeath(4,28,2,1);
        }
        if(GetX<12||GetX>436||GetY<40){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1600){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 24);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}
script_enemy parts5 {
    let time = 0;
    let phase = 1;
    let rate = 4;
    let kaku = 10;
    let score = 180;
    let lv = 0;
    let angle = GetAngle();
    let rank = GetSpeed();
    let arg = GetArgument();
    let ex = GetCommonData("ex");
    let mapx = GetX();
    let mapy = GetY();
    let imgEnemy = GetCurrentScriptDirectory~"img\train.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 230 );
        SetInvincibility( 10 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        Tshot;
		Tgazou( 144, 208, 208, 256 );
		Tgazou3( 144, 160, 240, 208 ,32);
   	layer = 1;
    }
    @MainLoop {
        if(phase==1&&GetLife<=100){
           phase-=1;
           if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 40);}
           PlaySE(se2);
           Tdeath(6,35,2,1);
        }
        if(GetX<12||GetX>436||GetY<40){
           SetInvincibility( 5 );
        }
        if(time>240&&GetY>500){VanishEnemy;}
        if(time>1600){VanishEnemy;}
        if(phase>=1){SetCollisionA(GetX, GetY, 40);}
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
        if(GetCommonData("kakusei")>0){lv=1}
        else{lv=0}
        time++;
        yield;
    }
    @Finalize() {
    }
    @DrawLoop {
    }

    task Tshot{
        yield;
        wait(20+GetCommonData("ransu")%4*20);
        SetCommonData("ransu",GetCommonData("ransu")+1);
        loop{
           if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)){
              if(phase<=0){return;}
              let p=genteikaku(GetAngleToPlayer(),32);
              let a=0;
              loop(6+ex*2){
                 let b=0;
                 loop(1+a*5){
                    let c=atan2(sin(b)*(2*a),100+cos(b)*(2*a));
                    CreateShotFromScript( "shot1",GetX()+cos(p)*30, GetY()+sin(p)*30, (3.2+cos(b)*((0.065+ex*0.02)*a)+ex)/cos(c), p+c, 0, 06);
                    b+=360/(1+a*5);
                 }
                 a++;
              }
           }
           if(lv==0){wait(50-rank*6);}
           wait(18);
        }
    }


    #include_function".\efanction.txt"
    #include_function".\effobj.txt"
}
#include_script".\escript.txt"