script_enemy_main{
        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\gun10.wav";
   let dif = GetCommonData("Dif");
	@Initialize
	{
            if(GetPlayerType == REIMU_A){SetLife(500);}
            else{SetLife(500);}
            SetDamageRate(100,10);
            LoadGraphic(Enemy);
            SetTimer(30);
            LoadUserShotData(shotData);
		SetGraphicRect(256,120,316,180);	
		SetMovePosition02(GetX,GetClipMinY+120,90);
          SetInvincibility(30);
          LoadSE(se1);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

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

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

     task Shot{
    loop{
           ascent(i in 0..9){
          ascent(a in 0..8){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer+45*a;
          let v = 1;
          let v2 = 3;
         let color = 34;
          let delay = 20;
         CreateShot01(x,y,v,angle+2*(i-5),color,delay); 
         CreateShot01(x,y,2,angle+4*(i-5),color,delay); 
          PlaySE(se1);
            }
         wait(10);
        }    
         wait(60);
          descent(i in 0..9){
          ascent(a in 0..8){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer+45*a;
          let v = 1;
          let v2 = 3;
         let color = 37;
          let delay = 20;
         CreateShot01(x,y,v,angle+2*(i-5),color,delay); 
         CreateShot01(x,y,2,angle+4*(i-5),color,delay); 
          PlaySE(se1);
            }
         wait(10);
        }      
           wait(60);
        }
       }

 task Shot2{
    loop{
           ascent(i in 0..21){
          ascent(a in 0..12){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer+30*a;
          let v = 1;
          let v2 = 5;
         let color = 34;
          let delay = 20;
         CreateShot01(x,y,v,angle+40*(i-5),color,delay); 
         CreateShot01(x,y,2,angle+12*(i-5),color,delay); 
          PlaySE(se1);
            }
         wait(5);
        }    
         wait(60);
          descent(i in 0..21){
          ascent(a in 0..12){
        let x = GetX;
        let y = GetY;
         let angle = GetAngleToPlayer+30*a;
          let v = 1;
          let v2 = 5;
         let color = 37;
          let delay = 20;
         CreateShot01(x,y,v,angle+40*(i-5),color,delay); 
         CreateShot01(x,y,2,angle+12*(i-5),color,delay); 
          PlaySE(se1);
            }
         wait(5);
        }      
           wait(60);
        }
       }

     task Move{
         wait(120);
      SetMovePosition02(GetX,GetClipMinY-100,60);
       wait(60);
       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;}
       }
}
}