
#Title[BOSS巇條榟]
#Text[]
#ScriptVersion[2]

script_enemy_main {
  let imgBoss = "script\朸榟\dotwasi.png";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetClipMaxY - 300;
  let anglew   = 90;
  let anglew2   = 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 X=GetX;
let Y=GetY;
let BLV=0;
 let Q=1;
let scoa=0;
 let D=1;
@Initialize {

    SetLife(1000);
    SetDamageRate(0, 0);
    LoadGraphic(imgBoss);
SetShotAutoDeleteClip(128,128,128,128);
LoadUserShotData(".\塇.txt");
   SetTexture(imgBoss); 
   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,3);
  if(GetLife<850){Q=rand_int(1,4);}
  if(GetLife<650){Q=rand_int(2,4);}
  if(GetLife<400){Q=rand_int(2,4);}
if(GetLife<500){
move;loop(60){shotw;yield;}wait(60);}wait(30);
if(Q==1){wing;}
if(Q==2){
    SetColor(179,218,253);
Concentration01(30);
SetColor(255,255,255);
  wait(30);
TOL;wait(60);}
if(Q==4){
DAIV;SetMovePosition02(GetCenterX,GetClipMinY-50,1);wait(1);SetMovePosition02(GetCenterX,GetClipMinY+150,60);wait(90);}
if(Q==3){
D=rand_int(0,1);
if(D==0){
SetMovePosition02(GetClipMinX-30,GetY,30);wait(30);
DASHR;
loop(rand_int(1,2)){
DASHL;
DASHR;}
SetMovePosition02(GetClipMaxX+30,GetClipMinY+100,1);wait(1);
SetMovePosition02(GetCenterX,GetClipMinY+100,20);wait(20);
}
else{
SetMovePosition02(GetClipMaxX+30,GetY,30);wait(30);
DASHL;
loop(rand_int(1,2)){
DASHR;
DASHL;}
SetMovePosition02(GetClipMinX-30,GetClipMinY+100,1);wait(1);
SetMovePosition02(GetCenterX,GetClipMinY+100,20);wait(20);
}
}



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

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

  task move{
  
loop(4){

       moveToPlayer(rand(0, 60), rand(-30, 20), 30,
                     GetClipMinX + 60, GetClipMinY + 32,
                     GetClipMaxX - 60, GetClipMinY + 60);
        loop(30) { yield; }
}
setGraphicPose;
wait(5);
loop(5){
CreateShot02(GetX,GetY,12,GetAngleToPlayer+30,0,0,AQUA31,0);
CreateShot02(GetX,GetY,12,GetAngleToPlayer,0,0,AQUA31,0);
CreateShot02(GetX,GetY,12,GetAngleToPlayer-30,0,0,AQUA31,0);
wait(6);
if(GetLife<300){
CreateShot02(GetX,GetY,12,GetAngleToPlayer+15,0,0,BLUE31,0);
CreateShot02(GetX,GetY,12,GetAngleToPlayer-15,0,0,BLUE31,0);
}
wait(6);
}
wait(55);
}
 sub shotw{
    yield;
let ag=10;

loop(4){


CreateShotA(3,GetX,GetY,0);
SetShotDataA(3,0,5,anglew,0,0,9,21);
anglew=anglew+7;
CreateShotA(4,GetX,GetY,0);
SetShotDataA(4,0,5,anglew2,0,0,9,21);
anglew2=anglew2-7;
CreateShotA(5,GetX,GetY,1);
SetShotDataA(5,0,5,anglew,0,0,9,21);
anglew=anglew+7;
CreateShotA(6,GetX,GetY,1);
SetShotDataA(6,0,5,anglew2,0,0,9,21);
anglew2=anglew2-7;

SetShotDataA(3,8,5,anglew,0,0,9,BLUE21);
SetShotDataA(4,8,5,anglew2,0,0,9,BLUE21);
SetShotDataA(5,8,5,anglew,0,0,9,BLUE21);
SetShotDataA(6,8,5,anglew2,0,0,9,BLUE21);

SetShotDataA(3,17,5,anglew,0,0,9,PURPLE21);
SetShotDataA(4,17,5,anglew2,0,0,9,PURPLE21);
SetShotDataA(5,17,5,anglew,0,0,9,PURPLE21);
SetShotDataA(6,17,5,anglew2,0,0,9,PURPLE21);



SetShotDataA(3,20,3,anglew+ag,0,0,9,BLUE12);
SetShotDataA(4,20,4,anglew2+ag,0,0,9,PURPLE12);
SetShotDataA(5,20,3,anglew+ag,0,0,9,BLUE12);
SetShotDataA(6,20,4,anglew2+ag,0,0,9,PURPLE12);
ag=ag+10;
FireShot(3);
FireShot(4);
FireShot(5);
FireShot(6);

}
anglew=anglew-42;
anglew2=anglew2+42;



}
sub DAIV{
 let angle   = 90;
  let angle2   = 90;
X=GetX;
Y=GetY;
task shot{
    yield;
let CX=X;
let CY=Y;
let sc=90;
angle=0;
loop(10){

CreateShotA(3,CX,CY,0);
angle=angle+180;
SetShotDataA(3,0,10,90,7,0,9,BLUE12);
SetShotDataA(3,sc,0,angle+135,0,0.2,4,BLUE31);
FireShot(3);
wait(5);
sc=sc-5;

}}
 task shot2{
    yield;
let CX=X;
let CY=Y;
let sc=90;
angle=0;
loop(10){

CreateShotA(3,CX,CY,0);
angle=angle+180;
SetShotDataA(3,0,10,90,7,0,9,PURPLE12);
SetShotDataA(3,sc,0,angle+45,0,0.2,4,PURPLE31);

FireShot(3);
wait(5);
sc=sc-5;

}
}
 task shot3{
    yield;
let CX=X;
let CY=Y;
let sc=90;
angle=0;
loop(2){
CreateShotA(3,GetX,GetY,0);
SetShotDataA(3,0,3,GetAngleToPlayer,0,0,5,AQUA04);
FireShot(3);
}

}

SetMovePosition01(GetClipMinX-60,GetClipMinY-60,18);
wait(30);
  loop(1){
angle=55;
SetMovePosition01(GetClipMaxX+60,GetClipMaxY+60,14);
daiv1;
loop(30){Y=GetY;X=GetX+80;wait(3);shot;}
SetMovePosition01(GetClipMaxX+60,GetClipMinY-60,18);
loop(10){if(GetLife<350){shot3;}wait(3);}
angle=125;
SetMovePosition01(GetClipMinX-60,GetClipMaxY+60,14);
daiv2;
loop(30){Y=GetY;X=GetX+80;wait(3);shot2;}
SetMovePosition01(GetClipMinX-60,GetClipMinY-60,18);
loop(10){if(GetLife<350){shot3;}wait(3);}
}

}
task wing{
let S=rand_int(1,2);
if(S==1){loop(4){CreateEnemyFromFile(GetCurrentScriptDirectory~"takar.txt",rand(-60,150),0,0,0,0);wait(20);}}
if(S==2){loop(4){CreateEnemyFromFile(GetCurrentScriptDirectory~"takal.txt",rand(266,476),0,0,0,0);wait(20);}}
}
task dashshot{
let angle=0;
wait(rand(0,3));
loop(15){
CreateShot02(GetX,GetY,1,angle+90,0.2,3,BLUE12,20);
CreateShot02(GetX,GetY,1,angle-90,0.2,4,PURPLE12,20);
angle=angle+180;
 wait(1);
 wait(1);

CreateShot02(GetX,GetY,1,angle+90,0.2,4,BLUE12,20);
CreateShot02(GetX,GetY,1,angle-90,0.2,3,PURPLE12,20);

angle=angle+180;
 wait(1);
 wait(1);

}
}
task dshsh{
if(GetLife<600){
loop(10){
CreateShot02(GetX,GetY,7,GetAngleToPlayer,0,9,AQUA31,0);
wait(4);
}}
}

sub DASHR{
SetMovePosition02(GetClipMinX-30,GetPlayerY,1);
yield;
dashshot;
dashR;

SetMovePosition01(GetClipMaxX+75,GetY,13);
wait(60);
}
 sub DASHL{
SetMovePosition02(GetClipMaxX+30,GetPlayerY,1);
yield;
dashshot;
dashL;

SetMovePosition01(GetClipMinX-75,GetY,13);
wait(60);
}
sub TOL{
  let angle   = 90;
  let angle2   = 90;
X=GetX;
Y=GetClipMinY;
   task setGraphicPose2  {
loop(5){SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;} 
loop(95){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(80){SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;} }
task stshot{
    yield;
let CX=X;
let CY=Y;
let sc=140;
angle=0;
loop(10){

CreateShotA(3,CX,CY,0);
angle=angle+180;
SetShotDataA(3,0,10,90,7,0,9,BLUE12);
SetShotDataA(3,sc,1,angle+45*rand_int(-1,1),0,0.2,4,BLUE31);

FireShot(3);
wait(5);
sc=sc-5;
SetPlayerY(GetPlayerY+1);


}}
SetMovePosition02(GetPlayerX,GetY ,20);
wait(30);
Y=GetClipMinY-5;
X=GetX+80;
setGraphicPose2;
loop(30){stshot;
Y=Y+40;
wait(3);}
wait(90);

}




    sub setGraphicStop  {SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*0,  64*1,  128*1); }
    task setGraphicPose  { loop(5){SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;} 
loop(60){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*4,   128*0,  64*5,  128*1);yield;} 
loop(2){SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;} 
loop(15){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*3,   128*0,  64*4,  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 daiv1{loop(120){ SetGraphicAngle(180,0,0); SetGraphicRect(  64*2,   128*1,  64*4,  128*2);yield;} }
    task daiv2{loop(120){SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*1,  64*4,  128*2);yield;} }
    task dashR{loop(60){SetGraphicAngle(180,0,0); SetGraphicRect(  64*0,   128*1,  64*2,  128*2);yield;} }
    task dashL{loop(60){ SetGraphicAngle(0,0,0); SetGraphicRect(  64*0,   128*1,  64*2,  128*2);yield;} }
task intro{
loop(5){SetGraphicAngle(0,0,0); SetGraphicRect(  64*2,   128*0,  64*3,  128*1);yield;} 
loop(50){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(110){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;
if(GetLife<500){SetGraphicAngle(0,0,0); SetGraphicRect(  64*5,   128*0,  64*6,  128*1);}

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