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_gun000.wav";
        let se2 = csd~ "bgm\tm2_coin000.wav";
        let se3 = csd~ "bgm\bell01.wav";
  let dif = GetCommonData("Dif");
	@Initialize
	{
            if(GetPlayerType == REIMU_A){SetLife(100);}
            else{SetLife(100);}
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
		SetGraphicRect(70,60,90,100);	
    /*     SetMovePosition03(GetX,GetClipMinY+90,10,3);  */ 
          SetInvincibility(0);
          LoadSE(se1);LoadSE(se2);LoadSE(se3);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),12);
		SetCollisionB(GetX(),GetY(),12);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
         if(!BeVanished){
             AddScore(100);
         loop(6){ 
             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{
        let radius = 24;
          let color = 48;
          let delay = 20;
       loop{
         loop(4){
          let angle = rand(-160,-20);
          let x = GetX+offsetX(radius,angle);
          let y = GetY+offsetY(radius,angle);
          let v = rand(0.5,1.5);
          let accel = rand(0.005,0.02);
           let grvAngle = 90;
          GravityShot(x,y,v,angle,accel,grvAngle,color,delay);
         PlaySE(se3);
           }
          wait(30);
         }
      }
     
  task Shot2{
        let radius = 24;
          let color = 48;
          let delay = 20;
       loop{
         loop(4){
          let angle = rand(-160,-20);
          let x = GetX+offsetX(radius,angle);
          let y = GetY+offsetY(radius,angle);
          let v = rand(0.5,3);
          let accel = rand(0.01,0.05);
           let grvAngle = 90;
          GravityShot(x,y,v,angle,accel,grvAngle,color,delay);
         PlaySE(se3);
           }
          wait(10);
         }
      }     

     task Move{
           SetSpeed(gspeed);
           SetAngle(gangle);
       wait(280);
       VanishEnemy;   
      } 

     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;}
       }
}
}