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\senkan2.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
   @Initialize(){
      SetLife( 550 );
      SetInvincibility( 60 );
      LoadGraphic( imgEnemy );
      LoadUserShotData( tama );
      SetX(mapx-GetCommonData("bgx"));
      SetY(GetCommonData("bgy")-mapy);
		Tshot;
   }
   @MainLoop {
       if(time==1){
          CreateEnemyFromScript( "dodai", mapx, mapy, 0, 0, 0);
          CreateEnemyFromScript( "parts2", mapx+70, mapy+110, rank, 0, 0);
          CreateEnemyFromScript( "parts2", mapx-70, mapy+110, rank, 0, 0);
          CreateEnemyFromScript( "parts1", mapx+80, mapy-30, rank, 0, 0);
          CreateEnemyFromScript( "parts1", mapx-80, mapy-30, rank, 0, 0);
       }
       if(phase==1&&GetLife<=100){
          phase-=1;
          VanishEnemy;
       }
       if(GetX<12||GetX>436||GetY<60){
          SetInvincibility( 5 );
       }
       if(time>1010){VanishEnemy;}
      if(phase>=1){SetCollisionA(GetX, GetY-60, 48);}
       SetX(mapx-GetCommonData("bgx"));
       SetY(GetCommonData("bgy")-mapy);
       if(GetCommonData("kakusei")>0){lv=1}
       else{lv=0}
       time++;
       yield;
   }
   @Finalize() {
   }
   @DrawLoop {
   }

   task Tshot{
      yield;
      loop{
         if(GetX>48&&GetX<400&&GetY>16&&GetY<(300+rank*20)){
            let p=genteikaku(atan2( GetPlayerY()-(GetY()-60), GetPlayerX()-(GetX())),32);
            let a=0;
            loop(40){
            	let b=-2;
            	loop(5+ex*2){
               	if(phase<=0){return;}
               	CreateShotFromScript( "shot1",GetX()+5, GetY()-60, 3.5+a*0.25+ex, p+b*(35-10*ex), 0, 13);
               	CreateShotFromScript( "shot1",GetX()-5, GetY()-60, 3.5+a*0.25+ex, p+b*(35-10*ex), 0, 13);
            		b++;
            	}
               a++;
         		wait(2-lv*1);
            }
         }
         wait(30-lv*29);
      }
   }
   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\senkan2.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
   @Initialize(){
       SetLife( 180 );
       SetInvincibility( 10 );
       LoadUserShotData( tama );
       SetX(mapx-GetCommonData("bgx"));
       SetY(GetCommonData("bgy")-mapy);
       Tshot;
   }
   @MainLoop {
   	if(BeParentVanished==true){
   		VanishEnemy();
   	}
       if(phase==1&&GetLife<=100){
          phase-=1;
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 30);}
          PlaySE(se3);
          Tdeath(4,24,2,1);
       }
       if(GetX<12||GetX>436||GetY<40){
          SetInvincibility( 5 );
       }
       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 {
	SetTexture( imgEnemy );
       SetGraphicRect( 384, 80, 464, 144 );
	DrawGraphic( GetX(), GetY() );
   }

   task Tshot{
      yield;
      loop{
         if(GetX>32&&GetX<416&&GetY>16&&GetY<(300+rank*20)){
            let p=genteikaku(GetAngleToPlayer(),32);
            let a=0;
            loop(7){
            	let b=-1-ex;
            	loop(3+ex*2){
               	if(phase<=0){return;}
               	CreateShotFromScript( "shot1",GetX(), GetY(), 3+ex, p+b*(20-ex*8), 0, 05);
            		b++;
            	}
               a++;
         		wait(4-lv*2);
            }
         }
         wait(30-lv*15);
      }
   }


   #include_function".\efanction.txt"
}
script_enemy parts2 {
   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\senkan2.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
   @Initialize(){
       SetLife( 180 );
       SetInvincibility( 10 );
       LoadUserShotData( tama );
       SetX(mapx-GetCommonData("bgx"));
       SetY(GetCommonData("bgy")-mapy);
       Tshot;
   }
   @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>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 {
	SetTexture( imgEnemy );
      SetGraphicRect( 384, 0, 480, 80 );
      SetGraphicAngle(0,0,0);
	DrawGraphic( GetX(), GetY() );
   }

   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;
            loop(5+rank){
               if(phase<=0){return;}
               let b=-1-ex;
               loop(24){
                  CreateShotFromScript( "shot6",GetX(), GetY(), 3, b*15, 0, 05);
                  b++;
               }
               a++;
               wait(3-lv*1);
            }
         }
         wait(60-lv*50);
      }
   }


   #include_function".\efanction.txt"
}

script_enemy dodai {
   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\senkan2.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
   let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
   @Initialize(){
       SetLife( 400 );
       SetInvincibility( 60 );
       LoadUserShotData( tama );
       SetX(mapx-GetCommonData("bgx"));
       SetY(GetCommonData("bgy")-mapy);
       Tgazou(1,1,384,288);
   }
   @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 Tgazou(x1,y1,x2,y2)
   {
      let system = GetCurrentScriptDirectory~"img\system.png";
      let objenemy = Obj_Create(OBJ_EFFECT);//GtFNgIuWFNg쐬
      ObjEffect_SetTexture(objenemy, imgEnemy);//Ȃ炩̃eNX`ݒ
      ObjEffect_SetPrimitiveType(objenemy, PRIMITIVE_TRIANGLESTRIP);//v~eBu^Cvݒ
      ObjEffect_CreateVertex(objenemy, 4);//_4
      ObjEffect_SetLayer(objenemy,layer);
		
      //lp`Ɋe_̍Wݒ
      ObjEffect_SetVertexXY(objenemy, 0, -(x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 1, -(x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 2,  (x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
      ObjEffect_SetVertexXY(objenemy, 3,  (x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
		
      //lp`Ɋe_UVlݒB(0,0)-(10,10)̕B
      ObjEffect_SetVertexUV(objenemy, 0, x1, y1);
      ObjEffect_SetVertexUV(objenemy, 1, x1, y2);
      ObjEffect_SetVertexUV(objenemy, 2, x2, y1);
      ObjEffect_SetVertexUV(objenemy, 3, x2, y2);

      Obj_SetPosition(objenemy, GetX, GetY);
   
		
      loop{
         ObjEffect_SetVertexXY(objenemy, 0, -(x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 1, -(x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 2,  (x2-x1)*bairitu/2, -(y2-y1)*bairitu/2);
         ObjEffect_SetVertexXY(objenemy, 3,  (x2-x1)*bairitu/2,  (y2-y1)*bairitu/2);
         Obj_SetX(objenemy,GetX);
         Obj_SetY(objenemy,GetY);
         yield;
      }
      Obj_Delete(objenemy);
   }
   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(se2);
      VanishEnemy();
   }


    #include_function".\efanction.txt"
}

#include_script".\escript.txt"