
#Title[BOSS仕様マンモス]
#Text[]
#ScriptVersion[2]


script_enemy_main {
  let imgBoss = "script\某マンモス\dotmanmo.png";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetClipMaxY - 300;
  let anglef   = 90;
       let ST=51;
       let FA=52;
       let IC=53;
       let BM=54;
       let EL=55;
       let CM=56;
       let OC=57;
       let AM=58;
let scoa=0;
let BLV=0;
 let Q=1;
@Initialize {

    SetLife(1000);
    SetDamageRate(0, 0);
    LoadGraphic(imgBoss);
   SetTexture(imgBoss);   SetGraphicRect(0, 0, 64, 128);
   setGraphicStop;
    setGraphicMove;
    TMain;

   }
@MainLoop {

    SetCollisionA(GetX, GetY, 24);
    SetCollisionB(GetX, GetY, 24);
   yield;

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

@Finalize {
if(scoa==0){
AddScore(2500*BLV+2500*BLV*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;
   hinoko;
    loop{
                  Q=rand_int(1,1);
  if(GetLife<800){Q=rand_int(1,2);}
shot;   
move;
shot2;
setGraphicPose;
loop(120) { yield; }
if(Q==1){wa;wait(90);} 
if(Q==2){SetMovePosition02(xIni, yIni-60, 30);wait(60);wall;loop(4){tama;wait(150);}wait(90);}
}
      }


    sub standBy{
            let wIni =60;
        SetMovePosition02(xIni, yIni-60, wIni);
    SetInvincibility(wIni);
   wait(wIni);  
CreateEventFromScript("FA");
loop{yield;   SetInvincibility(5);if(OnEvent()==false){break;}}
wait(30);
intro;
wait(60);
 CutIn(KOUMA, "", "script\ロククロ\warn.png", 64, 0, 432, 462);
 PlaySE("\koukaonn\warp3.wav");
  wait(120); 
SetText("");
 SetDamageRate(10, 10);
      BLV=2;
if(GetCommonDataEx("gokusi",ST)+GetCommonDataEx("gokusi",FA)+GetCommonDataEx("gokusi",CM)+GetCommonDataEx("gokusi",OC)+GetCommonDataEx("gokusi",BM)+GetCommonDataEx("gokusi",IC)+GetCommonDataEx("gokusi",EL)+GetCommonDataEx("gokusi",AM)<4){
 SetDamageRate(16,16);
      BLV=1;
}
PlayMusic("\bgm\FlameMammoth.mid");
             }

  sub move{
    yield;

      
       moveToPlayer(rand(0, 60), rand(-30, 20), 60,
                     GetClipMinX + 60, GetClipMinY + 32,
                     GetClipMaxX - 60, GetClipMinY + 60);
   wait(90);
          
       }
    function wait(w) {
        loop(w) { yield; }
                    }
  task shot {

loop(30){
loop(4){CreateShot02(GetX,GetY,3,anglef,0,0,RED04,0);
anglef=anglef+10;}
    anglef=anglef+19;wait(5);}
   }
 sub shot2 {  
  let angle2   = 90;
loop(30){
loop(4){CreateShot02(GetX,GetY,2,angle2+6,0.1,4,ORANGE03,60);angle2=angle2+90;}
    angle2=angle2+18;wait(1);}
}

sub wa{
    task setGraphicPose2  {loop(10){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;} }
       moveToPlayer(rand(60, 150), rand(-60, 40), 30,
                     GetClipMinX + 60, GetClipMinY + 32,
                     GetClipMaxX - 60, GetClipMinY + 60);
wait(30);
loop(5){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;}
loop(55){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*3,   128*0,  64*4,  128*1);yield;}

let Angle=GetAngleToPlayer; 
loop(3){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;}
loop(60){
if(GetLife<600){
Angle=GetAngleToPlayer;} 
setGraphicPose2;
CreateShotA(45,GetX,GetY,40);
SetShotDataA(45,0,8,Angle,0,0,9,ORANGE03);
SetShotDataA(45,1,8,Angle,rand(-1.5,1.5),0,9,ORANGE03);
SetShotDataA(45,25,8,NULL,0,0,9,ORANGE03);
CreateShotA(46,GetX,GetY,40);
SetShotDataA(46,0,8,Angle,0,0,9,RED03);
SetShotDataA(46,1,8,Angle,rand(-1.5,1.5),0,9,RED03);
SetShotDataA(46,25,8,NULL,0,0,9,RED03);


FireShot(45);
FireShot(46);
yield;
yield;

}

}
task wall{
   task setGraphicPose2  {loop(660){SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;} }
 sub w{let X=GetClipMinX-100; 
loop(1){

CreateLaserA(45,X,GetClipMinY,0,60,ORANGE01,30);
SetLaserDataA(45,0,0,0,10,1,90);
SetLaserDataA(45,35,0,0,0,1,90);
SetLaserDataA(45,90,0,0,0,1,90);
FireShot(45);

yield;

}

}
 sub w2{let X=GetClipMaxX+100; 
loop(1){

CreateLaserA(45,X,GetClipMinY,0,60,ORANGE01,30);
SetLaserDataA(45,0,180,0,10,1,90);
SetLaserDataA(45,35,180,0,0,1,90);
SetLaserDataA(45,90,180,0,0,1,90);
FireShot(45);

yield;

}}
setGraphicPose2; 
  loop(2){ 
if(GetLife<400){
       w;}
      wait(150);
if(GetLife<400){
       w2;}
      wait(150);
        }
}
sub tama{
let a=1;
let b=rand_int(1,6);
CreateShotA(11,GetX,GetY,0);
SetShotDataA(11,0,1,GetAngleToPlayer,0,0.5,9,RED03);
loop(100){
b=rand_int(1,12);
CreateShotA(12,rand(-30,30),rand(-30,30),30);
SetShotDataA(12,0,2,30*b,0,-0.5,2,ORANGE11);
AddShot(a,11,12,0);
a=a+1;
}
    SetColor(240,100,20);
Concentration01(60);
SetColor(255,255,255);
  wait(30);
FireShot(11);
}

task hinoko{

   loop{   

    CreateShotA(3594, rand(-60, 500), GetClipMaxY-rand(0,60), 90);
    SetShotDataA(3594, 0, 1, 270, 0, 0, 1, ORANGE05);
     FireShot(3594);
     if(GetLife>800){wait(8);}if(GetLife>500){wait(8);}if(GetLife>200){wait(8);}
    CreateShotA(3595, rand(-60, 500), GetClipMaxY-rand(0,60), 60);
    SetShotDataA(3595, 0, 1, 270, 0, 0, 1, RED05);
   FireShot(3595);
     if(GetLife>650){wait(8);}if(GetLife>350){wait(8);}if(GetLife>0){wait(8);}
   } 

}



   sub setGraphicStop  {SetGraphicAngle(0,0,0); SetGraphicRect(  0,   0,  64,  128); }
    task setGraphicPose  {

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

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