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\zakoair2.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se10 = GetCurrentScriptDirectory~"wav\se10.wav";
   @Initialize(){
       SetLife( 106 );
       SetInvincibility( 6 );
   	 SetSpeed(5.5);
       LoadGraphic( imgEnemy );
       LoadUserShotData( tama );
   	if(arg==99){Tserchx;}
   	else{Tserch;}
       Tshot1;
   }
   @MainLoop {
       if(phase==1&&GetLife<=100){
          phase-=1;
          if(lv==0||GetPoint>0){DeleteEnemyShotImmediatelyInCircle(SHOT, GetX, GetY, 24);}
          PlaySE(se10);
          Tdeath(2,24,2,1);
       }
       if(time>240&&GetY>500){VanishEnemy;}
       if(time>1000){VanishEnemy;}
       if(phase>=1){
          SetCollisionA(GetX, GetY, 24);
          SetCollisionB(GetX, GetY, 16);
       }
       if(GetCommonData("kakusei")>0){lv=1}
       else{lv=0}
       time++;
   	
       yield;
   }
   @Finalize() {
   }
   @DrawLoop {
	SetTexture( imgEnemy );
       SetGraphicRect( 0, 0, 48, 48 );
       SetGraphicAngle(0,0,angle+90);
	DrawGraphic( GetX(), GetY());
   }

   /*task Tshot1{
      loop{
         if(phase<=0){return;}
         SetShotDirectionType(ABSOLUTE);
         let p=GetAngleToPlayer;
         let a=-1-ex;
         loop(3+ex*2){
            CreateShotFromScript( "shot1",GetX(), GetY(), 2.4, p+a*30, 0, 06);
         	a++;
         }
       	wait(3-lv);
      }
   }*/
   task Tshot1{
      loop{
         if(phase<=0){return;}
         if(GetX>0&&GetX<448&&GetY>0&&GetY<480){
         	SetShotDirectionType(ABSOLUTE);
      		let p=genteikaku(GetAngleToPlayer,24);
      		//let p=GetAngleToPlayer;
         	CreateShotFromScript( "shot1",GetX(), GetY(), 3.2+ex, p-5, 0, 06);
         	CreateShotFromScript( "shot1",GetX(), GetY(), 3.2+ex, p+5, 0, 06);
         	//CreateShotFromScript( "shot3",GetX(), GetY(), 0.05, p, 0, 06);
         	if(ex==1){
         		CreateShotFromScript( "shot3",GetX(), GetY(), 0.05, p, 0, 06);
         	}
      	}
       	wait(3-lv);
      }
   }
   task Tserch {
      yield;
      loop(100){
         let a=GetAngleToPlayer()-angle;
         if((a>0&&a<=180)||(a<0&&a<=-180)){angle+=2;}
         else if((a>0&&a>180)||(a<0&&a>-180)){angle-=2;}
         if(angle>=360){angle-=360;}
         if(angle<0){angle+=360;}
         SetAngle(angle);
         yield;
      }
      wait(120);
      VanishEnemy();
   }
   task Tserchx {
      yield;
      loop(100){
         let a=GetAngleToPlayer()-angle;
         if((a>0&&a<=180)||(a<0&&a<=-180)){angle+=6;}
         else if((a>0&&a>180)||(a<0&&a>-180)){angle-=6;}
         if(angle>=360){angle-=360;}
         if(angle<0){angle+=360;}
         SetAngle(angle);
         yield;
      }
      wait(120);
      VanishEnemy();
   }


   #include_function".\efanction.txt"
}

#include_script".\escript.txt"