#TouhouDanmakufu
#Title[NonSpell03]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  #include_function ".\Halo.txt"
  let imgNue = GetCurrentScriptDirectory ~ "Nue.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 
  @Initialize {
  
  CreateAura01("ROSE",0,2);
   LoadUserShotData(qwe);
    SetLife(2500);
    //SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    //PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue.mp3");
    InitializeAnimationData;
	SetTimer(30);
  
    Animate("nue", "idle", true);
   mus;
    ShowOffNueAnimation;
    
  }let aq=0;
  let aaaa=0;
  let anglet=0;
  let anglet2=0;
  
  @MainLoop {
  
  SetCollisionA(GetX,GetY,10);
  SetCollisionB(GetX,GetY,10);
    yield ;
  }
  let wave=0;
  let x=0;
  @DrawLoop {
     SetTexture(imgNue);SetAlpha(255);
 SetGraphicRect(0,0,0,0);
	
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetX,GetY);
      DrawAnimatedSprite("nue", GetX, GetY);
   
	    SetTexture(cir);SetAlpha(210);
 
	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,GetY);
  
  
  

   
  }
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue1.mp3");}
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  let angle=270;let sp=3;let a=0;let angle2=0;
 
  task ShowOffNueAnimation {
  
    wait(20);
	SetMovePosition03(GetCenterX, GetClipMinY+130, 20, 4);
      SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}

	  	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);
 Concentration02(40);
 Concentration02(30);
 Concentration01(80);
 Concentration01(80);
 Concentration01(80);
 wait(60);
 wait(30);
	  
	  
      wait(30);
      Animate("nue", "start cast", false);
	  wait(10);
	  fire;
      wait(120);
      Animate("nue", "stop cast", false);
      wait(16);
      Animate("nue", "idle", true);
      wait(60);
   
   
   loop{yield;
   
   
  // fire2;
   SetMovePosition03(GetX-rand(20,40), GetY+rand(-10,10), 20, 4);
      SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}
   wait(30);
      Animate("nue", "start cast", false);
	  wait(10);
	  fire;
      wait(120);
      Animate("nue", "stop cast", false);
      wait(16);
      Animate("nue", "idle", true);
      wait(20);
   
   
   
    //fire2;
   SetMovePosition03(GetX+rand(20,40), GetY+rand(-10,10), 20, 4);
      SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}
   wait(30);
      Animate("nue", "start cast", false);
	  wait(10);
	  fire;
      wait(120);
      Animate("nue", "stop cast", false);
      wait(16);
      Animate("nue", "idle", true);
      wait(20);
   
   
   
   
   
   
   
   }
   
   
  }
  
  
  let as=0;
  let as2=0;
  let as22=0;
  let as222=0;
  let f=0;
  task fire{
   as=0;
  as2=0;
   as22=0;
   as222=0;
   f=0;
  
  loop(8){
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan00.wav");
  loop(10){
  
  
  //
  CreateShot01(GetX+as*cos(as22), GetY-20+as*sin(as22),2+as222,as2+f,62,5);
  CreateShot01(GetX-as*cos(as22), GetY-20+as*sin(as22),2+as222,as2-f,62,5);
  //
  as2+=360/10;
  
  }
  as+=20;
  as22+=3-as222*10;
  
  as222-=0.05;
  wait(5);
  f+=11.454;
  }
  
   loop(10){
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan00.wav");
  loop(10){
  
  
  //
  CreateShot01(GetX+as*cos(as22), GetY-20+as*sin(as22),1.5+as222,as2+f,63,5);
  CreateShot01(GetX-as*cos(as22), GetY-20+as*sin(as22),1.5+as222,as2-f,63,5);
  //
  as2+=360/10;
  
  }
  as+=-20;
  as22+=13-as222*10;
  
  as222-=0.01;
  wait(5);
  f+=rand(0,360);
  }fire2;
    as=0;
  as2=0;
   as22=0;
   as222=0;
   f=0;
  
  }
  
  let sp=0;
  task fire2{
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  
  
  
  //CreateShot01(GetX, GetY-15,0.75,as2+GetAngleToPlayer,201,5);
  //CreateShot01(GetX, GetY-15,1,as2+GetAngleToPlayer,201,5);
 CreateShot01(GetX, GetY-15,1.25,as2+GetAngleToPlayer,201,5);
 CreateShot01(GetX, GetY-15,1.5,as2+GetAngleToPlayer,201,5);
 CreateShot01(GetX, GetY-15,1.75,as2+GetAngleToPlayer,201,5);
CreateShot01(GetX, GetY-15,2,as2+GetAngleToPlayer,201,5);
 
 
 //CreateShot01(GetX, GetY-15,0.75,as2+GetAngleToPlayer+10,201,5);
  //CreateShot01(GetX, GetY-15,1,as2+GetAngleToPlayer+10,201,5);
 CreateShot01(GetX, GetY-15,1.25,as2+GetAngleToPlayer+10,201,5);
 CreateShot01(GetX, GetY-15,1.5,as2+GetAngleToPlayer+10,201,5);
 CreateShot01(GetX, GetY-15,1.75,as2+GetAngleToPlayer+10,201,5);
CreateShot01(GetX, GetY-15,2,as2+GetAngleToPlayer+10,201,5);
 
  //CreateShot01(GetX, GetY-15,0.75,as2+GetAngleToPlayer-10,201,5);
  //CreateShot01(GetX, GetY-15,1,as2+GetAngleToPlayer-10,201,5);
 CreateShot01(GetX, GetY-15,1.25,as2+GetAngleToPlayer-10,201,5);
 CreateShot01(GetX, GetY-15,1.5,as2+GetAngleToPlayer-10,201,5);
 CreateShot01(GetX, GetY-15,1.75,as2+GetAngleToPlayer-10,201,5);
CreateShot01(GetX, GetY-15,2,as2+GetAngleToPlayer-10,201,5);
 
  f+=rand(0,360);sp+=0.3;
  
  loop(30){
  
  CreateShot01(GetX, GetY-15,1,as2+f,202,5);

  as2+=360/30;
  }f+=rand(0,360);sp+=0.3;
  
  }
  
  
  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", 8);
    SetAnimationFrame("nue", "idle", 0, imgNue, 8, 14, 0, 51, 63);
    SetAnimationFrame("nue", "idle", 1, imgNue, 8, 77, 0, 114, 64);
    SetAnimationFrame("nue", "idle", 2, imgNue, 8, 141, 0, 177, 64);
    SetAnimationFrame("nue", "idle", 3, imgNue, 8, 205, 0, 241, 65);
	
    SetAnimationFrame("nue", "idle", 4, imgNue, 8, 205, 0, 241, 65);
    SetAnimationFrame("nue", "idle", 5, imgNue, 8, 141, 0, 177, 64);
	 SetAnimationFrame("nue", "idle", 6, imgNue, 8, 77, 0, 114, 64);
	 SetAnimationFrame("nue", "idle", 7, imgNue, 8, 14, 0, 51, 63);
	
	
    CreateAnimation("nue", "start move right", 4);
    SetAnimationFrame("nue", "start move right", 0, imgNue, 8, 12, 65, 54, 125);
    SetAnimationFrame("nue", "start move right", 1, imgNue, 8, 75, 65, 118, 125);
    SetAnimationFrame("nue", "start move right", 2, imgNue, 8, 139, 65, 182, 122);
    SetAnimationFrame("nue", "start move right", 3, imgNue, 8, 203, 65, 246, 122);
    
    CreateAnimation("nue", "stop move right", 4);
    SetAnimationFrame("nue", "stop move right", 0, imgNue, 4, 203, 65, 246, 122);
    SetAnimationFrame("nue", "stop move right", 1, imgNue, 4, 139, 65, 182, 122);
    SetAnimationFrame("nue", "stop move right", 2, imgNue, 4, 75, 65, 118, 125);
    SetAnimationFrame("nue", "stop move right", 3, imgNue, 4, 12, 65, 54, 125);
    
	
	
	
    CreateAnimation("nue", "start move left", 4);
    SetAnimationFrame("nue", "start move left", 0, imgNue, 8, 203, 195, 245, 255);
    SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 139, 195, 182, 255);
    SetAnimationFrame("nue", "start move left", 2, imgNue, 8, 75, 195, 118, 253);
    SetAnimationFrame("nue", "start move left", 3, imgNue, 8, 11, 195, 54, 252);
    
    CreateAnimation("nue", "stop move left", 4);
    SetAnimationFrame("nue", "stop move left", 0, imgNue, 4, 11, 195, 54, 252);
    SetAnimationFrame("nue", "stop move left", 1, imgNue, 4,75, 195, 118, 253);
    SetAnimationFrame("nue", "stop move left", 2, imgNue, 4, 139, 195, 182, 255);
    SetAnimationFrame("nue", "stop move left", 3, imgNue, 4,  203, 195, 245, 255);
    
    CreateAnimation("nue", "start cast", 4);
    SetAnimationFrame("nue", "start cast", 0, imgNue, 4, 14,127,55,191);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 4, 77,127,121,191);
    SetAnimationFrame("nue", "start cast", 2, imgNue, 4, 141,128,182,192);
    SetAnimationFrame("nue", "start cast", 3, imgNue, 4, 204,128,242,192);
    
    
    CreateAnimation("nue", "stop cast", 4);
    SetAnimationFrame("nue", "stop cast", 0, imgNue, 4,204,128,242,192);
    SetAnimationFrame("nue", "stop cast", 1, imgNue, 4,141,128,182,192);
    SetAnimationFrame("nue", "stop cast", 2, imgNue, 4, 77,127,121,191);
    SetAnimationFrame("nue", "stop cast", 3, imgNue, 4, 14,127,55,191);
 
  }
}


















let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,5);
	Obj_SetAngle(obj,rand(0,360));
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,203);
	ObjShot_SetDelay(obj,10);
	

	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	

  if(Obj_GetX(obj)<GetClipMinX) 
         {Obj_SetAngle(obj,180-Obj_GetAngle(obj));
                       
         
                    }

                    if(Obj_GetX(obj)>GetClipMaxX) 
         { Obj_SetAngle(obj,180-Obj_GetAngle(obj));
                        
           
                    }

      


	
	
	}}


