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

script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  #include_function ".\Halo.txt"
  let imgNue = GetCurrentScriptDirectory ~ "su.png";
  let imgNue2 = GetCurrentScriptDirectory ~ "sa.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 
  @Initialize {
  
  //CreateAura01("RED",0,1);
   LoadUserShotData(qwe);
    SetLife(4500);
    //SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(imgNue2);
    LoadGraphic(cir);
    //PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue.mp3");
    InitializeAnimationData;
	SetTimer(29);
  
    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;let cha=0;
  @DrawLoop {
     
	 
	 if(cha==0){SetTexture(imgNue);}
	 if(cha==1){SetTexture(imgNue2);}
	 
	 
	 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(255+aaaa);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(2+aq+sin(wave)*0.2,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);
 
 }
 
 }
 
 task gh2{
 loop(110){
 aaaa+=2;
 aq+=0.02;
 
 wait(1);
 
 }
 
 }
 
  task ShowOffNueAnimation {
  gh;
    wait(20);	SetMovePosition03(GetClipMaxX+100,GetCenterY-rand(-30,120), 20, 5);
       Animate("nue", "start move right", false);
      yield ;
      while(GetSpeed>0.1){yield;}
	  ani2;
	  Animate("nue", "start move right", false);
  yield;
	  SetX(GetClipMinX-100);
	   
	  SetY(GetCenterY);
imgNue=imgNue2;
cha=1;	  
	  
	  gh2;
	 yield;
	// Animate("nue", "start move right", false);
	 wait(1);
	 //SetNueMoveAnimation("right");
	  SetMovePosition03(GetCenterX, GetCenterY-110, 20, 4);
	yield;
     while(GetSpeed>0.1){yield;}
Animate("nue", "stop move right",false);
wait(20);
	 Animate("nue", "idle", true);
	 
	 
 wait(10);
	  	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);
 Concentration02(40);
 Concentration02(30);
 Concentration01(80);
 Concentration01(80);
 Concentration01(80);
 wait(60);
 wait(30);
 loop{nan=0;
	   Animate("nue", "start cast2", false);
	  wait(30);
	
	  stars;
	  Animate("nue", "stop cast2", false);
	  wait(20);
	  wait(60);
	  nan=1;
     let asd=0;
     let asd2=0;
   wait(180);
  }
  }
  
  let as=0;
  let as2=0;
  let as22=0;
  let as222=0;
  let f=0;
 
  let la=0;
  
  
  
  let yx=0;
  let ang2=0;
  let ang3=0;
  let ang4=0;
  task stars{
   PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
 
  task st1{
  loop(19){
  
  star(GetX-90+ox/2,GetY-90,ang);
  star(GetX-90,GetY-90+ox/2,ang);
 
  
  
 star(GetX+90-ox/2,GetY+90,ang);
  star(GetX+90,GetY+90-ox/2,ang);
  
  wait(1);
  ox+=20;
  }
  wait(240);blast;
  ox=0;
}
  
  
  st1;
  
 ox=0;
  
  
  
  }
  let yh=0;
  let yh2=0;
  let yh3=0;
  task blast{
  
  
  loop(30){
  
  
    PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  loop(10){
  
  CreateShot01(GetX,GetY,0.3+yh,yh2+yh3,14,5);
  yh2+=360/120;
  }yh3+=15.5344;yh+=0.05;
  wait(5);
  
  }yh=0;
  
  }
  
  let nan=0;
  let ox=0;let yt=rand(0,360);
  let oy=0;
  let ox2=0;
  let oy2=0;let ang=0;
  let gg=0;
  let cg=10;
  task star(x,y,ang){
  
 task star2(nap,an){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
 
 
 
 task ran{
 
 task ran2{
 
 //loop(20){Obj_SetSpeed(obj1,Obj_GetSpeed(obj1)+0.05);wait(5);}
 }
 
 
 
 }
 
 
let obj1=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj1,x);
	Obj_SetY(obj1,y);
	Obj_SetSpeed(obj1,0);
	
	
	Obj_SetAngle(obj1,atan2(GetY - Obj_GetY(obj1), GetX - Obj_GetX(obj1)));
	
	
	ObjShot_SetBombResist(obj1,true);
	ObjShot_SetGraphic(obj1,250);
	ObjShot_SetDelay(obj1,10);
	
//ran;

task ron{
  loop(15){
   Obj_SetX(obj1,Obj_GetX(obj1)+nap/100);
   yield;
   }
   }
  
  
  
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
  
   loop(13){
   Obj_SetX(obj1,Obj_GetX(obj1)+nap/80);
   yield;
   }
   loop(30){
   Obj_SetX(obj1,Obj_GetX(obj1)+nap/280);
   yield;
   }
    loop(30){
   Obj_SetX(obj1,Obj_GetX(obj1)+nap/480);
   yield;
   }
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_power0.wav");
  wait(20); 
    loop(15){
 
   Obj_SetSpeed(obj1,Obj_GetSpeed(obj1)+0.1);wait(5);
   
   
   if(cg==0){Obj_SetAngle(obj1,Obj_GetAngle(obj1)-2);}
   if(cg==1){Obj_SetAngle(obj1,Obj_GetAngle(obj1)+1);}
 
   
   
   }

   
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_power1.wav");
   
   
  
  
   Obj_SetSpeed(obj1,1.8);
   
  
  
  
  wait(60);
  
   loop(12){
  
   Obj_SetSpeed(obj1,Obj_GetSpeed(obj1)-0.07);wait(5);
   
  
   
   }
  
  
  
  
  
 }}

