
script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  #include_function ".\function_cutin.txt"
  let imgNue = GetCurrentScriptDirectory ~ "Bya.png";
  let Cut = GetCurrentScriptDirectory ~ "MurCut.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 let cir = GetCurrentScriptDirectory ~ "circle.png";
 let cha = GetCurrentScriptDirectory ~ "ch.png";
 let spbg1 = GetCurrentScriptDirectory ~ "sp1.png";
 let spbg2 = GetCurrentScriptDirectory ~ "sp2.png";
  @Initialize {
 
  
   LoadUserShotData(qwe);
   
    SetLife(800000);
	SetY(-100);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(cha);
    LoadGraphic(Cut);
    LoadGraphic(spbg1);
    LoadGraphic(spbg2);
    
    InitializeAnimationData;
	
 
  
  
    Animate("nue", "idle", true);
   mus;
    ShowOffNueAnimation;
    
  }
  
  @MainLoop {SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
    yield ;
  }let wave=0;
  let x=0;let y=0;let z=0;let dir=60;let dor=60; let sa=0;
  @DrawLoop {
    
	  
	  
	 
	  
	  
	  
	   SetTexture(cir);SetAlpha(150);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(2+sin(wave)*0.2,2+sin(wave)*0.2);

wave+=3;x+=5;
	SetGraphicAngle(0, 0, x);
	DrawGraphic(GetX+5,GetY+2);
   
   //////
   //GetX + dir*cos(dor), GetY + dir*sin(dor);
   

	 
  
  
  
   
    SetTexture(imgNue);SetAlpha(255);SetGraphicScale(1,1);SetRenderState(ALPHA);
	  SetGraphicAngle(y, 0, 0);
    DrawAnimatedSprite("nue", GetX, GetY);
  }
  @BackGround{
  
  }
 task charge{
 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);
 Concentration02(30);
 Concentration02(30);
 wait(60);
 }
  task mus{}
  @Finalize {
  
  
  
    Explosion01(GetX,GetY,4,1,30);
   wait(3);
    Explosion01(GetX,GetY,4,1,30);
   wait(3);
    Explosion01(GetX,GetY,4,1,30);
   wait(3);
    Explosion01(GetX,GetY,4,1,30);
   wait(3);
    Explosion01(GetX,GetY,4,1,30);
   wait(3);
  }
  let angle=270;let sp=3;let a=0;let angle2=0;let xx=610;let yy=0;let an=0;let spd=1;
 let fi=0;let na=0;
 
 let a2=0;let gra=0;
 task fir{
 gra=rand_int(95,107);
 na=rand_int(5,15);
 loop(20){a2=a2+10;
 wait(10);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
 loop(na){
	CreateShotA(122,GetX,GetY,10);
   SetShotDataA(122,0,2,angle+a2,0,0,0,gra);
  
	FireShot(122);
	angle+=360/na;
}
 
 
 
 
 }}
 
 
 
 
 
 
 
 
  task ShowOffNueAnimation {
  
  
  
  
  
 
    wait(20);sp=0;
   
      SetMovePosition03(GetClipMaxX-100, GetCenterY-100, 20, 4);
      SetNueMoveAnimation("right"); charge;
      yield ;
      while(GetSpeed>0.1){yield;}
	 
     
	  wait(30);
	  
	
	  Animate("nue", "idle", true);
	  wait(120);
	  Animate("nue", "start cast", false);
	  wait(20);
	  loop(6) {PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira01.wav");
	   CreateEnemyFromScript("fam",GetX,GetY,0,0,0);
	  
	  
	  wait(19);
	  yield;
    }
	wait(10);
	Animate("nue", "stop cast", false);
	wait(60);
	
	 SetMovePosition03(GetClipMaxX+300, GetCenterY-100, 20, 4);
      SetNueMoveAnimation("right");
	wait(180);
	fi=1;
	loop{yield;
	wait(420);
	
	 SetMovePosition03(GetClipMinX-300, GetCenterY-100, 20, 4);
      SetNueMoveAnimation("left");
	fir;
	
	wait(420);
	
	 SetMovePosition03(GetClipMaxX+300, GetCenterY-100, 20, 4);
      SetNueMoveAnimation("right");
	fir;
	
	
  }}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  task SetNueMoveAnimation(direction) {
    if(direction == "left"){
      Animate("nue", "start move left", false);
      yield ;
      while(GetSpeed>0.1){
        yield ;
      }
      Animate("nue", "stop move left", false);
    }
    if(direction == "right"){
      Animate("nue", "start move right", false);
      yield ;
      while(GetSpeed>0.1){
        yield ;
      }
      Animate("nue", "stop move right", false);
    }
    wait(12);
    Animate("nue", "idle", true);
  }
  

  
  
 
  
  
  
  
  
  
  
  function wait(t){
    loop(t){yield;}
  }
  
  sub InitializeAnimationData {
    CreateAnimation("nue", "idle", 4);
    SetAnimationFrame("nue", "idle", 0, imgNue, 12, 0, 0, 96, 112);
    SetAnimationFrame("nue", "idle", 1, imgNue, 12, 96, 0, 192, 112);
    SetAnimationFrame("nue", "idle", 2, imgNue, 12, 192, 0, 288, 112);
    SetAnimationFrame("nue", "idle", 3, imgNue, 12, 288, 0, 384, 112);
    
    CreateAnimation("nue", "start move right", 4);
    SetAnimationFrame("nue", "start move right", 0, imgNue, 8, 0, 112, 96, 224);
    SetAnimationFrame("nue", "start move right", 1, imgNue, 8, 96, 112, 192, 224);
    SetAnimationFrame("nue", "start move right", 2, imgNue, 8, 192, 112, 288, 224);
    SetAnimationFrame("nue", "start move right", 3, imgNue, 8, 288, 112, 384, 224);
    
    CreateAnimation("nue", "stop move right", 3);
    SetAnimationFrame("nue", "stop move right", 0, imgNue, 4, 288, 112, 384, 224);
    SetAnimationFrame("nue", "stop move right", 1, imgNue, 4, 192, 112, 288, 224);
    SetAnimationFrame("nue", "stop move right", 2, imgNue, 4, 96, 112, 192, 224);
    
    CreateAnimation("nue", "start move left", 4);
    SetAnimationFrame("nue", "start move left", 0, imgNue, 8, 0, 224, 96, 343);
    SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 96, 224, 192, 343);
    SetAnimationFrame("nue", "start move left", 2, imgNue, 8, 192, 224, 288, 343);
    SetAnimationFrame("nue", "start move left", 3, imgNue, 8, 288, 224, 384, 343);
    
    CreateAnimation("nue", "stop move left", 3);
    SetAnimationFrame("nue", "stop move left", 0, imgNue, 4, 288, 224, 384, 343);
    SetAnimationFrame("nue", "stop move left", 1, imgNue, 4, 192, 224, 288, 343);
    SetAnimationFrame("nue", "stop move left", 2, imgNue, 4, 96, 224, 192, 343);
    
    CreateAnimation("nue", "start cast", 4);
    SetAnimationFrame("nue", "start cast", 0, imgNue, 6, 0,343,96,460);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 6, 96,343,192,460);
    SetAnimationFrame("nue", "start cast", 2, imgNue, 6, 192,343,288,460);
    SetAnimationFrame("nue", "start cast", 3, imgNue, 6, 288,343,384,460);

    
    CreateAnimation("nue", "stop cast", 4);
     SetAnimationFrame("nue", "stop cast", 0, imgNue, 6, 288,343,384,460);
      SetAnimationFrame("nue", "stop cast", 1, imgNue, 6, 192,343,288,460);
   SetAnimationFrame("nue", "stop cast", 2, imgNue, 6, 96,343,192,460);
    SetAnimationFrame("nue", "stop cast", 3, imgNue, 6, 0,343,96,460);
 
  }
}







  script_enemy fam{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "BF.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(180);
 SetGraphicAngle(0,0,-dir);
	SetGraphicRect(0,0,79,79);
	SetGraphicScale(1,1);
	DrawGraphic(GetX,GetY);
	
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir/2);
	SetGraphicRect(0,0,79,79);
	SetGraphicScale(1.3,1.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
  
  }
  let angle=0;
  task main{
  fire;
  f;
  loop{yield;
  SetMovePosition03(GetEnemyX+r*cos(dir),GetEnemyY+r*sin(dir),1,10);
  dir+=3;
  
  }
  
  }
  let angle2=0;
  task f{
  
  fi=1;
  
  }
  task fg{
  loop{yield;a++;}
  }
  let a=0;let s=0;
  task fire{
  fg;wait(300);
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);

 wait(90);
  loop(3000){
  wait(10);angle2=rand(0,360);s=rand_int(1,3);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan02.wav");
  loop(3){
  CreateShot01(GetEnemyX+r*cos(dir),GetEnemyY+r*sin(dir),s,angle2,192,5);
  angle2+=360/350;
  
  
  }
  
  
  
  
  
  }
  
  
  
  }
  
   function wait(t){
    loop(t){yield;}
  }
  }
  






