script_enemy_main {
    let time = 0;
    let phase = 1;
    let rate = 10;
    let kaku = 40;
    let score = 5000;
    let layer = 1;
    let bairitu = 1;
    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\senkan1.png";
    let tama = GetCurrentScriptDirectory~"tama.txt";
    let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
    let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
    @Initialize(){
        SetLife( 450 );
        SetInvincibility( 60 );
        LoadGraphic( imgEnemy );
        LoadUserShotData( tama );
        SetX(mapx-GetCommonData("bgx"));
        SetY(GetCommonData("bgy")-mapy);
    }
    @MainLoop {
        if(time==1){
           CreateEnemyFromScript( "dodai", mapx, mapy, 0, 0, 0);
           CreateEnemyFromScript( "parts3", mapx, mapy-100, rank, 0, 0);
           CreateEnemyFromScript( "parts1", mapx+55, mapy-50, rank, 0, 0);
           CreateEnemyFromScript( "parts1", mapx-55, mapy-50, rank, 0, 0);
           CreateEnemyFromScript( "parts3", mapx, mapy+10, rank, 0, 0);
           CreateEnemyFromScript( "parts1", mapx+55, mapy+50, rank, 0, 0);
           CreateEnemyFromScript( "parts1", mapx-55, mapy+50, rank, 0, 0);
           //CreateEnemyFromScript( "parts3", mapx, mapy+60, rank, 0, 0);
           CreateEnemyFromScript( "parts1", mapx+95, mapy+125, rank, 0, 0);
           CreateEnemyFromScript( "parts1", mapx-95, mapy+125, rank, 0, 0);
        }
        if(phase==1&&GetLife<=100){
           phase-=1;
           VanishEnemy;
        }
        if(GetX<12||GetX>436||GetY<140){
           SetInvincibility( 5 );
        }
        if(time>1010){VanishEnemy;}
       if(phase>=1){SetCollisionA(GetX, GetY-120, 48);}
        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"
}
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\senkan1.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;
		Tgazou(256, 80, 336, 144);
   	layer = 1;
   }
   @MainLoop {
   	if(BeParentVanished==true){
   		VanishEnemy();
   	}
       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>1000){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;
      wait(40+GetCommonData("ransu")%4*10);
      SetCommonData("ransu",GetCommonData("ransu")+1);
      loop{
         if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)){
            let p=genteikaku(GetAngleToPlayer(),40);
            let a=-0.5;
            loop(2+ex){
               if(phase<=0){return;}
               CreateShotFromScript( "shot1",GetX(), GetY(), 2.5+ex, p+a*20, 0, 06);
               a++;
            }
         }
         wait(8-rank*4);
      }
   }


   #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(BeParentVanished==true){
   		VanishEnemy();
   	}
      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>1000){VanishEnemy;}
      if(phase>=1){SetCollisionA(GetX, GetY, 32);}
      SetX(mapx-GetCommonData("bgx"));
      SetY(GetCommonData("bgy")-mapy);
      if(GetCommonData("kakusei")>0){lv=1}
      else{lv=0}
      time++;
      yield;
   }
   @Finalize() {
   }
   @DrawLoop {
   }

   task Tshot{
      yield;
      let a=0;
      loop{
         if(GetY>16&&GetY<(300+rank*20)){
         	loop(6){
            	let b=-1.5-ex;
            	loop(4+rank*2){
            	   if(phase<=0){return;}
            	   CreateShotFromScript( "shot1",GetX(), GetY(), 2.6+ex, 90+b*40, 0, 13);
         	      b++;
            	}
         		wait(3);
         	}
         }
         a++;
         wait(30-lv*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\senkan1.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
   @Initialize(){
       SetLife( 180 );
       SetInvincibility( 10 );
       LoadGraphic( imgEnemy );
       LoadUserShotData( tama );
       SetX(mapx-GetCommonData("bgx"));
       SetY(GetCommonData("bgy")-mapy);
       Tshot;
		Tgazou(256, 0, 352, 80 );
   	layer = 1;
   }
   @MainLoop {
   	if(BeParentVanished==true){
   		VanishEnemy();
   	}
      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>1000){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=0;
         	let p=genteikaku(GetAngleToPlayer,32);
            loop(8+rank){
               if(phase<=0){return;}
               let b=-1-ex;
               loop(3+ex*2){
                  CreateShotFromScript( "shot1",GetX()+3, GetY(), 3.5+ex, p+b*(30-ex*6), 0, 11);
                  CreateShotFromScript( "shot1",GetX(), GetY(), 3.5+ex, p+b*(30-ex*6), 0, 11);
                  CreateShotFromScript( "shot1",GetX()-3, GetY(), 3.5+ex, p+b*(30-ex*6), 0, 11);
                  b++;
               }
               a++;
               wait(4-lv*1);
            }
         }
         wait(40-lv*30);
      }
   }


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

script_enemy dodai {
   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\senkan1.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
   let se9 = GetCurrentScriptDirectory~"wav\se9.wav";
   @Initialize(){
		SetLife( 400 );
		SetInvincibility( 60 );
		LoadGraphic( imgEnemy );
		LoadUserShotData( tama );
		SetX(mapx-GetCommonData("bgx"));
		SetY(GetCommonData("bgy")-mapy);
		Tgazou(1,1,256,368);
   	layer = 0;
   }
   @MainLoop {
      if(BeParentVanished==true&&phase==1){
         phase-=1;
         Tdeath(12,70,1,0);
         Tbaku;Toti;
      }
      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;
      }
   }
   task Toti{
      layer=1;
      let a=0;
      loop(80){
         if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, 224, 240, 600);}
         if(a%10==0){
        		PlaySE(se3);
         }
         bairitu=1-a/80*0.3;
         a++;
         yield;
      }
      Explosion01(GetX,GetY,4,0.2,50);
      PlaySE(se9);
      VanishEnemy();
   }


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

#include_script".\escript.txt"