let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,x);
	Obj_SetY(obj,y);
	Obj_SetSpeed(obj,0);
	Obj_SetAngle(obj,atan2(GetY - Obj_GetY(obj), GetX - Obj_GetX(obj))+ang);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,125);
	ObjShot_SetDelay(obj,4);
	

	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	if(nan==1){
	
	star2(-180,90+yt);
	star2(180,90-yt);
	yield;
	Obj_Delete(obj);
	break;
	}
  
  
  
  }
  }
  
  
  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;}
  }
  
  task InitializeAnimationData {
  if(cha==0){
   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);

	
 }
  }
  
  
  sub ani2 {
    CreateAnimation("nue", "idle", 8);
    SetAnimationFrame("nue", "idle", 0, imgNue2, 13, 15, 2, 48, 61);
   
    SetAnimationFrame("nue", "idle", 1, imgNue2, 13, 79, 3, 112, 61);
    SetAnimationFrame("nue", "idle", 2, imgNue2, 13, 143, 3, 176, 61);
    SetAnimationFrame("nue", "idle", 3, imgNue2, 13, 207, 3, 240, 61);
	
	  SetAnimationFrame("nue", "idle", 4,  imgNue2, 13, 15, 2, 48, 61);
   
    SetAnimationFrame("nue", "idle", 5, imgNue2, 13, 79, 3, 112, 61);
    SetAnimationFrame("nue", "idle", 6, imgNue2, 13, 143, 3, 176, 61);
    SetAnimationFrame("nue", "idle", 7, imgNue2, 13, 207, 3, 240, 61);
	
	
    CreateAnimation("nue", "start move right", 4);
    SetAnimationFrame("nue", "start move right", 0, imgNue2, 8, 12, 65, 54, 125);
    SetAnimationFrame("nue", "start move right", 1, imgNue2, 8, 75, 65, 118, 125);
    SetAnimationFrame("nue", "start move right", 2, imgNue2, 1, 139, 65, 182, 122);
    SetAnimationFrame("nue", "start move right", 3, imgNue2, 8, 203, 65, 246, 122);
    
    CreateAnimation("nue", "stop move right", 4);
    SetAnimationFrame("nue", "stop move right", 0, imgNue2, 4, 203, 65, 246, 122);
    SetAnimationFrame("nue", "stop move right", 1, imgNue2, 4, 139, 65, 182, 122);
    SetAnimationFrame("nue", "stop move right", 2, imgNue2, 4, 75, 65, 118, 125);
    SetAnimationFrame("nue", "stop move right", 3, imgNue2, 4, 12, 65, 54, 125);
    
	
	
	
    CreateAnimation("nue", "start move left", 4);
    SetAnimationFrame("nue", "start move left", 0, imgNue2, 8, 203, 195, 245, 255);
    SetAnimationFrame("nue", "start move left", 1, imgNue2, 8, 139, 195, 182, 255);
    SetAnimationFrame("nue", "start move left", 2, imgNue2, 2, 75, 195, 118, 253);
    SetAnimationFrame("nue", "start move left", 3, imgNue2, 8, 11, 195, 54, 252);
    
    CreateAnimation("nue", "stop move left", 4);
    SetAnimationFrame("nue", "stop move left", 0, imgNue2, 4, 11, 195, 54, 252);
    SetAnimationFrame("nue", "stop move left", 1, imgNue2, 4,75, 195, 118, 253);
    SetAnimationFrame("nue", "stop move left", 2, imgNue2, 4, 139, 195, 182, 255);
    SetAnimationFrame("nue", "stop move left", 3, imgNue2, 4,  203, 195, 245, 255);
    
    CreateAnimation("nue", "start cast2", 3);
    SetAnimationFrame("nue", "start cast2", 0, imgNue2, 6, 10,147,46,215);
    SetAnimationFrame("nue", "start cast2", 1, imgNue2, 6, 74,139,110,215);
    SetAnimationFrame("nue", "start cast2", 2, imgNue2, 6, 138,131,174,215);
   
    
    
    CreateAnimation("nue", "stop cast2", 3);
    SetAnimationFrame("nue", "stop cast2", 0, imgNue2, 6, 138,131,174,215);
    SetAnimationFrame("nue", "stop cast2", 1, imgNue2,  6, 74,139,110,215);
    SetAnimationFrame("nue", "stop cast2", 2, imgNue2, 6, 10,147,46,215);
    

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

      


	
	
	}}


