
#Title[No.003 - 006]
#Text[duz[XAJ[v
]duf^AJ[v]
#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        = " duz[XAJ[v";
   let imgBOSS = csd~"img\dot_murasa.png";
   let shotData = csd ~ "data_usershot.txt";
 let history = SpellCardHistory[difficult+3];
 let getnum = GetSpellCard[difficult+3];

 alternative(difficult)
  case(2,3){name =  " ]duf^AJ[v";}

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

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

 task Easy{
   loop{
   let x = GetX; 
   let y = GetY;
   let v = 8;
   let angle = GetAngleToPlayer;
   let accel = 0.1;
   let size = 20;
   let kill = 600;
   Anchor(x,y,v,angle,accel,size,kill); 
    wait(120);
   Move;
    wait(120);
      }
    }

  task Normal{
   loop{
   let x = GetX; 
   let y = GetY;
   let v = 8;
   let angle = GetAngleToPlayer;
   let accel = 0.1;
   let size = 25;
   let kill = 600;
   Anchor(x,y,v,angle,accel,size,kill); 
    wait(120);
   Move;
    wait(120);
      }
    }

   task Hard{
   loop{
   let x = GetX; 
   let y = GetY;
   let v = 8;
   let angle2 = atan2(GetPlayerY-GetY,minx-GetX);
   let angle3 = atan2(GetPlayerY-GetY,maxx-GetX);
   let accel = 0.1;
   let size = 25;
   let kill = 600;
   Anchor(x,y,v,angle2,accel,size,kill); 
   Anchor(x,y,v,angle3,accel,size,kill); 
    wait(30);
  let angle = GetAngleToPlayer;
   Anchor(x,y,v,angle,accel,size,kill); 
    wait(120);
   Move;
    wait(120);
      }
    }

  task Lunatic{
    loop{
   let x = GetX; 
   let y = GetY;
   let v = 8;
   let angle2 = atan2(GetPlayerY-GetY,minx-GetX);
   let angle3 = atan2(GetPlayerY-GetY,maxx-GetX);
   let accel = 0.1;
   let size = 25;
   let kill = 600;
   Anchor(x,y,v,angle2,accel,size,kill); 
   Anchor(x,y,v,angle3,accel,size,kill); 
    wait(30);
  let angle = GetAngleToPlayer;
   Anchor(x,y,v,angle,accel,size,kill); 
    wait(120);
   Move;
    wait(120);
      }
    }

    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,90)*(-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;}
       }
}