
#Title[BOSS仕様ペンギン]
#Text[]
#ScriptVersion[2]


script_enemy_main {
  let imgBoss = "script\某ペンギン\dotpen.png";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetClipMaxY - 300;
       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;
loop{
                  Q=rand_int(1,2);
  if(GetLife<800){Q=rand_int(1,4);}
  if(GetLife<600){Q=rand_int(1,5);}
  if(GetLife<400){Q=rand_int(2,6);}


if(Q==1){SHOTGANICE; wait(60); }
if(Q==2){NORMALSHOT;wait(230);}
if(Q==3){KOUTEI; wait(60); }
if(Q==4){KOUTEI; wait(60); }
if(Q==6){loop(1){SHOTGANICE; wait(50);}loop(2){SHOTGANICE2; wait(50);}wait(10); }
if(Q==5){HUBUKI;snow;
loop(10){
       SetMovePosition02(GetPlayerX+rand(-90,90), GetClipMinY+30, 30);
        loop(30) { yield; }      } 
      SetMovePosition02(xIni, yIni, 30);
wait(30);
  }



         move;}


      }


    sub standBy{
            let wIni =60;
        SetMovePosition02(xIni, yIni, wIni);
    SetInvincibility(wIni);
   wait(wIni);  
CreateEventFromScript("IC");
loop{yield;   SetInvincibility(5);if(OnEvent()==false){break;}}
  wait(30); 
intro;
 wait(40); 
  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\ChillPenguin.mid");


             }

  sub move{
    yield;

        
       moveToPlayer(rand(60, 120), rand(-30, 20), 30,
                     GetClipMinX + 60, GetClipMinY + 32,
                     GetClipMaxX - 60, GetClipMinY + 60);
   wait(80);
          
       }
    function wait(w) {
        loop(w) { yield; }
                    }

task NORMALSHOT{
  let angle   = 90;
  let angle2   = 97;

  sub shot { setGraphicPose2;wait(15);   loop(40){ setGraphicPose; 
     CreateShotA(359, GetX, GetY, 0);
     SetShotDataA(359, 0, 7, angle, 0, 0, 1, WHITE01);
     angle = angle + 54;
     SetShotDataA(359, 20, 0, NULL, 0 , 0, 1, BLUE23);
     SetShotDataA(359, 40, 2, rand(60, 120), 0, 0, 1, BLUE23);
     yield;
   FireShot(359);
   wait(1);    }}
   
 sub shot2 {   loop(40){setGraphicPose;
 CreateShotA(3594, GetX, GetY, 0);
     SetShotDataA(3594, 0, 7, angle2, 0, 0, 1, AQUA01);
     angle2 = angle2 - 54;
     SetShotDataA(3594, 20, 0, NULL, 0, 0, 1, WHITE02);
     SetShotDataA(3594, 40, 4, angle2 - 120, 0 , 0, 1, WHITE02);
          yield;
   FireShot(3594);
   wait(1);   }}

shot;
shot2;
}

