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

	@Finalize{ 
         if(!BeVanished&&!IsTimeOut){
             AddScore(200);
         loop(48){
            CreateItem(ITEM_SCORE,GetX+offsetX(32,rand(-180,180)),GetY+offsetY(32,rand(-180,180)));
            } 
      if(arg == 1){CreateItem(ITEM_1UP,GetX,GetY);}
          DeleteEnemyShotToItem(ALL);
             }
	}

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

     task Shot{
   let base = GetAngleToPlayer;
     loop{
     ascent(b in 0..360){
     ascent(a in 0..4){
       let angle = 90*a+7*b+base;
       let angle2 = angle+180+7*b;
       let radius = 16;
       let radius2 = 48;
        let x = GetX+offsetX(radius,angle)+offsetX(radius2,angle2);
        let y = GetY+offsetY(radius,angle)+offsetY(radius2,angle2);
          let v = 1.5;
         let color = 241;
          let delay = 10;
         CreateShot01(x,y,v,angle+angle2,color,delay); 
          PlaySE(se1);
       }
     wait(10);
        }
        }
       }
     
  task Shot2{
   let a = GetAngleToPlayer; let b = 0; let n = 0;
   let way = 6;
     loop{
     loop(way){
       let angle = a+b;
       let angle2 = angle+180+b;
       let radius = 48;
       let radius2 = 36;
        let x = GetX+offsetX(radius,angle)+offsetX(radius2,angle2);
        let y = GetY+offsetY(radius,angle)+offsetY(radius2,angle2);
          let v = 3;
         let color = 241;
          let delay = 10;
         CreateShot01(x,y,v,angle+angle2,color,delay); 
      a += 360/way;
       }
  PlaySE(se1);
    b += n;
     n += 1;
     wait(arg);
        }
       }
    

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