
#Title[VAVA2]
#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(1000);

    SetDamageRate(0, 0);
SetShotAutoDeleteClip(128,128,128,240);
    LoadGraphic(imgBoss);
   SetTexture(imgBoss);   SetGraphicRect(0, 0, 64, 128);

    TMain;

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

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

@Finalize {
if(scoa==0){
AddScore(7500+7500*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<700){Q=rand_int(2,3);}
  if(GetLife<500){Q=rand_int(3,3);}
  if(GetLife<300){Q=rand_int(4,4);}
if(Q==1){

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

    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(300);
    SH=SH+180;

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

          }
    }


    sub standBy{
            let wIni =60;
        SetMovePosition02(xIni, yIni, wIni);
    SetInvincibility(wIni);
   wait(wIni);  
CreateEventFromScript("VA2");
loop{yield;   SetInvincibility(5);if(OnEvent()==false){break;}}

wait(30);
setGraphicMove;
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);

}
sub  pop{
  let AG=90;
  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(55){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1); yield;} }
task shot{let aa=-30;
loop(3){
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,9,AG+aa,0,0,9,BLUE03);
let ss=AG+aa;
SetShotKillTime(11,41);
let as=-20;
loop(3){
CreateShotA(12,0,0,40);
SetShotDataA(12,0,14,ss+as+180,0,-0.5,5,AQUA02);
SetShotKillTime(12,51);
loop(4){
CreateShotA(13,0,0,30);
SetShotDataA(13,0,8,ss+as+rand(-20,20),0,-0.5,2,WHITE04);
AddShot(50,12,13,0);
}
AddShot(40,11,12,0);
as=as+20;
}
FireShot(11);
aa=aa+30;
}
}

task shot2{let aa=-45;
loop(4){
CreateShotA(21,GetX,GetY,0);
SetShotDataA(21,0,15,AG+aa,0,-0.7,1,RED03);
let ss=AG+aa;
SetShotKillTime(21,21);
let as=-20;
loop(3){
CreateShotA(22,0,0,40);
SetShotDataA(22,0,14,ss+as,0,-0.5,5,PURPLE02);
SetShotKillTime(22,41);
loop(4){
CreateShotA(23,0,0,30);
SetShotDataA(23,0,8,ss+as+rand(-20,20)+180,0,-0.5,2,YELLOW04);
AddShot(40,22,23,0);
}
AddShot(20,21,22,0);
as=as+20;
}
FireShot(21);
aa=aa+30;
}
}
        
        
setGraphicPose;
wait(20);
shot2;
wait(30);
shot;
wait(10);
SetMovePosition02(GetX+120, GetY, 30);
wait(90);
AG=135;
setGraphicPose;
wait(20);
shot2;
wait(30);
shot;
wait(10);
SetMovePosition02(GetX-240, GetY, 30);
wait(90);
AG=45;

setGraphicPose;
wait(20);
shot2;
wait(30);
shot;
wait(10);
SetMovePosition02(GetX+120, GetY, 30);
wait(90);
AG=90;

}

sub night{
 let AG=90;
task shot{


loop{
CreateLaserB(359,700,100,PURPLE01,80);
SetLaserDataB(359,0,0,0,0,0,0,90,0);
SetShotKillTime(359,280);
FireShot(359);
wait(280);
}
}
        
 task shot2{


loop{
wait(80);
loop(50){
CreateShot02(GetX+rand(-40,80),GetClipMaxY+rand(-40,20),5,rand(210,330),-1,1.5,RED11,60);
wait(4);
}
wait(80);
loop(50){
CreateShot02(GetX+rand(-80,40),GetClipMaxY+rand(-40,20),5,rand(210,330),-1,1.5,RED11,60);
wait(4);
}
}
}
 task shot3{
let a=90;

loop{

loop(36){
CreateShot02(GetX,GetY,9,a,-0.5,2,GREEN12,20);
a=a+10;
}
wait(60);

loop(36){
CreateShot02(GetX,GetY,9,a,-0.5,2,YELLOW12,20);
a=a+10;
}
wait(60);

loop(36){
CreateShot02(GetX,GetY,9,a,-0.5,2,BLUE12,20);
a=a+10;
}
wait(60);

}
}
task shot4{
let aa=90;
wait(40);
loop{
aa=90;
loop(10){
CreateShot02(GetX,GetY,9,aa,0,9,ORANGE04,0);
aa=aa+9;
wait(4);
}
wait(240);
aa=90;
loop(10){
CreateShot02(GetX,GetY,9,aa,0,2,AQUA04,20);
aa=aa-9;
wait(4);
}
wait(240);


}
}
SetMovePosition02(GetClipMaxX-20, GetY, 40);
shot;
shot2;
shot3;
shot4;
wait(40);

  loop{
wait(40);
SetMovePosition02(GetClipMinX+20, GetY, 240);
wait(280);

SetMovePosition02(GetClipMaxX-20, GetY, 240);
wait(240);

          }}

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

  sub setGraphicStop  {SetGraphicAngle(0,0,0); SetGraphicRect(  64*1,   128*0,  64*2,  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 VA2.txt"