script_enemy_main{
      #include_script".\Local.txt"
	let Enemy=csd~"img\dot_yousei.png";
        let shotData = csd ~ "data_usershot.txt";
   let arg = GetArgument;
  let effect = csd ~ "img\circle.png";
	@Initialize
	{

         SetLife(300);
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
      sgr(0,0);	
          SetInvincibility(666);
               Main;
	}
	
	@MainLoop{
               SetCollisionA(GetX(),GetY(),12);
		SetCollisionB(GetX(),GetY(),6);
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
   let rank = GetCommonDataDefaultEx("","PlayRank",0);
         if(!BeVanished){
             AddScore(100);
 if(arg != 100){ 
  let radius = rand(0,48);
  let angle = rand(-180,180);
   loop(8){
  CreateItem(ITEM_SCORE,GetX+offsetX(radius,angle),GetY+offsetY(radius,angle));
    }
  loop(5){
    let radius = rand(0,48);
  let angle = rand(-180,180);
   CreateItem(ITEM_SCORE,GetX+offsetX(radius,angle),GetY+offsetY(radius,angle));
    }
   }
 else if(arg == 100){CreateItem(ITEM_1UP,GetX,GetY);}
       rank += 1;
             }
   SetCommonDataEx("","PlayRank",rank);
	}

         task Main{
             yield; 
       Shot;
     }

     task Shot{
   SetMovePosition02(GetX,GetY+120,90);
    wait(90);
  let rank = GetCommonDataDefaultEx("","PlayRank",0);
   let v = 0.3;  let way = 6;  let mul = 0.3;
  let n = 5;
 if(arg == 100){n = 7;}
 loop(6){
  let angle = rand(-180,180);
   ascent(a in 0..12){
     ascent(b in 0..way*2){
      CreateShot01(GetX,GetY,v+mul*a,angle+180/way*b-n*a,RED12,10);
       }
    PlaySE(seshot1);
    wait(4);
      }
  angle = rand(-180,180);
   ascent(a in 0..12){
     ascent(b in 0..way){
      CreateShot02(GetX,GetY,4,angle+360/way*b+1.5*a,-0.1,1.7+0.17*a,BLUE12,10);
       }
    PlaySE(seshot1);
    wait(4);
      }
    way += 2;
    v += 0.1;
     }
   SetAngle(90);
   SetSpeed(1);
    wait(420);
   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);
     }

  function sgr(a,b){SetGraphicRect(a*32,b*32,(a+1)*32,(b+1)*32);}

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