script_enemy_main {
   let time = 0;
   let rate = 1;
   let phase = 1;
   let score =1200;
   let angle = 90;
   let rank = GetSpeed;
   let ex = 0;
   let arg = GetArgument();
   let imgEnemy = GetCurrentScriptDirectory~"img\dot__yousei_r.png";
   let imgmahou = GetCurrentScriptDirectory~"img\kdm_seal001.png";
   let tama = GetCurrentScriptDirectory~"tama.txt";
   let se1 = GetCurrentScriptDirectory~"wav\se1.wav";
   let se2 = GetCurrentScriptDirectory~"wav\se2.wav";
   let seshot1 = GetCurrentScriptDirectory~"wav\shot1.wav";
   @Initialize(){
      SetLife( 500 );
      SetInvincibility(60);
      LoadUserShotData( tama );
      SetSpeed(5);
      Tshot1;
      Tmove;
   	if(GetCommonData("ex")==1){ex=1;}
   }
   @MainLoop {
      if(phase==1&&GetLife<=100){
         phase-=1;
         PlaySE(se2);
         Tdeath(10,64,3,20);
      	if(ex==1){
            let p=GetAngleToPlayer;
            SetShotDirectionType(ABSOLUTE);
      		let a=-1.5;
      		loop(4){
            	CreateShot02( GetX(), GetY(), 0, p+a*8, 0.2, 10, ORANGE02, 0);
      			a++;
      		}
      	}
      }
      if(phase>=1){
      SetCollisionA(GetX, GetY, 20);
      SetCollisionA(GetX+30, GetY+10, 20);
      SetCollisionA(GetX-30, GetY+10, 20);
      }
      yield;
      time++;
   }
   @Finalize() {
   }
   @DrawLoop {
	SetTexture( imgEnemy );
       SetGraphicRect( 0, 0, 32, 32 );
       SetGraphicAngle(0,0,angle-90);
	DrawGraphic( GetX(), GetY() );
	SetTexture( imgmahou );
       SetGraphicRect( 0, 0, 32, 32 );
       SetGraphicAngle(0,0,angle-90);
	DrawGraphic( GetX()+30, GetY()+10 );
	DrawGraphic( GetX()-30, GetY()+10 );
   }

   task Tshot1{
      yield;
      wait(80);
      loop{
			loop(3){
         	if(phase<1){return;}
				let a=0-ex/2;
				loop(1+ex*2){
         		SetShotDirectionType(ABSOLUTE);
         		CreateShot01( GetX()+30, GetY(), 4.5+ex*2, 80+a*20, ORANGE04, 0);
         		CreateShot01( GetX()-30, GetY(), 4.5+ex*2, 100+a*20, ORANGE04, 0);
					a++;
				}
				wait(10);
      	}
      	wait(30);
      	let a=0;
      	loop(2+ex*2){
         	if(phase<1){return;}
         	SetShotDirectionType(ABSOLUTE);
      		let b=-(a%2)/2;
        		loop(a%2+1){
           		CreateShot01( GetX(), GetY(), 6.5+ex*3, genteikaku(GetAngleToPlayer,40)+b*13, WHITE04, 0);
        			b++;
        		}
         	PlaySE(seshot1);
         	wait(15-ex*5);
        		a++;
      	}
      	wait(50);
		}
	}

  task Tmove {
     SetMovePosition02(224-100*arg,GetY-30,80);
     wait(80);
     SetMovePosition02(224-60*arg,GetY+10,100);
     wait(100);
     SetMovePosition02(224-100*arg,GetY,100);
     wait(100);
     SetMovePosition02(224-60*arg,GetY-10,100);
     wait(100);
     SetMovePosition02(224-100*arg,GetY,100);
     wait(100);
     SetMovePosition02(224-60*arg,GetY-10,100);
     wait(100);
     SetMovePosition02(224-100*arg,GetY,100);
     wait(100);
     SetMovePosition02(224-260*arg,GetY-30,80);
     wait(80);
     VanishEnemy();
  }


   #include_function".\efanc.txt"
}
