script_enemy_main{
      #include_script".\Local.txt"
    let shotData = csd ~ "data_usershot.txt";
  /* let arg = GetArgument;
   let difficult = GetCommonDataDefaultEx("","dif",0); */
	@Initialize
	{
 SetCommonDataEx("","dif",difficult);
         SetLife(arg[0]);
            SetDamageRate(100,arg[2]);
            LoadUserShotData(shotData);	
          SetInvincibility(arg[3]);
   sgrnum = 3;
               Main;
	}
	
	@MainLoop{
    if(GetCommonDataDefaultEx("","gof",false)){
       SetDamageRate(0,0);
     SetSpeed(0);
       break;
       }
        SetCollisionA(GetX(),GetY(),arg[4]);
	SetCollisionB(GetX(),GetY(),arg[4]);
		yield;
	}
	
       	@DrawLoop{
    alternative(arg[1])
   case(0){SetTexture(EnemyBlue);}
   case(1){SetTexture(EnemyRed);}
   case(2){SetTexture(EnemyGreen);}
   case(3){SetTexture(EnemyYellow);}
   case(4){SetTexture(EnemyEx1);}
   case(5){SetTexture(EnemyEx2);}
   case(6){SetTexture(EnemyOther);}
    others{SetTexture(EnemyBlue);}
   GraphicTurn;
    DrawGraphic(GetX,GetY);
/* DrawText(ToString(EnemyBlue),cx-180,cy+90,20,255);*/
	}

	@Finalize{ 
         if(!BeVanished){
      PlaySE(seshot7);
             AddScore(arg[7]); 
      ascent(a in 0..arg[8]){
     let x = GetX; 
     let y = GetY;
       CreateItem(ITEM_SCORE,x,y);
       x = GetX+offsetX(rand(3,15),rand(-180,180));
       y = GetY+offsetY(rand(3,15),rand(-180,180));
                }
  /*   ascent(a in 0..arg[9]){
     let x = GetX;  let y = GetY;
       CreateItem(ITEM_SCORE,x,y);
       x = GetX+offsetX(rand(3,15),rand(-180,180));
       y = GetY+offsetY(rand(3,15),rand(-180,180));
                }  */
      ascent(a in 0..arg[10]){
     let x = GetX;   let y = GetY;
       CreateItem(ITEM_BOMB,x,y);
                }
       ascent(a in 0..arg[11]){
     let x = GetX;   let y = GetY;
       CreateItem(ITEM_1UP,x,y);
                }
            }
	}

         task Main{
             yield; 
    alternative(difficult)
   case(0){Easy;}
   case(1){Normal;}
   case(2){Hard;}
   case(3){Lunatic;}
       Move;
   wait(180);
     }

     task Easy{
   alternative(arg[5])
    case(11){}
       }

     task Normal{
    alternative(arg[5])
    case(11){}
    }

     task Hard{
    alternative(arg[5])
    case(11){}
   }

     task Lunatic{
     alternative(arg[5])
    case(11){}
  }

     task Move{
     alternative(arg[6])
    case(11){}

    while(GetX >= minx-32 && GetX <= maxx+32 && GetY >= miny-32 && GetY <= maxy+32){wait(1);}
     VanishEnemy;
   }

     function offsetX(radius,angle){
           return radius * cos(angle);
     }

        function offsetY(radius,angle){
            return radius * sin(angle);
     }           

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

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