
#Title[再戦カメレオン]
#Text[]
#ScriptVersion[2]

script_enemy_main {
  let imgBoss = "script\ザコ\zako3.PNG";
  let frame   = 0;
  let xIni    = GetCenterX;
  let yIni    = GetClipMaxY - 400;
  let Q=1;
 let a=255;
let scoa=0;
@Initialize {
    SetLife(300);
             
    SetDamageRate(0, 0);
           SetEffectForZeroLife(0,0,0);
    LoadGraphic(imgBoss);
   SetTexture(imgBoss);   SetGraphicRect(0, 0, 64, 64);
setGraphicMove;
    TMain;

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

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

@Finalize {
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;
     kunai;
  loop{
                Q=rand_int(1,3);


if(Q==1){NORMALSHOT;move;}
if(Q==2){loop(10){a=255;yield;}CAMESTING;wait(60);}
if(Q==3){CAMESTING2;}
if(Q==4){tama;wait(60);}
if(Q==5){}
       move;
     
     }    
}


  sub standBy{
            let wIni =60;
        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);

             }

 sub move{

             SetMovePosition02(
                     rand(GetClipMinX + 50, GetClipMaxX - 50),
                     rand(GetClipMaxY - 300, GetClipMinY + 60),90);
wait(120);
       }
    function wait(w) {
        loop(w) { yield; }
                    }
  task kunai{
    yield;
loop{let s= rand(GetClipMinX,GetClipMaxX-50); 
     yield;       
  if(GetLife<500){
        loop(3){    CreateShotA(359,s, GetClipMinY,0);
            s=s+30;
            SetShotDataA(359,0,0,90,0,0,0,GREEN31);
            SetShotDataA(359,20,0,90,0,0.02,2,GREEN31);
            FireShot(359);}
         wait(30);
          }
}
  }


 task NORMALSHOT{let a=GetAngleToPlayer;
  loop(90){
            CreateShot01(GetX, GetY, 3, a, GREEN12, 30);
            CreateShot01(GetX, GetY, 3, a+10, BLUE12, 20);
            CreateShot01(GetX, GetY, 3, a-10, RED12, 10);
         a=a+123;
 wait(1);
   }
   }
task CAMESTING{
let A=rand_int(1,3);
sub aro{
  let an=GetAngleToPlayer;
 CreateLaserC(359,GetX,GetY,20,30,GREEN21,0);
SetLaserDataC(359,1,10,an,0,0,0);
 CreateLaserC(357,GetX,GetY,20,30,GREEN21,0);
SetLaserDataC(357,1,10,an+30,0,0,0); 
CreateLaserC(358,GetX,GetY,20,30,GREEN21,0);
SetLaserDataC(358,1,10,an-30,0,0,0);
let aa=1;
loop(100){
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,GREEN04);
 AddShot(aa,359,35,0);
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,GREEN04);
 AddShot(aa,357,35,0);
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,GREEN04);
 AddShot(aa,358,35,0);
 aa++;
 
}
FireShot(359);
FireShot(358);
FireShot(357);
}
 sub aro2{   let an=GetAngleToPlayer;
 CreateLaserC(359,GetX,GetY,20,30,BLUE21,0);
SetLaserDataC(359,1,10,an,0,0,0);
 CreateLaserC(357,GetX,GetY,20,30,BLUE21,0);
SetLaserDataC(357,1,10,an+30,0,0,0); 
CreateLaserC(358,GetX,GetY,20,30,BLUE21,0);
SetLaserDataC(358,1,10,an-30,0,0,0);
let aa=1;
loop(100){
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,BLUE04);
 AddShot(aa,359,35,0);
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,BLUE04);
 AddShot(aa,357,35,0);
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,BLUE04);
 AddShot(aa,358,35,0);
 aa++;

}
FireShot(359);
FireShot(358);
FireShot(357);
}
 sub aro3{   let an=GetAngleToPlayer;
 CreateLaserC(359,GetX,GetY,20,30,RED21,0);
SetLaserDataC(359,1,10,an,0,0,0);
 CreateLaserC(357,GetX,GetY,20,30,RED21,0);
SetLaserDataC(357,1,10,an+30,0,0,0); 
CreateLaserC(358,GetX,GetY,20,30,RED21,0);
SetLaserDataC(358,1,10,an-30,0,0,0);
let aa=1;
loop(100){
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,RED04);
 AddShot(aa,359,35,0);
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,RED04);
 AddShot(aa,357,35,0);
 CreateShotA(35,0,0,0);
 SetShotDataA(35,0,1.5,an-rand(90,270),0,0,0,RED04);
 AddShot(aa,358,35,0);
 aa++;


}
FireShot(359);
FireShot(358);
FireShot(357);
}
if(A==1){aro;}
if(A==2){aro2;}
if(A==3){aro3;}
}
task tama{
yield;
let aa=1;
let a=1;
let a2=1;
let ang=GetAngleToPlayer;
let ang1=ang;
let ang2=ang;
 SetColor(0,255,26);
 Concentration01(60);
 SetColor(255,255,255);
 CreateLaserC(355,GetX,GetY,30,12,GREEN21,30);
SetLaserDataC(355,0,10,ang,0,0,0);
loop(100){
 CreateShotA(35,0,0,40);
 SetShotDataA(35,0,0,ang,0,0,0,GREEN04);
 SetShotDataA(35,60-aa,2,ang+90,0,0,0,GREEN04);
 CreateShotA(36,0,0,40);
 SetShotDataA(36,0,0,ang,0,0,0,GREEN04);
 SetShotDataA(36,60-aa,2,ang-90,0,0,0,GREEN04);
 AddShot(aa+2,355,36,0);
 AddShot(aa,355,35,0);
 aa++;aa++;aa++;aa++;

}
FireShot(355);
loop(8){
CreateShotA(359,GetX,GetY,0);
SetShotDataA(359,1,10,ang1,0,0,0,AQUA01);
ang1=ang1+10;
SetShotDataA(359,13,0,ang,0,0,0,GREEN02);
SetShotDataA(359,30,a,ang,0,0,0,GREEN02);
SetShotKillTime(359,46);

a=a+1;
loop(3){
   CreateShotA(3,0,0,0);    
   CreateShotA(5,0,0,0);
   CreateShotA(9,0,0,0);
SetShotDataA(3,1,2,ang1,0,0,0,GREEN31);
SetShotDataA(5,1,1,ang1-50,0,0,0,RED31);
SetShotDataA(9,1,2,ang1-100,0,0,0,BLUE31);
 AddShot(45,359,3,0);
 AddShot(45,359,5,0);
 AddShot(45,359,9,0);
  }
FireShot(359);
}
loop(8){
CreateShotA(358,GetX,GetY,0);
SetShotDataA(358,1,10,ang2,0,0,0,AQUA01);
ang2=ang2-10;
SetShotDataA(358,13,0,ang,0,0,0,GREEN02);
SetShotDataA(358,30,a2,ang,0,0,0,GREEN02);
SetShotKillTime(358,46);

a2=a2+1;
loop(3){
   CreateShotA(3,0,0,0);    
   CreateShotA(5,0,0,0);
   CreateShotA(9,0,0,0);
SetShotDataA(3,1,2,ang2,0,0,0,GREEN31);
SetShotDataA(5,1,1,ang2+50,0,0,0,RED31);
SetShotDataA(9,1,2,ang2+100,0,0,0,BLUE31);
 AddShot(45,358,3,0);
 AddShot(45,358,5,0);
 AddShot(45,358,9,0);
  }
FireShot(358);
}
}
task CAMESTING2{
let A=rand_int(1,3);
sub aro{
  let an=GetAngleToPlayer;
 CreateLaserC(359,GetX,GetY,20,45,GREEN21,0);
SetLaserDataC(359,1,7.5,an,0,0,0);
 CreateLaserC(357,GetX,GetY,20,45,GREEN21,0);
SetLaserDataC(357,1,7.5,an+20,0,0,0); 
CreateLaserC(358,GetX,GetY,20,45,GREEN21,0);
SetLaserDataC(358,1,7.5,an-20,0,0,0);
let aa=1;

FireShot(359);
FireShot(358);
FireShot(357);
}
 sub aro2{   let an=GetAngleToPlayer;
 CreateLaserC(359,GetX,GetY,20,45,BLUE21,0);
SetLaserDataC(359,1,7.5,an,0,0,0);
 CreateLaserC(357,GetX,GetY,20,45,BLUE21,0);
SetLaserDataC(357,1,7.5,an+20,0,0,0); 
CreateLaserC(358,GetX,GetY,20,45,BLUE21,0);
SetLaserDataC(358,1,7.5,an-20,0,0,0);
let aa=1;

FireShot(359);
FireShot(358);
FireShot(357);
}
 sub aro3{   let an=GetAngleToPlayer;
 CreateLaserC(359,GetX,GetY,20,45,RED21,0);
SetLaserDataC(359,1,7.5,an,0,0,0);
 CreateLaserC(357,GetX,GetY,20,45,RED21,0);
SetLaserDataC(357,1,7.5,an+20,0,0,0); 
CreateLaserC(358,GetX,GetY,20,45,RED21,0);
SetLaserDataC(358,1,7.5,an-20,0,0,0);
let aa=1;

FireShot(359);
FireShot(358);
FireShot(357);
}
if(A==1){aro;}
if(A==2){aro2;}
if(A==3){aro3;}
}



    sub setGraphicStop  { SetGraphicRect(  0,   0,  64,  128); }
    task setGraphicPose  {loop(30){ SetGraphicRect( 192,   0, 256,  128);a=255;yield;} }
    task setGraphicPose2  {loop(60){ SetGraphicRect( 192,   0, 256,  128);a=255;yield;} }
    sub setGraphicRight  { SetGraphicRect(128,   0, 192,  128); }
    sub setGraphicLeft { SetGraphicRect(64,   0, 128,  128); }

    task setGraphicMove {
     loop{yield; 
          SetAlpha(a);
 
        if(a>0){  a=a-5;}
         }
    }


}}

