script_enemy_main{
    #include_script".\function_bullet.txt"
        let csd = GetCurrentScriptDirectory;
	let Enemy=csd~"img\dot-kaze-ti.png";
        let shotData = csd ~ "data_usershot.txt";
        let gx = GetX;
        let gy = GetY;
        let gspeed = GetSpeed;
        let gangle = GetAngle;
        let arg = GetArgument;
        let se1 = csd~ "bgm\tm2_gun002.wav";
        let se2 = csd~ "bgm\tm2_coin000.wav";
        let se3 = csd~ "bgm\tm2_alchemist000.wav";
  let dif = GetCommonData("Dif");
	@Initialize
	{
            if(GetPlayerType == REIMU_A){SetLife(10);}
            else{SetLife(10);}
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
		SetGraphicRect(70,60,90,100);	
      /*   SetMovePosition02(GetClipMinX,GetY,60);  */
          SetInvincibility(60);
          LoadSE(se1);LoadSE(se2);LoadSE(se3);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),18);
		SetCollisionB(GetX(),GetY(),12);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
         if(!BeVanished){
             AddScore(100);
         loop(12){ 
             CreateItem(ITEM_SCORE,GetX+offsetX(32,rand(-180,180)),GetY+offsetY(32,rand(-180,180)));
             }
          }
	}

         task Main{
             yield; 
       Move; 
        if(dif == 1){Shot;}
    else if(dif == 2){Shot2;}
     }

     task Shot{
     wait(60);
          let v = 1;
          let color = 172;
          let delay = 20;
         let way = 36;
          let x = GetX;
          let y = GetY;
          let accel = 0.03;
    ascent(a in 0..way){
      let angle = GetAngleToPlayer+360/way*a;
        CreateShot02(x,y,v,angle,accel,rand(1,5),color,delay);
       }
         PlaySE(se1);
      }
          
    task Shot2{
     wait(60);
          let v = -1;
          let color = 181;
          let delay = 20;
         let way = 24;
          let x = GetX;
          let y = GetY;
          let accel = 0.01;
        let grvAngle = 90;
    ascent(a in 0..way){
      let angle = GetAngleToPlayer+360/way*a;
          GravityShot(x,y,v,angle,accel,grvAngle,color,delay);
       }
         PlaySE(se1);
      }

     task Move{
    if(arg == 0){
     SetMovePosition02(GetClipMinX+60,GetClipMinY+120,60);
      }
     else if(arg == 1){
     SetMovePosition02(GetClipMaxX-60,GetClipMinY+120,60);
      }
     else if(arg == 2){
     SetMovePosition02(GetClipMinX+120,GetClipMinY+30,60);
      }
     else if(arg == 3){
     SetMovePosition02(GetClipMaxX-120,GetClipMinY+30,60);
      }
     else if(arg == 4){
     SetMovePosition02(GetClipMinX+60,GetClipMinY+60,60);
      }
     else if(arg == 5){
     SetMovePosition02(GetClipMaxX-60,GetClipMinY+60,60);
      }
     else if(arg == 6){
     SetMovePosition02(GetClipMinX+80,GetClipMinY+100,60);
      }
     else if(arg == 7){
     SetMovePosition02(GetClipMaxX-80,GetClipMinY+100,60);
      }
     else if(arg == 8){
     SetMovePosition02(GetClipMinX+100,GetClipMinY+140,60);
      }
     else if(arg == 9){
     SetMovePosition02(GetClipMaxX-100,GetClipMinY+140,60);
      }
     else if(arg == 10){
     SetMovePosition02(GetClipMinX+120,GetClipMinY+180,60);
      }
     else if(arg == 11){
     SetMovePosition02(GetClipMaxX-120,GetClipMinY+180,60);
      }
     else if(arg == 12){
     SetMovePosition02(GetClipMinX+140,GetClipMinY+210,60);
      }
     else if(arg == 13){
     SetMovePosition02(GetClipMaxX-140,GetClipMinY+210,60);
      }
    wait(61);
           SetSpeed(1);
           SetAngle(rand(30,150));
       wait(180);
        loop{
          if(GetY >= GetClipMaxY+20){VanishEnemy;}
           wait(1);
            }
      } 

     function offsetX(radius,angle){
           return radius * cos(angle);
     }

        function offsetY(radius,angle){
            return radius * sin(angle);
     }           

       function move(f){
          SetMovePosition02(rand(GetClipMinX+60,GetClipMaxX-60),GetY+rand(-20,20),f);
     }
            
        function sc(r,g,b){
             SetShotColor(r,g,b);
     }

       sub setGraphicStop  { SetGraphicRect( 40,  20, 80, 100); }

       function wait(w){
                loop(w){yield;}
       }
}
}