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(100);
            SetDamageRate(100,100);
            LoadGraphic(Enemy);
            
            LoadUserShotData(shotData);
      sgr(0,0);	
          SetInvincibility(110);
               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); 
  loop(1){
  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));
    }
       rank += 1;
             }
   SetCommonDataEx("","PlayRank",rank);
	}

         task Main{
             yield; 
       Shot;
     }

     task Shot{
  let color = RED01;
  if(arg == 1){color = BLUE01;}
   SetMovePosition02(GetX,GetY+120,90);
    wait(90);
  let rank = GetCommonDataDefaultEx("","PlayRank",0);
   let v = 0.5;
 loop(2){
  let angle = rand(-180,180);
   ascent(a in 0..8){
     ascent(b in 0..12){
      CreateShot01(GetX,GetY,v+0.3*a,angle+30*b-4*a,color,10);
       }
    PlaySE(seshot3);
    wait(5);
      }
  wait(10);
  angle = rand(-180,180);
   ascent(a in 0..8){
     ascent(b in 0..12){
      CreateShot01(GetX,GetY,v+0.3*a,angle+30*b+4*a,color,10);
       }
    PlaySE(seshot3);
    wait(5);
      }
     wait(10);
     }
   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;}
       }
}