
#Title[メットールエース１]
#Text[]
#ScriptVersion[2]


script_enemy_main {
  let imgBoss = "script\ザコ\Szako.PNG";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetCenterY;
  let Q=1;
let scoa=0;
@Initialize {

    SetLife(500);
            
    SetDamageRate(0, 0);
    LoadGraphic(imgBoss);
   SetTexture(imgBoss);   SetGraphicRect(0, 0, 64, 128);
SetGraphicRect(  0,   0,  64,  64);
    TMain;

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

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

@Finalize {ExtendPlayer(1);
if(scoa==0){
AddScore(500+500*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;
move;
loop{
                  Q=rand_int(1,2);
if(Q==1){shot1;}
if(Q==2){shot2;}
wait(40);
if(GetLife>200){wait(20);}
      }


      }


    sub standBy{
            let wIni =120;
        SetMovePosition02(xIni, yIni, wIni);
    SetInvincibility(wIni);
   wait(wIni);  
  CutIn(KOUMA, "", "script\ロククロ\warn.png", 64, 0, 432, 462);
 PlaySE("\koukaonn\warp3.wav");
  wait(120); 
SetText("");
SetDamageRate(10,10);
PlayMusic("\bgm\16-BattleTheme.mid");
Explosion01(GetX,GetY,10,0.5,30);
loop(5){yield;}
SetGraphicRect(  64,   0,  128,  64);
        CreateEnemyFromScript("met2", GetX, GetY, 0, 0, 0);

             }

task move{
loop{
        SetMovePosition02(GetClipMaxX-60, GetClipMinY+60, 60);
wait(90);
        SetMovePosition02(GetClipMinX+60, GetClipMinY+60, 60);
wait(90);
        SetMovePosition02(GetClipMaxX-60, GetClipMaxY-60, 60);
wait(90);
        SetMovePosition02(GetClipMinX+60, GetClipMaxY-60, 60);
wait(90);
        SetMovePosition02(GetClipMinX+60, GetCenterY, 30);
wait(60);
        SetMovePosition02(GetClipMaxX-60, GetCenterY, 60);
wait(90);
     }     
       }
    function wait(w) {
        loop(w) { yield; }
                    }

task shot1{
        loop(3){
           CreateShot02(GetX, GetY, 4, GetAngleToPlayer,0,0, PURPLE01, 0);
           CreateShot02(GetX, GetY, 4, GetAngleToPlayer+15,0,0, PURPLE01, 0);
           CreateShot02(GetX, GetY, 4, GetAngleToPlayer-15,0,0, PURPLE01, 0);

            loop(5){ yield;}}

}
task shot2{
let an=0;
        loop(6){
           CreateShot02(GetX, GetY, 5, an,-0.1,2, RED04, 30);
           CreateShot02(GetX, GetY, 5, an+30,-0.1,2, ORANGE04, 30);
an=an+60;
           }

}




    sub setGraphicStop  { SetGraphicRect(  0,   0,  64,  128); }
    task setGraphicPose  {loop(50){ SetGraphicRect( 192,   0, 256,  128);yield;} }
    sub setGraphicRight  { SetGraphicRect(128,   0, 192,  128); }
    sub setGraphicLeft { SetGraphicRect(64,   0, 128,  128); }

    task setGraphicMove {
     loop{yield;
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } if(GetSpeedX > 0){
            setGraphicRight;
        } if(GetSpeed == 0){
          setGraphicStop;}
         }


    }



}}
script_enemy met2 {
  let imgBoss = "script\ザコ\zako4.PNG";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetCenterY;
  let Q=1;

@Initialize {

    SetLife(600);
SetDamageRateEx(10,10,100,100);
    LoadGraphic(imgBoss);
   SetTexture(imgBoss);   SetGraphicRect(0, 0, 64, 128);
SetGraphicRect(  0,   0,  64,  64);
    TMain;

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

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

@Finalize {
    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 {

move;
loop{
                  Q=rand_int(1,2);
if(Q==1){shot1;}
if(Q==2){shot2;}
wait(40);
if(GetLife>200){wait(20);}
      }


      }


    sub standBy{
            let wIni =120;
        SetMovePosition02(xIni, yIni, wIni);
    SetInvincibility(wIni);
   wait(wIni);  
  CutIn(KOUMA, "", "script\ロククロ\warn.png", 64, 0, 432, 462);
 PlaySE("\koukaonn\warp3.wav");
  wait(120); 
SetText("");
 SetDamageRate(10, 10);
PlayMusic("\bgm\16-BattleTheme.mid");
Explosion01(GetX,GetY,10,0.5,30);
loop(5){yield;}
SetGraphicRect(  64,   0,  128,  64);

             }

task move{
loop{
        SetMovePosition02(GetClipMinX+60, GetClipMaxY-60, 60);
wait(90);
        SetMovePosition02(GetClipMaxX-60, GetClipMaxY-60, 60);
wait(90);
        SetMovePosition02(GetClipMinX+60, GetClipMinY+60, 60);
wait(90);
        SetMovePosition02(GetClipMaxX-60, GetClipMinY+60, 60);
wait(90);
        SetMovePosition02(GetClipMaxX-60, GetCenterY, 30);
wait(60);
        SetMovePosition02(GetClipMinX+60, GetCenterY, 60);
wait(90);
     }     
       }
    function wait(w) {
        loop(w) { yield; }
                    }

task shot1{
        loop(3){
           CreateShot02(GetX, GetY, 4, GetAngleToPlayer,0,0, PURPLE01, 0);
           CreateShot02(GetX, GetY, 4, GetAngleToPlayer+15,0,0, PURPLE01, 0);
           CreateShot02(GetX, GetY, 4, GetAngleToPlayer-15,0,0, PURPLE01, 0);

            loop(5){ yield;}}

}
task shot2{
let an=0;
        loop(6){
           CreateShot02(GetX, GetY, 5, an,-0.1,2, BLUE04, 30);
           CreateShot02(GetX, GetY, 5, an+30,-0.1,2, AQUA04, 30);
an=an+60;
           }

}




    sub setGraphicStop  { SetGraphicRect(  0,   0,  64,  128); }
    task setGraphicPose  {loop(50){ SetGraphicRect( 192,   0, 256,  128);yield;} }
    sub setGraphicRight  { SetGraphicRect(128,   0, 192,  128); }
    sub setGraphicLeft { SetGraphicRect(64,   0, 128,  128); }

    task setGraphicMove {
     loop{yield;
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } if(GetSpeedX > 0){
            setGraphicRight;
        } if(GetSpeed == 0){
          setGraphicStop;}
         }


    }



}}