
#Title[No.001 - 002]
#Text[uK[fBAWuv
uK[fBAWuv]
#Player[FREE]
#Image[.\img.png]
#BackGround[User]
#ScriptVersion[2]

script_enemy_main{
    #include_script".\Local.txt"
     #include_function".\function_bullet.txt"
    #include_function".\function_effect.txt"
   let name        = " uK[fBAWuv";
   let imgBOSS = csd~"img\dot_itirin.png";
   let shotData = csd ~ "data_usershot.txt";
  let out = GetCommonDataDefaultEx("","timeout",false);
 if(difficult == 3){name =  " uK[fBAWuv";}

   @Initialize{
  SetCommonDataEx("","dif",difficult);
    SetLife(525);
    if(out){AddLife(-600); MagicCircle(false);}
  if(difficult >= 2 && !out){SetScore(2500000/3);
 CutIn(YOUMU, name, "", 0, 0, 0, 0);
  PracticeCardFrag[difficult-1] = true;
  SetCommonDataEx("","pcf",PracticeCardFrag);
  SpellCardHistory[difficult-1] = history + 1;
  SetCommonDataEx("","sch",SpellCardHistory); 
   }
 SetDamageRate(15,10);
           SetTimer(55);
           SetInvincibility(120);
         SetMovePosition03(GetCenterX,GetClipMinY+120,20,5);
        SetAlpha(255);
           LoadGraphic(imgBOSS);
          LoadUserShotData(shotData);
           TMain;
   if(playmode >= 4){
     LastSpell; 
  SetDamageRate(15,0);
    SetCommonDataEx("","spellnow",difficult-1);
         }
     ForbidShot(false);
     ForbidBomb(false);
    }

   @MainLoop{
    if(OnEvent){break;}
    if(GetCommonDataDefaultEx("","gof",false)){
       SetDamageRate(0,0);
       SetTimer(100);
       break;
       }
      SetCollisionA(GetX, GetY, 24);
      SetCollisionB(GetX, GetY, 20);
 if(playmode >= 4 && GetTimeOfPlayerInvincibility != 0){
     ShootDownPlayer;
     }
         yield;
       }

   @DrawLoop{
         SetTexture(imgBOSS);  
       if(GetHitCount >= rand_int(1,damage) && GetTimeOfInvincibility == 0){
   SetColor(0,0,255);
        }
        DrawGraphic(GetX,GetY);
        SetColor(255,255,255);
  SetFontColor(255,255,0,255,255,0);
  DrawText("Itirin Kumoi",minx+15,miny+15,10,255);
  SetFontColor(255,255,255,255,255,255);
     }

    @Finalize{
 if(!IsTimeOut && !OnPlayerMissed && !out){PlaySE(sevanish);}
        DeleteGraphic(imgBOSS);
    if(playmode < 4 && difficult >= 2 && !out){
  loop(10){
     CreateItem(ITEM_SCORE,GetX+offsetX(rand(16,48),rand(0,360)),GetY+offsetY(rand(16,48),rand(0,360))); 
       }   
       }
 if(GotSpellCardBonus){
      GetSpellCard[difficult-1] = getnum + 1;
      SetCommonDataEx("","gsc",GetSpellCard);
          }
   DeleteCommonData("timeout");
     }
 
     task TMain{
 if(difficult >= 2 && !out){SpellBackGround(800);}
          wait(120);
 SetEnemyMarker(true);
        Count;
  alternative(difficult)
   case(2){Hard;}
   case(3){Lunatic;}
    }

   task Hard{
 Shake(40,0.15,0.005,0.05,3);
  let size = 40;
  let v = 10;
  let accel = -0.1;
  let angle = 90;
  let kill = [240,180,150];
  let width = 10;
  let length = 150;
   let color = 19;
  let delay = 30;
   sgrnum = 2;
   SetMovePosition03(cx+120,GetClipMinY+120,10,3);
   wait(60);
   loop{
  sgrnum = 1;
   SetMovePosition03(cx-150,GetClipMinY+120,10,3);
  ascent(a in 0..3){
  let x = maxx-40-100*a;
  Hand(x,miny-size*1.5,v,angle,accel,size,kill[a]+60);
      wait(30);
    if(a == 0){wait(30);}
        } 
  wait(150);
  sgrnum = 3;
    descent(a in 0..60){
      ascent(b in 0..2){
  let angle = 90+(180-12.5*a)*(-1)^b;
  let x = GetX+offsetX(32,angle);
  let y = GetY+offsetY(32,angle);
  CreateLaser01(x,y,4,angle-90*(-1)^b,length,width,color,delay);
       }
   PlaySE(seray);
   wait(1);
       }
   wait(150);
   sgrnum = 2;
   SetMovePosition03(cx+150,GetClipMinY+120,10,3);
       ascent(a in 0..3){
  let x = minx+40+100*a;
  Hand(x,miny-size*1.5,v,angle,accel,size,kill[a]+60);
      wait(30);
    if(a == 0){wait(30);}
        } 
  wait(150);
  sgrnum = 3;
    ascent(a in 0..60){
      ascent(b in 0..2){
  let angle = 90+(180+12.5*a)*(-1)^b;
  let x = GetX+offsetX(32,angle);
  let y = GetY+offsetY(32,angle);
  CreateLaser01(x,y,4,angle-90*(-1)^b,length,width,color,delay);
       }
   PlaySE(seray);
   wait(1);
       }
   wait(150);
       }
    }

  task Lunatic{
   Shake(80,0.25,0.005,0.1,5);
  let size = 50;
  let v = 10;
  let accel = -0.1;
  let angle = 90;
  let kill = [240,180,150];
  let width = 10;
  let length = 190;
   let color = 19;
  let delay = 30;
   sgrnum = 2;
   SetMovePosition03(cx+120,GetClipMinY+120,10,3);
   wait(60);
   loop{
  sgrnum = 1;
   SetMovePosition03(cx-150,GetClipMinY+120,10,3);
  ascent(a in 0..3){
  let x = maxx-50-120*a;
  Hand(x,miny-size*1.5,v,angle,accel,size,kill[a]+60);
      wait(30);
    if(a == 0){wait(30);}
        } 
  wait(150);
  sgrnum = 0;
    descent(a in 40..100){
      ascent(b in 0..2){
  let angle = 90+(60-22*a)*(-1)^b;
  let x = GetX+offsetX(32,angle);
  let y = GetY+offsetY(32,angle);
  CreateLaser01(x,y,5,angle-60*(-1)^b,length,width,color,delay);
       }
   PlaySE(seray);
   wait(1);
       }
   wait(150);
   sgrnum = 2;
   SetMovePosition03(cx+150,GetClipMinY+120,10,3);
       ascent(a in 0..3){
  let x = minx+50+120*a;
  Hand(x,miny-size*1.5,v,angle,accel,size,kill[a]+60);
      wait(30);
    if(a == 0){wait(30);}
        } 
  wait(150);
  sgrnum = 0;
    ascent(a in 40..100){
      ascent(b in 0..2){
  let angle = 90+(60-22*a)*(-1)^b;
  let x = GetX+offsetX(32,angle);
  let y = GetY+offsetY(32,angle);
  CreateLaser01(x,y,5,angle-60*(-1)^b,length,width,color,delay);
       }
   PlaySE(seray);
   wait(1);
       }
   wait(150);
       }
    }

   task Shake(n,x1,y1,y2,my){
   loop{
  while(!shake){wait(1);}
   loop(n){
  let x = rand(minx,maxx);
 let y = miny;
  let vx = rand(-x1,x1);
  let vy = 0;
  let ax = 0;
  let ay = rand(y1,y2);
  let lx = vx;
  let ly = rand(0.5,my);
  let color = 23;
  let delay = 0;
   CreateShot12(x,y,vx,vy,ax,ay,lx,ly,color,delay);
    }
   while(shake){wait(1);}
         }
       }

    task Move{
   let f = 1.5;
  let r = rand_int(0,1);
 if(GetX < minx+100){r = 0;}
 else if(GetX > maxx-100){r = 1;}
 else if(GetX < GetPlayerX){r = 0;}
 else if(GetX > GetPlayerX){r = 1;}
    let x = GetX + rand(30,45)*(-1)^r;
    let y = GetY + rand(-32,32);
    if(y < miny+48){y = miny+48;}
    else if(y > miny+130){y = miny+130;}
   if(GetX > x){sgrnum = 1;}
   else if(GetX < x){sgrnum = 2;}  
    SetMovePosition03(x,y,15,f);
     wait(90);
    sgrnum = 0;
    }


    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*128,b*128,(a+1)*128,(b+1)*128);}

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