task SHOTGANICE{
  let angle   = 90;
 setGraphicPose2;wait(15); 
loop(6){

CreateShotA(11,0,0,0);
SetShotDataA(11,1,3,angle+135,0,0,9,BLUE23);
CreateShotA(22,0,0,0);
SetShotDataA(22,1,3,angle-135,0,0,9,BLUE23);
CreateShotA(33,0,0,0);
SetShotDataA(33,1,3,angle-90,0,0,9,BLUE23);
CreateShotA(44,0,0,0);
SetShotDataA(44,1,3,angle+90,0,0,9,BLUE23);
CreateShotA(3,0,0,0);
SetShotDataA(3,1,5,angle,0,0,9,WHITE01);
SetShotDataA(3,5,0,NULL,0,0,9,WHITE01);
CreateShotA(45,GetX,GetY,0);
SetShotDataA(45,1,7,GetAngleToPlayer,0,0,9,WHITE02);
angle=angle+60;

SetShotKillTime(3,61);
AddShot(60,3,11,0);
AddShot(60,3,22,0);
AddShot(60,3,33,0);
AddShot(60,3,44,0);
AddShot(20,45,3,0);

SetShotKillTime(45,21);
FireShot(45);

}
loop(12){

CreateShotA(11,0,0,0);
SetShotDataA(11,1,3,angle,0,0,9,AQUA23);
CreateShotA(22,0,0,0);
SetShotDataA(22,1,3,angle-180,0,0,9,AQUA23);
CreateShotA(33,0,0,0);
SetShotDataA(33,1,3,angle+90,0,0,9,AQUA23);
CreateShotA(44,0,0,0);
SetShotDataA(44,1,3,angle-90,0,0,9,AQUA23);
CreateShotA(5,0,0,0);
SetShotDataA(5,1,5,angle+15,0,0,9,WHITE01);
angle=angle+30;
SetShotDataA(5,10,0,NULL,0,0,9,WHITE01);
CreateShotA(46,GetX,GetY,0);
SetShotDataA(46,1,7,GetAngleToPlayer,0,0,9,WHITE02);

SetShotKillTime(5,61);
AddShot(60,5,11,0);
AddShot(60,5,22,0);
AddShot(60,5,33,0);
AddShot(60,5,44,0);
AddShot(20,46,5,0);

SetShotKillTime(46,21);
FireShot(46);
}
loop(6){

CreateShotA(11,0,0,0);
SetShotDataA(11,1,3,angle-210,0,0,9,WHITE23);
CreateShotA(22,0,0,0);
SetShotDataA(22,1,3,angle-190,0,0,9,WHITE23);
CreateShotA(33,0,0,0);
SetShotDataA(33,1,3,angle-160,0,0,9,WHITE23);
CreateShotA(44,0,0,0);
SetShotDataA(44,1,3,angle-170,0,0,9,WHITE23);
CreateShotA(9,0,0,0);
SetShotDataA(9,1,5,angle,0,0,9,WHITE01);
angle=angle+60;
SetShotDataA(9,15,0,NULL,0,0,9,WHITE01);
CreateShotA(47,GetX,GetY,0);
SetShotDataA(47,1,7,GetAngleToPlayer,0,0,9,WHITE02);
SetShotKillTime(9,61);
AddShot(60,9,11,0);
AddShot(60,9,22,0);
AddShot(60,9,33,0);
AddShot(60,9,44,0);
AddShot(20,47,9,0);


SetShotKillTime(47,21);
FireShot(47);
}
}
task SHOTGANICE2{
  let angle   = 90;
 setGraphicPose; 
loop(6){

CreateShotA(11,0,0,0);
SetShotDataA(11,1,3,angle+135,0,0,9,BLUE23);
CreateShotA(22,0,0,0);
SetShotDataA(22,1,3,angle-135,0,0,9,BLUE23);
CreateShotA(33,0,0,0);
SetShotDataA(33,1,3,angle-90,0,0,9,BLUE23);
CreateShotA(44,0,0,0);
SetShotDataA(44,1,3,angle+90,0,0,9,BLUE23);
CreateShotA(3,0,0,0);
SetShotDataA(3,1,5,angle,0,0,9,WHITE01);
SetShotDataA(3,5,0,NULL,0,0,9,WHITE01);
CreateShotA(45,GetX,GetY,0);
SetShotDataA(45,1,7,GetAngleToPlayer,0,0,9,WHITE02);
angle=angle+60;

SetShotKillTime(3,61);
AddShot(60,3,11,0);
AddShot(60,3,22,0);
AddShot(60,3,33,0);
AddShot(60,3,44,0);
AddShot(20,45,3,0);

SetShotKillTime(45,21);
FireShot(45);

}
loop(12){

CreateShotA(11,0,0,0);
SetShotDataA(11,1,3,angle,0,0,9,AQUA23);
CreateShotA(22,0,0,0);
SetShotDataA(22,1,3,angle-180,0,0,9,AQUA23);
CreateShotA(33,0,0,0);
SetShotDataA(33,1,3,angle+90,0,0,9,AQUA23);
CreateShotA(44,0,0,0);
SetShotDataA(44,1,3,angle-90,0,0,9,AQUA23);
CreateShotA(5,0,0,0);
SetShotDataA(5,1,5,angle+15,0,0,9,WHITE01);
angle=angle+30;
SetShotDataA(5,10,0,NULL,0,0,9,WHITE01);
CreateShotA(46,GetX,GetY,0);
SetShotDataA(46,1,7,GetAngleToPlayer,0,0,9,WHITE02);

SetShotKillTime(5,61);
AddShot(60,5,11,0);
AddShot(60,5,22,0);
AddShot(60,5,33,0);
AddShot(60,5,44,0);
AddShot(20,46,5,0);

SetShotKillTime(46,21);
FireShot(46);
}
loop(6){

CreateShotA(11,0,0,0);
SetShotDataA(11,1,3,angle-210,0,0,9,WHITE23);
CreateShotA(22,0,0,0);
SetShotDataA(22,1,3,angle-190,0,0,9,WHITE23);
CreateShotA(33,0,0,0);
SetShotDataA(33,1,3,angle-160,0,0,9,WHITE23);
CreateShotA(44,0,0,0);
SetShotDataA(44,1,3,angle-170,0,0,9,WHITE23);
CreateShotA(9,0,0,0);
SetShotDataA(9,1,5,angle,0,0,9,WHITE01);
angle=angle+60;
SetShotDataA(9,15,0,NULL,0,0,9,WHITE01);
CreateShotA(47,GetX,GetY,0);
SetShotDataA(47,1,7,GetAngleToPlayer,0,0,9,WHITE02);
SetShotKillTime(9,61);
AddShot(60,9,11,0);
AddShot(60,9,22,0);
AddShot(60,9,33,0);
AddShot(60,9,44,0);
AddShot(20,47,9,0);


SetShotKillTime(47,21);
FireShot(47);
}
}
task KOUTEI{
 sub shot{
if(GetLife>500){
CreateEnemyFromFile(GetCurrentScriptDirectory~"kooli.txt",GetX,GetY+30,0,0,0);}
if(500>=GetLife){loop(2){CreateEnemyFromFile(GetCurrentScriptDirectory~"kooli.txt",GetX+rand(-100,100),GetY+rand(0,60),0,0,0);}}

}
 shot;
  setGraphicPose3;
}
task HUBUKI{
let angle   = 90;
  let a=1;   loop(10){loop(3){ angle=rand(-45,45);
     CreateShotA(359, GetX, GetY, 0);
     SetShotDataA(359, 0, 5, GetAngleToPlayer+angle, 0, 0, 4, 01);
   loop(10){  CreateShotA(3592, 0, 0, 20);
     SetShotDataA(3592, 0, 1, GetAngleToPlayer+angle, 0, 0, 7, AQUA23);
        AddShot(a,359,3592,0);a=a+3;  }
   a=0;
       
       FireShot(359);
}
        wait(30);
      }

}
  task snow{  loop(1){   loop(75){   

    CreateShotA(3594, rand(-60, 500), GetClipMinY, 0);
    SetShotDataA(3594, 0, 4, 75, 0, 0, 3, WHITE05);
   

       yield;
     FireShot(3594);
     wait(1);
   } 
   loop(75){   

    CreateShotA(3594, rand(-60, 500), GetClipMinY, 0);
    SetShotDataA(3594, 0, 4, 105, 0, 0, 3, WHITE05);
   

       yield;
     FireShot(3594);
     wait(1);
   } }
   }






    sub setGraphicStop  {SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*0,  64*1,  128*1); }
    task setGraphicPose2{
loop(5){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*3,   128*0,  64*4,  128*1);yield;}
loop(45){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;}
 }
    task setGraphicPose{
loop(50){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;}
 }
    task setGraphicPose3{
loop(5){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;}
loop(5){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1);yield;}
loop(40){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*6,   128*0,  64*7,  128*1);yield;}
}
task intro{
loop(5){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;}
loop(5){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1);yield;}
loop(30){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*3,   128*0,  64*4,  128*1);yield;}
loop(70){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;}
}
    sub setGraphicRight  {SetGraphicAngle(0,0,0); SetGraphicRect(  64*1,   128*0,  64*2,  128*1); }
    sub setGraphicLeft {SetGraphicAngle(180,0,0); SetGraphicRect(  64*1,   128*0,  64*2,  128*1); }
    task setGraphicMove {
     loop{yield;
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } if(GetSpeedX > 0){
            setGraphicRight;
        } if(GetSpeed == 0){
          setGraphicStop;}
         }


    }



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