script_enemy_main {
   let time = 0;
   let rate = 1;
   let phase = 1;
   let score =200;
   let angle = 90;
   let ex = 0;
   let rank = GetSpeed;
   let arg = GetArgument();
   let imgEnemy = GetCurrentScriptDirectory~"img\dot__yousei_g.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se3 = GetCurrentScriptDirectory~"wav\se3.wav";
   @Initialize(){
      SetLife( 130 );
      SetInvincibility( 10 );
      LoadGraphic( imgEnemy );
      LoadUserShotData( tama );
      SetSpeed(3);
      SetAngle(90);
   	Tshot1;
   	alternative(arg)
   	case(1){Tmove1;imgEnemy = GetCurrentScriptDirectory~"img\dot__yousei_g.png";}
   	case(2){Tmove2;imgEnemy = GetCurrentScriptDirectory~"img\dot__yousei_b.png";}
   	case(3){Tmove3;imgEnemy = GetCurrentScriptDirectory~"img\dot__yousei_y.png";}
   	
   	if(GetCommonData("ex")==1){ex=1;rank+=2;}
   }
   @MainLoop {
      if(phase==1&&GetLife<=100){
         phase-=1;
         PlaySE(se3);
         Tdeath(1,24,2,30);
      	if(ex==1){
      		let p=GetAngleToPlayer+rand(-5,5);
            SetShotDirectionType(ABSOLUTE);
      		let r=rand_int(0,1)-0.5;
      		let a=0;
      		loop(rand(0.5,1.2)){
            	CreateShot01( GetX(), GetY(), 5+rank/2, p+a*(40*r), ORANGE01, 0);
      			a++;
      		}
      	}
      }
      if(phase>=1){
      SetCollisionA(GetX, GetY, 24);
      }
      yield;
      time++;
   }
   @Finalize() {
   }
   @DrawLoop {
	SetTexture( imgEnemy );
      SetGraphicRect( 1, 1, 32, 32 );
      SetGraphicAngle(0,0,angle-90);
	DrawGraphic( GetX(), GetY() );
   }

   task Tshot1{
      yield;
      wait(20);
      loop{
         if(phase<1){return;}
         if(GetX>32&&GetX<416&&GetY>16&&GetY<464){
            let p=GetAngleToPlayer;
            SetShotDirectionType(ABSOLUTE);
            CreateShot01( GetX(), GetY(), 5+rank/2, genteikaku(p,32), ORANGE01, 0);
         }
         wait(90-rank*10-ex*20);
      }
   }

   task Tmove1 {
      SetSpeed(3);
      yield;
   	let r=1;
   	wait(80);
   	if(GetX<224){r=-1;}
   	loop(60){
   		SetAngle(GetAngle+r*3);
   		yield;
   	}
   	wait(80);
      VanishEnemy();
   }
	
	task Tmove2 {
		SetSpeed(4);
      yield;
   	wait(60);
   	let r=1;
   	if(GetX>224){r=-1;}
   	SetAngle(90+r*150);
   	wait(60);
      VanishEnemy();
   }
	task Tmove3 {
   	let r=1;
   	if(GetX>224){r=-1;}
   	SetAngle(90-r*120);
		SetSpeed(4.7);
      yield;
		loop(60){
   		SetAngle(GetAngle() + r*2);
			SetSpeed(GetSpeed() - 0.03);
      	yield;
		}
   	SetAngle(270);
		SetSpeed(3);
   	wait(90);
      VanishEnemy();
   }



   #include_function".\efanc.txt"
}
