
#Title[No.007 - 010]
#Text[QuXPXEv
QuC̖v
CuS[fH[ebNXv]
#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        = " QuXPXEv";
   let imgBOSS = csd~"img\dot_murasa.png";
   let shotData = csd ~ "11-221Shot.txt";
 let history = SpellCardHistory[difficult+7];
 let getnum = GetSpellCard[difficult+7];

 alternative(difficult)
  case(2){name =  " QuC̖v";}
  case(3){name =  " CuS[fH[ebNXv";}

   @Initialize{
  SetCommonDataEx("","dif",difficult);
  PracticeCardFrag[difficult+7] = true;
  SetCommonDataEx("","pcf",PracticeCardFrag);
     CutIn(YOUMU, name, "", 0, 0, 0, 0);
 SetScore(2500000/3);
 SetDamageRate(20,8);
           SetLife(600);
           SetTimer(63);
           SetInvincibility(120);
         SetMovePosition03(GetCenterX,GetClipMinY+80,20,5);
        SetAlpha(255);
           LoadGraphic(imgBOSS);
          LoadUserShotData(shotData);
           TMain;
 SpellCardHistory[difficult+7] = history + 1;
  SetCommonDataEx("","sch",SpellCardHistory);
  if(playmode >= 4){
      LastSpell; 
    SetDamageRate(20,0);
    SetCommonDataEx("","spellnow",difficult+7);
       }
  else{SetEffectForZeroLife(60,0,0);}
     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("Minamitsu Murasa",minx+15,miny+15,10,255);
  SetFontColor(255,255,255,255,255,255);
     }

    @Finalize{
 if(playmode >= 4 && (IsTimeOut || OnPlayerMissed) ){}
 else{PlaySE(BossVanish);}
        DeleteGraphic(imgBOSS);
 if(GotSpellCardBonus){
      GetSpellCard[difficult+7] = getnum + 1;
      SetCommonDataEx("","gsc",GetSpellCard);
          }
     }
 
     task TMain{
 SpellBackGround(800);
          wait(120);
 SetEnemyMarker(true);
        Count;
     if(playmode < 4){End;}
  alternative(difficult)
   case(0){Easy;}
   case(1){Normal;}
   case(2){Hard;}
   case(3){Lunatic;}
    }

 task Easy{
  let px = [];
  let py = [];
  let d = 180/(3+5^0.5);
   let delay = 6;
   let color = [21,29];
   let num = 0;
   let v = 0.1;
   let accel = 0.01;
   let vmax = 1;
  let way = 1;
  let n = 80;
  let k = -60;
   loop{
  let base =rand(-180,180);
   sgrnum = 3;
    loop(way){
   px = px~[cx]; 
   py = py~[cy];
  }
  ascent(a in 0..n){
    ascent(b in 0..way){
   let r = a*4;
  let x = cx+offsetX(r,base+a*d+360/way*b);
  let y = cy+offsetY(r,base+a*d+360/way*b);
  let angle = atan2(py[b]-y,px[b]-x)+k;
 if(((GetPlayerX-x)^2+(GetPlayerY-y)^2)^0.5 >= 25){
  CreateShotA(0,x,y,delay);
  SetShotDataA(0,0,v,angle,0,0,vmax,color[num]);
  SetShotDataA(0,2*n+0-2*a+2,NULL,NULL,0,accel,vmax,color[num]);
  FireShot(0);}
   px[b] = x; py[b] = y;
  PlaySE(seshot1);
   }
   wait(2);
   }
  d = -d;
  k = -k;
   PlaySE(seshot3);
  wait(60);
  Move;
   wait(60);
  Move;
 num++;
  if(num > 1){num = 0;}
  wait(120);
  Move;
  wait(60);
      }
    }

  task Normal{
    let px = [];
  let py = [];
  let d = 180/(3+5^0.5);
   let delay = 6;
   let color = [21,29];
   let num = 0;
   let v = 0.1;
   let accel = 0.01;
   let vmax = 1.5;
  let way = 4;
  let n = 80;
  let k = -60;
   loop{
  let base = rand(-180,180);
   sgrnum = 3;
    loop(way){
   px = px~[cx]; 
   py = py~[cy];
  }
  ascent(a in 0..n){
    ascent(b in 0..way){
   let r = a*6;
  let x = cx+offsetX(r,base+a*d+360/way*b);
  let y = cy+offsetY(r,base+a*d+360/way*b);
  let angle = atan2(py[b]-y,px[b]-x)+k;
 if(((GetPlayerX-x)^2+(GetPlayerY-y)^2)^0.5 >= 25){
  CreateShotA(0,x,y,delay);
  SetShotDataA(0,0,v,angle,0,0,vmax,color[num]);
  SetShotDataA(0,2*n+0-2*a+2,NULL,NULL,0,accel,vmax,color[num]);
  FireShot(0);}
   px[b] = x; py[b] = y;
  PlaySE(seshot1);
   }
   wait(2);
   }
  PlaySE(seshot3);
  d = -d;
  k = -k;
   wait(60);
  Move;
  wait(60);
  Move;
  num++;
  if(num > 1){num = 0;}
   wait(120);
  Move;
  wait(60);
      }
    }

   task Hard{
   let px = [];
  let py = [];
  let d = 180/(3+5^0.5);
   let delay = 6;
    let color = [21,29];
   let num = 0;
   let v = 0.1;
   let accel = 0.01;
   let vmax = 1.75;
  let way = 4;
  let n =80;
   let k = [55-5,-130+5,35+4,-142.5-4];  
   loop{
  let base = rand(-180,180);
   sgrnum = 3;
    loop(way){
   px = px~[cx]; 
   py = py~[cy];
  }
  ascent(a in 0..n){
    ascent(b in 0..way){
   ascent(c in 0..2){
   let r = a*5;
  let x = cx+offsetX(r,base+a*d+360/way*b+90*c);
  let y = cy+offsetY(r,base+a*d+360/way*b+90*c);
  let angle = atan2(py[b]-y,px[b]-x)+k[c+2*num]+90*c;
 if(((GetPlayerX-x)^2+(GetPlayerY-y)^2)^0.5 >= 25){
  CreateShotA(0,x,y,delay);
  SetShotDataA(0,0,v,angle,0,0,vmax,color[num]+c);
  SetShotDataA(0,2*n+0-2*a+2,NULL,NULL,0,accel,vmax,color[num]+c);
  FireShot(0);}
   px[b] = x; py[b] = y;
  PlaySE(seshot1);
   }
  }
   wait(2);
   }
 PlaySE(seshot3);
  d = -d;
 /* k = -k; */
   wait(60);
  Move;
  wait(60);
  Move;
  num++;
  if(num > 1){num = 0;}
   wait(120);
  Move;
  wait(60);
      }
    }

  task Lunatic{
    let px = [];
  let py = [];
  let d = 180/(3+5^0.5);
   let delay = 6;
    let color = [18,19,21-3,22-3];
   let num = 0;
   let v = 0.1;
   let accel = [0.015,0.015,0.01,0.01];
   let vmax = [1.3,1.3,2,2];
  let way = 4;
  let n = 80;
 /* let k = [-37.5-5+180,-30+180,-55-5,-30,-47.5+180,-55-4+180,-31,-55-4]];*/
    let k = [-37.5-5+180+165,-30-180-165,-55-5,-30,-47.5-180-165,-55-4+180+165,-31,-55-4];
   loop{
  let base = rand(-180,180);
   sgrnum = 3;
    loop(way){
   px = px~[cx]; 
   py = py~[cy];
  }
  ascent(a in 0..n){
    ascent(b in 0..way){
   ascent(c in 0..4){
   let r = a*4;
  let x = cx+offsetX(r,base+a*d+360/way*b+90*c);
  let y = cy+offsetY(r,base+a*d+360/way*b+90*c);
  let angle = atan2(py[b]-y,px[b]-x)+k[c+num/2];
 if(((GetPlayerX-x)^2+(GetPlayerY-y)^2)^0.5 >= 25){
  CreateShotA(0,x,y,delay);
  SetShotDataA(0,0,v,angle,0,0,vmax,color[c]+num);
  SetShotDataA(0,2*n+2-2*a,NULL,NULL,0,accel[c%4],vmax[c%4],color[c]+num);
  FireShot(0);   
       }
   px[b] = x; py[b] = y;
  PlaySE(seshot1);
   }
  }
   wait(2);
   }
 PlaySE(seshot3);
  d = -d;
  wait(60);
  Move;
  wait(60);
  Move;
  num+=8;
  if(num > 8){num = 0;}
   wait(120);
   Move;
   wait(60);
      }
    }

    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(45,120)*(-1)^r;
    let y = GetY + rand(-48,48);
    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);
    }


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