script_enemy_main {
   let time = 0;
   let phase = 1;
   let rate = 1;
   let kaku = 10;
   let score = 80;
   let lv = 0;
   let angle = GetAngle();
   let rank = GetSpeed();
   let arg = GetArgument();
   let ex = GetCommonData("ex");
   let imgEnemy = GetCurrentScriptDirectory~"img\zakoheli3.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se10 = GetCurrentScriptDirectory~"wav\se10.wav";
   @Initialize(){
       SetLife( 110 );
       SetInvincibility( 20 );
       SetSpeed(3.3);
       LoadGraphic( imgEnemy );
       LoadUserShotData( tama );
       Tmove;Tshot1;
   }
   @MainLoop {
       if(phase==1&&GetLife<=100){
          phase-=1;
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 25);}
          PlaySE(se10);
          Tdeath(2,24,2,1);
       }
       if(time>240&&GetY>500){VanishEnemy;}
       if(time>1000){VanishEnemy;}
       if(phase>=1&&GetY>-20){
          SetCollisionA(GetX, GetY, 24);
          SetCollisionB(GetX, GetY, 16);
       }
       if(GetCommonData("kakusei")>0){lv=1}
       else{lv=0}
       time++;
       yield;
   }
   @Finalize() {
   }
   @DrawLoop {
	SetTexture( imgEnemy );
       SetGraphicRect( 1, 1, 48, 48 );
       SetGraphicAngle(0,30,angle-90);
	DrawGraphic( GetX()-cos(angle)*6, GetY()-sin(angle)*6 );
       SetGraphicRect( 48, 0, 96, 48 );
       SetGraphicAngle(0,30,-time*17);
	DrawGraphic( GetX()-cos(angle)*15, GetY()-sin(angle)*15 );
   }

   task Tshot1{
      yield;
      loop(30){angle=GetAngleToPlayer;yield;}
      loop{
         if(phase<=0){return;}
         if(GetY>0){
         	let p=genteikaku(GetAngleToPlayer,24);
         	loop(7+rank*2+ex*2){
            	SetShotDirectionType(ABSOLUTE);
            	CreateShotFromScript( "shot1",GetX()+cos(p+47)*22, GetY()+sin(p+47)*22, 3.2+ex, angle, 0, 11);
            	CreateShotFromScript( "shot1",GetX()+cos(p-47)*22, GetY()+sin(p-47)*22, 3.2+ex, angle, 0, 11);
         		wait(2);
         	}
         }
      	loop(40-lv*30){angle=GetAngleToPlayer;yield;}
      }
   }
   task Tmove{
       yield;
       SetMovePosition03( GetX()+cos(GetAngle)*200, GetY()+sin(GetAngle)*200, 30, 4);
       loop(150) { yield; }
       SetMovePosition01( GetX(), -20, 2);
       loop(120) { yield; }
       VanishEnemy();
   }



   #include_function".\efanction.txt"
}

#include_script".\escript.txt"