
#Title[儼戞堦宍懺]
#Text[]
#ScriptVersion[2]

script_enemy_main {
  let imgBoss = "script\朸傾僑\dot儼.PNG";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetClipMinY+60;
  let angle   = 90;
let scoa=0;
 let Q=1;
let ang3=90;
  let name    = "";

@Initialize {

    SetLife(1000);

    SetDamageRate(0, 0);

    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(5000+5000*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;
wait(60);
  loop{ 
             Q=rand_int(1,1);
  if(GetLife<750){Q=rand_int(1,2);}
  if(GetLife<500){Q=rand_int(2,3);}
  if(GetLife<300){Q=rand_int(3,3);}

SetMovePosition02(GetClipMaxX-20,GetClipMinY+30,20);
  wait(30);
loop(6){
shot2;
if(GetX<=GetCenterX){
       SetMovePosition02(GetClipMaxX-20,GetY+60,20);}
if(GetX>=GetCenterX){
       SetMovePosition02(GetClipMinX+20,GetY+60,20);}
          wait(20);

shot3;
 wait(15);
}
loop(5){
shot2;
if(GetX<=GetCenterX){
       SetMovePosition02(GetClipMaxX-20,GetY-60,20);}
if(GetX>=GetCenterX){
       SetMovePosition02(GetClipMinX+20,GetY-60,20);}
              wait(20);

shot3;
 wait(15);
}
        SetMovePosition02(xIni, yIni+30, 10);
   wait(20);  
if(Q==1){oodama;wait(60);}
if(Q==2){  setGraphicPoseR;   shot; wait(30); setGraphicATR;wait(120); }
if(Q==3){ SetMovePosition02(GetCenterX-90, GetClipMinY+30,10);
wait(20);BLEED;
  SetMovePosition02(GetCenterX+90, GetClipMaxY-30,30);wait(60);
BLEED2;wait(30);}
if(Q==4){oodama2;wait(60);}
}
  wait(60);  
        }
    


    sub standBy{
            let wIni =60;
        SetMovePosition02(xIni, yIni, wIni);
    SetInvincibility(wIni*2);
   wait(wIni);  
CreateEventFromScript("sigma");
loop{yield;   SetInvincibility(5);if(OnEvent()==false){break;}}
wait(30);
intro;
    setGraphicMove;
wait(30);
 CutIn(KOUMA, "", "script\儘僋僋儘\warn.png", 64, 0, 432, 462);
 PlaySE("\koukaonn\warp3.wav");
  wait(120); 
SetText("");
 SetDamageRate(16, 16);
PlayMusic("\bgm\BossStage2.mid");


             }

  sub move{
    yield;
       
       moveToPlayer(rand(60, 90), rand(-60, 60), 90,
                     GetClipMinX + 60, GetClipMinY + 32,
                     GetClipMaxX - 60, GetClipMinY + 60);
 loop(120) { yield; }
       }
    function wait(w) {
        loop(w) { yield; }
                    }

sub shot{  let ang=30;
let ang2=150;

loop(4){
CreateShotA(359,GetX,GetY-50,30);
SetShotDataA(359,0,6,ang,0,0,2,PURPLE03);
ang=ang+47;
CreateShotA(358,GetX,GetY-50,30);
SetShotDataA(358,0,6,ang2,0,0,2,GREEN03);
ang2=ang2-47;
SetShotKillTime(359,31);
SetShotKillTime(358,31);
loop(24)
{
CreateShotA(31,0,0,0);
SetShotDataA(31,0,3,ang3,0,0,2,PURPLE21);
ang3=ang3+15;
AddShot(30,359,31,0);
CreateShotA(32,0,0,0);
SetShotDataA(32,0,3,ang3,0,0,2,GREEN21);
AddShot(30,358,32,0);

}

FireShot(359);
FireShot(358);
}}

task shot2{
         loop(8){  CreateShot02(GetX, GetY, 5, GetAngleToPlayer,0,8, RED01, 0);wait(2);}
}
sub shot3{
let ang4=15;
         loop(12){  CreateShot02(GetX, GetY, 8, ang4,-0.2,2, AQUA04, 30);ang4=ang4+30;}
}
sub oodama{
RR;
wait(30);
SetColor(128,233,244);
 Concentration01(30);
 SetColor(255,255,255);
wait(30);
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetPlayerX,GetClipMinY,0,0,0);
wait(30);
 SetColor(128,233,244);
 Concentration01(30);
 SetColor(255,255,255);
wait(30);
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetPlayerX,GetClipMinY,0,0,0);
wait(30);
 SetColor(128,233,244);
 Concentration01(60);
 SetColor(255,255,255);
LL;
wait(60);
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetX+180,GetClipMinY,0,0,0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetX-180,GetClipMinY,0,0,0);
}
sub BLEED{		
let j=0;
let aa=0;
CreateLaserB(35,270,30,GREEN01,10);
SetLaserDataB(35,0,0,50,0,180,-6,180,-6);
SetLaserDataB(35,30,0,NULL,0,NULL,0,NULL,0);
SetShotKillTime(35,150);
loop(30){
j=0;
loop(9){
CreateShotA(34,0,0,30);
SetShotDataA(34,0,1.5,90,0,0,1.5,GREEN12);
AddShot(aa,35,34,j);
j=j+30;
}aa=aa+1;}
aa=60;
loop(12){
j=0;
loop(9){
CreateShotA(34,0,0,30);
SetShotDataA(34,0,1.5,90,0,0,1.5,GREEN12);

AddShot(aa,35,34,j);
j=j+30;
}aa=aa+5;}

FireShot(35);
setGraphicPoseL;
wait(60);
  SetMovePosition02(GetCenterX-90, GetClipMaxY-30,60);
setGraphicDash;
wait(90);
}
sub BLEED2{		
let j=0;
let aa=0;
CreateLaserB(35,270,30,GREEN01,10);
SetLaserDataB(35,0,0,50,0,0,-6,0,-6);
SetLaserDataB(35,30,0,NULL,0,NULL,0,NULL,0);
SetShotKillTime(35,150);
loop(30){
j=0;
loop(9){
CreateShotA(34,0,0,30);
SetShotDataA(34,0,1.5,90,0,0,1.5,GREEN12);
AddShot(aa,35,34,j);
j=j+30;
}aa=aa+1;}
aa=60;
loop(12){
j=0;
loop(9){
CreateShotA(34,0,0,30);
SetShotDataA(34,0,1.5,90,0,0,1.5,GREEN12);

AddShot(aa,35,34,j);
j=j+30;
}aa=aa+5;}

FireShot(35);
setGraphicATR;
wait(60);
  SetMovePosition02(GetCenterX+90, GetClipMinY+30,60);
setGraphicBack;
wait(90);

}
sub oodama2{
task RR2{setGraphicPoseR;wait(15);loop(360){setGraphicATR;yield;}}
task LL2{setGraphicPoseL;wait(60);loop(240){setGraphicATL;yield;}}
wait(30);
RR2;
SetColor(128,233,244);
 Concentration01(360);
 SetColor(255,255,255);
loop(5){
wait(30);
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetPlayerX,GetClipMinY,0,0,0);
wait(30);
}
LL2;
wait(60);
loop(6){
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetX+150,GetClipMinY,0,0,0);
wait(25);
CreateEnemyFromFile(GetCurrentScriptDirectory~"僜僯僢僋僽僂僁僁僁僁僁僁儉両.txt",GetX-150,GetClipMinY,0,0,0);
wait(25);
}
}

    sub setGraphicStop  { SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1); }
    sub setGraphicRight  { SetGraphicAngle(0,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1); }
    sub setGraphicLeft { SetGraphicAngle(180,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1); }
    task setGraphicPoseR  {loop(60){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*6,   128*0,  64*7,  128*1);yield;} }
    task setGraphicPoseL  {loop(60){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*6,   128*0,  64*7,  128*1);yield;} }
    task setGraphicATR  {loop(3){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*7,   128*0,  64*8,  128*1);yield;} 
