
#Title[VAVA1]
#Text[]
#ScriptVersion[2]

script_enemy_main {
  let imgBoss = "script\vava\dotvava.png";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetClipMaxY - 400;
  let SH=180;
  let Q=1;
let scoa=0;
@Initialize {
    SetLife(600);

    SetDamageRate(0, 0);
SetShotAutoDeleteClip(128,128,128,240);
    LoadGraphic(imgBoss);
   SetTexture(imgBoss);   SetGraphicRect(0, 0, 63, 63);
 setGraphicStop;
    setGraphicMove;
    TMain;

   }
@MainLoop {
              
    SetCollisionA(GetX, GetY, 24);
    SetCollisionB(GetX, GetY, 24);
   yield;

}
@DrawLoop{
    DrawGraphic(GetX, GetY);
   }

@Finalize {
if(scoa==0){
AddScore(3000+3000*GetPlayerLife);scoa=1;}
    DeleteGraphic(imgBoss);}

function moveToPlayer(xMove, yAdd, frame, left, top, right, bottom) {
     let x;
     let y;

     if(GetPlayerX < GetX) {
         x = GetX - xMove;
         if(x < left) {
             x = GetX + xMove;
     }
     } else {
         x = GetX + xMove;
         if(right < x) {
             x = GetX - xMove;
         }
     }
     y = GetY + yAdd;
     if(y < top) {
         y = top;
     } else if(bottom > y) {
         y = bottom;
     }

     SetMovePosition02(x, y, frame);



}

  task TMain {
         yield;
       standBy;

  loop{
                 Q=rand_int(1,1);
  if(GetLife<300){Q=rand_int(2,2);}

if(Q==1){

 loop(2){  SetMovePosition02(GetPlayerX, yIni+rand(-30,120), 20);
    wait(20);fire;wait(30);}
wait(60);
}
if(Q==2){che;}

    SetMovePosition02(GetClipMaxX-20, yIni, 30);
    wait(60);
   dshot2;
    wait(60);
    dshot;
    SetMovePosition02(GetClipMinX+20, yIni, 240);
    wait(240);
    SH=SH+180;
    dshot2;
    wait(60);
    dshot;
    SetMovePosition02(GetClipMaxX-20, yIni, 240);
    wait(240);
    wait(60);
    SH=SH+180;

    SetMovePosition02(xIni, yIni, 20);
    wait(30);

          }
    }


    sub standBy{
            let wIni =60;
        SetMovePosition02(xIni, yIni, wIni);
    SetInvincibility(wIni);
   wait(wIni);  
CreateEventFromScript("VA");
loop{yield;   SetInvincibility(5);if(OnEvent()==false){break;}}
wait(30);
intro;
wait(45);
CutIn(KOUMA, "", "script\NN\warn.png", 64, 0, 432, 462);
 PlaySE("\koukaonn\warp3.wav");
PlayMusic("\bgm\MMX8_Boss-KM.mid");
  wait(120); 
SetText("");
 SetDamageRate(10, 10);




             }

  sub move{
    yield;

    loop {
   
       moveToPlayer(rand(130, 130), rand(-0, 0), 90,
                     GetClipMinX + 60, GetClipMinY + 32,
                     GetClipMaxX - 60, GetClipMinY + 60);
     loop(120) { yield; }
          }
       }
         task dshot{  loop(180){
                   CreateShot02(GetX-5, GetY+10, 10, 90+rand(-10,10),0,0, ORANGE21, 0);
                wait(1);
        }
        }
       task dshot2{  let AS=7;  let AD=0;
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,14,SH,0,0,9,PURPLE02);
loop(10){
AD=0;
CreateShotA(12,0,0,30-AS);
SetShotDataA(12,0,9,90,0,0,6,PURPLE04);
loop(50){
CreateShotA(13,0,0,20);
SetShotDataA(13,0,2,270,0,0,6,PURPLE12);
AddShot(AD,12,13,0);
AD=AD+4;
}
AddShot(AS,11,12,0);
AS=AS+3;
}
FireShot(11);


}
task fire{
    task setGraphicPose  {loop(3){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1); yield;}
loop(2){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*3,   128*0,  64*4,  128*1); yield;}
loop(25){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1); yield;} }
let a=1;
let b=rand_int(1,6);
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,1,90,0,0.5,9,RED03);
loop(100){
b=rand_int(1,12);
CreateShotA(12,rand(-30,30),rand(-30,30),30);
SetShotDataA(12,0,9,30*b,0,-0.5,2,ORANGE12);
AddShot(a,11,12,0);
a=a+1;
}
setGraphicPose;
wait(15); 
FireShot(11);

}
sub che{
  let SH=90;
let ANG=0;
   sub setGraphicPose1  {loop(12){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1); yield;}
loop(3){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*6,   128*0,  64*7,  128*1); yield;}
loop(5){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*7,   128*0,  64*8,  128*1); yield;}

 }
   task setGraphicPose  {loop(120){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*7,   128*0,  64*8,  128*1); yield;} }
      task shot{  let AS=0;  let AD=0;
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,9,ANG,0,0,9,RED04);
loop(8){
AD=0;
CreateShotA(12,0,0,0);
SetShotDataA(12,0,0,ANG+SH,0,0,6,RED12);
SetShotDataA(12,90-AD,3,ANG+SH,0,0,6,RED12);
AddShot(AS,11,12,0);
AS=AS+4;
SH=SH+180;
}
FireShot(11);


}

       task shot2{  let AS=0;  let AD=0;
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,9,ANG,0,0,9,PURPLE04);
loop(8){
AD=0;
CreateShotA(12,0,0,0);
SetShotDataA(12,0,0,ANG+SH,0,0,6,PURPLE12);
SetShotDataA(12,90-AD,3,ANG+SH,0,0,6,PURPLE12);
AddShot(AS,11,12,0);
AS=AS+4;
SH=SH+180;
}
FireShot(11);


}

       task shot3{  let AS=0;  let AD=0;
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,9,ANG,0,0,9,BLUE04);
loop(8){
AD=0;
CreateShotA(12,0,0,0);
SetShotDataA(12,0,0,ANG+SH,0,0,6,BLUE12);
SetShotDataA(12,90-AD,3,ANG+SH,0,0,6,BLUE12);
AddShot(AS,11,12,0);
AS=AS+4;
SH=SH+180;
}
FireShot(11);


}

       task shot4{  let AS=0;  let AD=0;
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,9,ANG,0,0,9,AQUA04);
loop(8){
AD=0;
CreateShotA(12,0,0,0);
SetShotDataA(12,0,0,ANG+SH,0,0,6,AQUA12);
SetShotDataA(12,90-AD,3,ANG+SH,0,0,6,AQUA12);
AddShot(AS,11,12,0);
AS=AS+4;
SH=SH+180;
}
FireShot(11);


}
setGraphicPose1;
setGraphicPose;
loop(30){
    shot;
ANG=ANG+6;
wait(3);
}
wait(30);
setGraphicPose;
loop(30){
    shot2;
ANG=ANG-6;
wait(3);
}
wait(30);
setGraphicPose;
loop(30){
    shot3;
ANG=ANG+6;
wait(3);
}
wait(30);
setGraphicPose;
loop(30){
    shot4;
ANG=ANG-6;
wait(3);
}
wait(120);

}



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


    sub setGraphicStop  {SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*0,  64*1,  128*1); }

    sub setGraphicLeft { SetGraphicAngle(180,0,0); SetGraphicRect(  64*0,   128*1,  64*2,  128*2); }
    sub setGraphicRight{ SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*1,  64*2,  128*2); }
   task intro  {loop(12){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1); yield;}
loop(3){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*6,   128*0,  64*7,  128*1); yield;}
loop(90){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*7,   128*0,  64*8,  128*1); yield;}}
    task setGraphicMove {
     loop{yield;
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } if(GetSpeedX > 0){
            setGraphicRight;
        } if(GetSpeed == 0){
          setGraphicStop;}
         }
    }


}}
#include_script".\BOSS VA.txt"