
#Title[NonSpell01]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  #include_function ".\Halo.txt"
  let imgNue = GetCurrentScriptDirectory ~ "su.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 
  @Initialize {
  
  //CreateAura01("RED",0,1);
   LoadUserShotData(qwe);
    SetLife(2000);
    //SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    //PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue.mp3");
    InitializeAnimationData;
	SetTimer(24);
  
    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;let h=0;
  @DrawLoop {
     SetTexture(imgNue);SetAlpha(255);
 SetGraphicRect(0,0,0,0);
	
	SetGraphicScale(1,1);


	SetGraphicAngle(la, 0, 0);
	DrawGraphic(GetX,GetY);
    DrawAnimatedSprite("nue", GetX, GetY-5*sin(h));
  

   h+=4;
   
	    SetTexture(cir);SetAlpha(aaaa);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(aq+sin(wave)*0.2,aq+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 gh{
 loop(110){
 aaaa+=2;
 aq+=0.02;
 
 wait(1);
 
 }
 
 }
 let yg=0;let yg2=0;
  task ShowOffNueAnimation {
  gh;
    wait(20);
	SetMovePosition03(GetCenterX, GetClipMinY+120, 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);
	  task rin{
	 loop(20){
	  CreateShot01(GetX,GetY,1,yg+yg2,12,10);
	  yg+=360/20;
	 }yg2+=17.345;
	 }
	  
     let asd=0;
     let asd2=0;
   loop{yield;
   rin;
    PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
	 loop(10){
	 nonb(1.5,20+asd+asd2);
	 nonb(1.75,20+asd+asd2);
	 nonb(2,20+asd+asd2);
	 
	 asd+=360/10;
	 
	 }asd2+=rand(120,360);
   
   SetMovePosition03(GetX-rand(20,40), GetY+rand(-10,10), 15, 4);
      SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}
   wait(12);
     PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
	 
	 rin;
	 loop(10){
	 nonb(1.5,20+asd+asd2);
	 nonb(1.75,20+asd+asd2);
	 nonb(2,20+asd+asd2);
	
	 asd+=360/10;
	 
	 }asd2+=rand(120,360);
   SetMovePosition03(GetX+rand(20,40), GetY+rand(-10,10), 15, 4);
      SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}
   wait(12);
      
   
   
   }
   
   
  }
  
  
  let as=0;
  let as2=0;
  let as22=0;
  let as222=0;
  let f=0;
 
  let la=0;
  task SetNueMoveAnimation(direction) {
    if(direction == "left"){la=180;
     Animate("nue", "start move right", false);
      yield ;
      while(GetSpeed>0.1){
        yield ;
      }
      Animate("nue", "stop move right", false);
    }
    if(direction == "right"){la=0;
      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, 65);
    SetAnimationFrame("nue", "idle", 1, imgNue, 8, 77, 0, 114, 65);
    SetAnimationFrame("nue", "idle", 2, imgNue, 8, 141, 0, 177, 65);
    SetAnimationFrame("nue", "idle", 3, imgNue, 8, 205, 0, 240, 64);
	
    SetAnimationFrame("nue", "idle", 4, imgNue, 8, 205, 0, 240, 64);
    SetAnimationFrame("nue", "idle", 5, imgNue, 8, 141, 0, 177, 65);
	 SetAnimationFrame("nue", "idle", 6, imgNue, 8, 77, 0, 114, 65);
	 SetAnimationFrame("nue", "idle", 7, imgNue, 8, 14, 0, 51, 65);
	
	
	
    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, 1, 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, 2, 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, 13,130,51,189);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 4, 81,130,109,191);
    SetAnimationFrame("nue", "start cast", 2, imgNue, 4, 146,130,174,190);
    SetAnimationFrame("nue", "start cast", 3, imgNue, 4, 210,130,238,189);
    
    
    CreateAnimation("nue", "stop cast", 4);
    SetAnimationFrame("nue", "stop cast", 0, imgNue, 4, 210,130,238,189);
    SetAnimationFrame("nue", "stop cast", 1, imgNue,  4, 146,130,174,190);
    SetAnimationFrame("nue", "stop cast", 2, imgNue, 4, 81,130,109,191);
    SetAnimationFrame("nue", "stop cast", 3, imgNue,  4, 13,130,51,189);
 
  }
  
  
  
  task nonb(s,an){
  
  
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,s);
	Obj_SetAngle(obj,an);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,106);
	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)+rand(-5,5));
                       ObjShot_SetGraphic(obj,96);
					   CreateShot01(Obj_GetX(obj),Obj_GetY(obj),4,4,195,20);
         break;
                    }

                    if(Obj_GetX(obj)>GetClipMaxX) 
         { Obj_SetAngle(obj,180-Obj_GetAngle(obj)+rand(-5,5));
		 ObjShot_SetGraphic(obj,96); CreateShot01(Obj_GetX(obj),Obj_GetY(obj),4,4,195,20);
                           break;
           
                    }
     if(Obj_GetY(obj)<GetClipMinY) 
         { Obj_SetAngle(obj,-Obj_GetAngle(obj)+rand(-5,5));
		 ObjShot_SetGraphic(obj,96); CreateShot01(Obj_GetX(obj),Obj_GetY(obj),4,4,195,20);
                           break;
           
                    }
  
  
  }
  
  
  
}



}














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)+rand(-5,5));
                       
         
                    }

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

      


	
	
	}}


