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(0,0);
            LoadGraphic(Enemy);
           LoadGraphic(effect);
      SetAlpha(0);
            LoadUserShotData(shotData);
      sgr(1,4);	
          SetInvincibility(30);
               Main;
	}
	
	@MainLoop{
		yield;
	}
	
       	@DrawLoop{
               SetTexture(Enemy);
		DrawGraphic(GetX,GetY);
	}

	@Finalize{ 
         if(!BeVanished){
             AddScore(100); 
   loop(12){
   let radius = rand(0,0);
  let angle = rand(-180,180);
  CreateItem(ITEM_SCORE,GetX+offsetX(radius,angle),GetY+offsetY(radius,angle));
    }
   
             }
	}

         task Main{
             yield; 
       Shot;
     }

     task Shot{
  alternative(arg)
  case(0){
   ascent(a in 0..8){
   let angle = 45*a;
 Dan(GetX,GetY,0,angle,8,0,75);
      }
  wait(21);
 PlaySE(seshot2);
    ascent(a in 0..5){
   let angle = GetAngleToPlayer+15*(a-2);
 CreateShot01(GetX,GetY,6,angle,8,0);
      }
    }
  case(1){
 ascent(a in 0..8){
   let angle = 45*a;
 Dan(GetX,GetY,0,angle,8,0,75);
      }
  wait(21);
  let base = GetAngleToPlayer;
 ascent(b in 0..8){
   ascent(a in 0..18){
   let angle = base+20*a+20/3*b;
 CreateShot01(GetX,GetY,6,angle,96,0);
      }
   PlaySE(seshot1);
   wait(6);
      } 
    }
 case(2){
 ascent(a in 0..8){
   let angle = 45*a;
 Dan(GetX,GetY,0,angle,8,0,75);
      }
  wait(21);
  let base = GetAngleToPlayer;
 ascent(b in 0..8){
   ascent(a in 0..18){
   let angle = base+20*a-20/3*b;
 CreateShot01(GetX,GetY,6,angle,96,0);
      }
   PlaySE(seshot1);
   wait(6);
      } 
  }
 case(3){
   ascent(a in 0..8){
   let angle = 45*a;
 Dan(GetX,GetY,0,angle,8,0,60);
      }
  wait(21);
 PlaySE(seshot2);
    ascent(a in 0..10){
   let angle = GetAngleToPlayer+36*(a-2);
 CreateShot01(GetX,GetY,6,angle,8,0);
      }
    }
 case(4){
   ascent(a in 0..8){
   let angle = 45*a;
 Dan(GetX,GetY,0,angle,8,0,60);
      }
  wait(21);
 PlaySE(seshot2);
    ascent(a in 0..20){
   let angle = GetAngleToPlayer+18*(a-2);
 CreateShot01(GetX,GetY,6,angle,8,0);
      }
    }
  wait(30);
   VanishEnemy; 
    }

   task Dan(x,y,v,angle,color,delay,radius){
        let p = Obj_Create(OBJ_SHOT);
         Obj_SetX(p,x);
         Obj_SetY(p,y);
         Obj_SetSpeed(p,v);
         Obj_SetAngle(p,angle);
         ObjShot_SetGraphic(p,color); 
         ObjShot_SetDelay(p,delay);
         Obj_SetAutoDelete(p,false);
         ObjShot_SetBombResist(p,false);
         Obj_SetCollisionToObject(p,true);
         Obj_SetCollisionToPlayer(p,true);
  let f = 21;
    ascent(a in 0..f){
   Obj_SetAngle(p,Obj_GetAngle(p)+5);
      Obj_SetX(p,GetX+offsetX(radius/f*(f-a),Obj_GetAngle(p)));
      Obj_SetY(p,GetY+offsetY(radius/f*(f-a),Obj_GetAngle(p)));
     wait(1);
      }
   Obj_Delete(p);
  }

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