loop(4){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*1,  64*2+1,  128*2);yield;}
loop(2){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*1,  64*4+1,  128*2);yield;}
loop(53){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*1,  64*6+1,  128*2);yield;}
}
   task setGraphicATL {loop(3){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*7,   128*0,  64*8,  128*1);yield;} 
loop(4){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*0,   128*1,  64*2+1,  128*2);yield;}
loop(2){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*2,   128*1,  64*4+1,  128*2);yield;}
loop(53){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*4,   128*1,  64*6+1,  128*2);yield;} }
sub intro{
loop(15){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*1,   128*0,  64*2,  128*1);yield;}
loop(4){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;}
loop(45){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*3,   128*0,  64*4,  128*1);yield;}
}

    task setGraphicDash  {loop(60){SetGraphicAngle(0,0,0); SetGraphicRect(  64*6,   128*1,  64*7,  128*2); yield;}}
    task setGraphicBack  {loop(60){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*7,   128*1,  64*8,  128*2);yield;} }
task RR{setGraphicPoseR;wait(15);loop(2){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*7,   128*0,  64*8,  128*1);yield;} 
loop(4){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*1,  64*2+1,  128*2);yield;}
loop(2){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*1,  64*4+1,  128*2);yield;}
loop(144){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*1,  64*6+1,  128*2);yield;}}

task LL{setGraphicPoseL;wait(60);setGraphicATL;wait(30);}
    task setGraphicMove {
     loop{yield;
        if(GetSpeedX < 0) {
            setGraphicLeft;
        } if(GetSpeedX > 0){
            setGraphicRight;
        } if(GetSpeed == 0){
          setGraphicStop;}
         }
    }

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