#TouhouDanmakufu
#Title[NonSpell04]
#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("RED",0,2);
   LoadUserShotData(qwe);
    SetLife(3500);
   
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    //PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue.mp3");
    InitializeAnimationData;
	
  
    Animate("nue", "idle", true);
   mus;
    ShowOffNueAnimation;
    
  }let aq=0;
  let aaaa=0;
  let anglet=0;
  let anglet2=0;
  task scratch2{
  aaaa=60;
  loop(69){
  
  wait(1); PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  
  CreateShot01(GetX-30,GetY-40,3,aaaa+180,121,10);
  CreateShot01(GetX-30,GetY-40,3,aaaa+180,195,30);
  CreateShot01(GetX-30,GetY-40,3,-aaaa+180,121,10);
  
   CreateShot01(GetX-30,GetY-40,2.5,aaaa+180,121,10);
  CreateShot01(GetX-30,GetY-40,2.5,aaaa+180,195,30);
  CreateShot01(GetX-30,GetY-40,2.5,-aaaa+180,121,10);
  
  CreateShot01(GetX-30,GetY-40,2,aaaa+180,121,10);
  CreateShot01(GetX-30,GetY-40,2,aaaa+180,195,30);
  CreateShot01(GetX-30,GetY-40,2,-aaaa+180,121,10);
  
 aq+=0.1;
 aaaa+=-aq;
  }aq=0;aaaa=0;
  
  }
   task scratch{
  aaaa=60;
  loop(68){aq+=0.1;
  aaaa+=-aq;
  wait(1); PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  
  CreateShot01(GetX+30,GetY-10,3,aaaa,125,10);
  CreateShot01(GetX+30,GetY-10,3,aaaa,196,30);
  CreateShot01(GetX+30,GetY-10,3,-aaaa,125,10);
  
   CreateShot01(GetX+30,GetY-10,2.5,aaaa,125,10);
  CreateShot01(GetX+30,GetY-10,2.5,aaaa,196,30);
  CreateShot01(GetX+30,GetY-10,2.5,-aaaa,125,10);
  
   CreateShot01(GetX+30,GetY-10,2,aaaa,125,10);
  CreateShot01(GetX+30,GetY-10,2,aaaa,196,30);
  CreateShot01(GetX+30,GetY-10,2,-aaaa,125,10);
 
  
  }aq=0;aaaa=180;
  
  }
  @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);
	
	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_cardget.wav");
   DeleteMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue.mp3");
  }
  let angle=270;let sp=3;let a=0;let angle2=0;let afe=0;
  task bullet{
  
  
  let obj22=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj22,rand(GetClipMinX+20,GetClipMaxX-20));
	Obj_SetY(obj22,rand(GetClipMinY+20,GetClipMinY+150));
	Obj_SetSpeed(obj22,rand(0,1));
	
	
	
	Obj_SetAngle(obj22,90+rand(-10,10));
	
	
	ObjShot_SetBombResist(obj22,true);
	ObjShot_SetGraphic(obj22,201);
	ObjShot_SetDelay(obj22,30);
	

	while(!Obj_BeDeleted(obj22)){yield;
	Obj_SetAutoDelete(obj22,true);
	loop(40){wait(3);
	Obj_SetSpeed(obj22,Obj_GetSpeed(obj22)+0.09);
	
	}
  break;
  
  }
  
  
  
  
  
  
  
  
  
  
  }
 task Fire{
 loop{
 
 bullet;
 bullet;
 wait(15);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
 }
 
 
 
 
 
 
 
 
 
 }
  task ShowOffNueAnimation {
  
    wait(20);
	SetMovePosition03(GetClipMinX+115, GetClipMinY+rand(80, 120), 20, 4);
      SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}

      wait(30);
      Animate("nue", "start cast", false);
	  wait(5);
	  Fire;
      wait(30);
      Animate("nue", "stop cast", false);
      wait(16);
      Animate("nue", "idle", true);
      wait(60);
    loop {afe=rand(0.10,0.5);scratch2;
	 SetMovePosition03(GetClipMaxX-115, GetClipMinY+rand(80, 120), 20, 4);
      SetNueMoveAnimation("right");
     
      yield ;
      while(GetSpeed>0.1){yield;} 
	 
      wait(160);afe=rand(0.10,0.5);scratch;
     SetMovePosition03(GetClipMinX+115, GetClipMinY+rand(80, 120), 20, 4);
      SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}
	
      wait(160);
    }
  }
  
  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, 336);
    SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 96, 224, 192, 336);
    SetAnimationFrame("nue", "start move left", 2, imgNue, 8, 192, 224, 288, 336);
    SetAnimationFrame("nue", "start move left", 3, imgNue, 8, 288, 224, 384, 336);
    
    CreateAnimation("nue", "stop move left", 3);
    SetAnimationFrame("nue", "stop move left", 0, imgNue, 4, 288, 224, 384, 336);
    SetAnimationFrame("nue", "stop move left", 1, imgNue, 4, 192, 224, 288, 336);
    SetAnimationFrame("nue", "stop move left", 2, imgNue, 4, 96, 224, 192, 336);
    
    CreateAnimation("nue", "start cast", 5);
    SetAnimationFrame("nue", "start cast", 0, imgNue, 4, 0,336,96,448);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 4, 96,336,192,448);
    SetAnimationFrame("nue", "start cast", 2, imgNue, 4, 192,336,288,448);
    SetAnimationFrame("nue", "start cast", 3, imgNue, 4, 288,336,384,448);
    SetAnimationFrame("nue", "start cast", 4, imgNue, 4, 384,336,480,448);
    
    CreateAnimation("nue", "stop cast", 4);
    SetAnimationFrame("nue", "stop cast", 0, imgNue, 4, 384,336,480,448);
    SetAnimationFrame("nue", "stop cast", 1, imgNue, 4, 288,336,384,448);
    SetAnimationFrame("nue", "stop cast", 2, imgNue, 4, 192,336,288,448);
    SetAnimationFrame("nue", "stop cast", 3, imgNue, 4, 96,336,192,448);
 
  }
}


















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));
                        
           
                    }

      


	
	
	}}


