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

script_enemy_main {let us=0;
  #include_function ".\AnimationLib.dnh"
 let yh=0;let yu=0;
  let imgNue = GetCurrentScriptDirectory ~ "su.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
  let co=rand_int(1,5);
  let sp1= GetCurrentScriptDirectory ~ "sp1.png";
  let sp2= GetCurrentScriptDirectory ~ "sp2.png";
  let sp22= GetCurrentScriptDirectory ~ "spbg1.png";
  let spn= GetCurrentScriptDirectory ~ "sn1.png";
  
   let Cut = GetCurrentScriptDirectory ~ "sucut.png";
 #include_function ".\function_cutin.txt"
 //#include_function ".\fam1.txt"
  #include_function ".\Halo.txt"
   let imagefile4 = GetCurrentScriptDirectory ~ "1q.png";
  @Initialize { 
  
  //CreateAura01("RED",0,2);
   LoadUserShotData(qwe);
    SetLife(4000);
	SetTimer(40);
    //SetY(-120);
	yim;
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(Cut);
    LoadGraphic(imagefile4);
    LoadGraphic(sp1);
    LoadGraphic(spn);
    LoadGraphic(sp2);
    LoadGraphic(sp22);
    // SetDurableSpellCard;
	 
    InitializeAnimationData;
	  MagicCircle(false);
  
    Animate("nue", "idle", true);
   mus;
    ShowOffNueAnimation;
    // CreateAura01;
  }
  
  task yim{loop{yield;
  
   if(GetTimer<11&&GetTimer>=0){PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_timeout.wav");wait(60);}
 
  }}let dam=0;
  @MainLoop {
   yield ;
   
   if(dam==0){SetDamageRate(0,0);}
   if(dam==1){SetDamageRate(90,30);}
   
  SetCollisionA(GetX,GetY,10);
  SetCollisionB(GetX,GetY,10);
   
    }
  let wave=0;
  let x=0;
  
  let xx=0;
  let aa=0;
  let yy=0;
  
  task u{
  b;
  c;
  
  
  task c{
  wait(70);
  loop(13){
  yield;
  yy+=8;
  }
  
  loop(10){
  yield;
  yy+=4;
  }
  loop(5){
  yield;
  yy+=3;
  }
  
  loop(10){
  yield;
  yy+=2;
  }
  
  
  loop(10){
  yield;
  yy+=1;
  }
  
  
  
  
  
  
  }
  
  
  
  task b{
  
  loop(60){
  yield;
  xx+=6;
  }
  }
  task a{
  loop(60){yield;
  ss+=0.011111;
  }
  }
  
  a;
  loop(90){
  yield;
  aa+=2.8;
  }
  
  
  
  }let ss=0;let h=0;
  @DrawLoop {
  
  
  
	 
   
	    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);
  
  
	 
	 
	 
     SetTexture(spn);SetAlpha(aa);
 SetGraphicRect(0,0,1054,80);
	
	SetGraphicScale(1.05-ss,1.05-ss);


	SetGraphicAngle(0,-xx, 0);
	DrawGraphic(GetCenterX,GetCenterY-yy);
	 
	 
  
      
  
  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;
   
   
  
  
  
  
  
  }
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue1.mp3");}
  
  let col=0;
  
   @BackGround{
  
 
	 
	
  
   SetAlpha(255);
   SetTexture(imagefile4);SetColor(255,255,255);
      SetGraphicRect(0, 0, 1111, 1111);
SetGraphicScale(1,1);
      SetGraphicAngle(0, 0,180);
      DrawGraphic(GetCenterX,GetCenterY);
  
      SetTexture(sp1);SetAlpha(255);
 
	SetGraphicRect(0,0,384,448);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY);
	
	
	
	
	
	
	
	
  
   SetAlpha(67); SetColor(255,255,255);SetRenderState(ALPHA);
   SetTexture(sp22);SetColor(255,255,255);
      SetGraphicRect(0, 0, 1111, 1111);
SetGraphicScale(2,2);
      SetGraphicAngle(0, 0,x/24);
      DrawGraphic(GetCenterX-533,GetCenterY-133);
	  
	  col+=4;
	  
	  
	   SetTexture(sp2);
	SetColor(200+cos(col)*3,130+cos(col)*2,160+cos(col));
	 SetAlpha(255);
 SetRenderState(ALPHA);
	SetGraphicRect(0,0,-684-cx,848);
	SetGraphicScale(1,1);
	

cx+=1;
	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY);
	  
	  
	    SetTexture(sp2);
	SetColor(200+cos(col)*3,130+cos(col)*2,160+cos(col));
	 SetAlpha(110);
 SetRenderState(ALPHA);
	SetGraphicRect(0,0,-684-cx/1.434567,848);
	SetGraphicScale(1,1);
	

cx+=1;
	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY-50);
	  
	
  }
  
  let cx=0;
  let cx2=0;
  
  
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  
  
 
  

  
  task ShowOffNueAnimation {
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_fault.wav");
  
  
  
  
  
  
  
  
  
  
  
  //wait(60);
   if(GetX>GetCenterX){la=180;
	SetMovePosition03(GetCenterX, GetCenterY-50, 13, 3);
     Animate("nue", "start move right", false);}
	   if(GetX<GetCenterX){
	SetMovePosition03(GetCenterX, GetCenterY-50, 13, 3);
     Animate("nue", "start move right", false);}
	    if(GetX==GetCenterX){
	SetMovePosition03(GetCenterX, GetCenterY-50, 13, 3);
      Animate("nue", "start move right", false);}
      yield ;
	  la=0;
      while(GetSpeed>0.1){yield;}
wait(50);
Animate("nue", "stop move right", false);
wait(20);
      Animate("nue", "start cast", false);
	  wait(20);
	  
	  SetScore(30000);
	  u;
	  cutin("NAZRIN", "",Cut,0,0,256,512);dam=1;
	  //PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_boon01.wav");
	    
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_cat00.wav");
		
		 wait(20); 
		  Animate("nue", "stop cast", false);
	  wait(20);
	   Animate("nue", "idle", true);
	   
	   wait(60);
	   
	   
	   SetMovePosition03(GetCenterX, GetCenterY-80, 13, 4);
	   SetNueMoveAnimation("right");
	   
	
	   PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");

	 Concentration02(30);
 Concentration02(40);
 Concentration02(30);let fg=0;
 Concentration02(40);
 Concentration02(30);let anga=0;
 Concentration02(40);
 while(GetSpeed>0.1){yield;}
	  
	wait(100);
	  
	 
	  
	  
	   Animate("nue", "start cast", false);
	   
	   
	 wait(20);
	
	spiral;
	wait(300);
	   Animate("nue", "stop cast", false);
	   wait(20);
	    Animate("nue", "idle", true);
		
	   loop{
	   wait(60);
	      PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");

	 Concentration02(30);
 Concentration02(40);
 Concentration02(30);let fg=0;
 Concentration02(40);
 Concentration02(30);let anga=0;
 Concentration02(40);
 
	  
	wait(100);
	    Animate("nue", "start cast", false);
	   
	   
	 wait(20);
	
	spiral;
	wait(300);
	   Animate("nue", "stop cast", false);
	   wait(20);
	    Animate("nue", "idle", true);
	   
	   
	   }
	   
	   
	   
  }
  let mm3=0;
  let xs=0;
  let ys=0;
  
  task spiral{
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  loop(42){
 yield;
  xs+=3.4;
   //PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
		mm3+=14.633;
  CreateShotA(1,GetClipMaxX-xs, GetY,5);
		SetShotDataA(1,0,0,90-mm3,0,0,0,248);
			SetShotDataA(1,120,0.1,NULL,0,0,0,248);
			SetShotDataA(1,160,0.2,NULL,0,0,0,248);
			SetShotDataA(1,180,0.3,NULL,0,0,0,248);
			SetShotDataA(1,200,0.4,NULL,0,0,0,248);
			SetShotDataA(1,220,0.5,NULL,0,0,0,248);
			SetShotDataA(1,240,0.6,NULL,0,0,0,248);
			SetShotDataA(1,260,0.7,NULL,0,0,0,248);
			SetShotDataA(1,280,0.8,NULL,0,0,0,248);
			SetShotDataA(1,300,0.9,NULL,0,0,0,248);
			SetShotDataA(1,320,1.0,NULL,0,0,0,248);
			SetShotDataA(1,340,1.1,NULL,0,0,0,248);
		
				
				FireShot(1);
  
  CreateShotA(1,GetClipMinX+xs, GetY,5);
		SetShotDataA(1,0,0,90+mm3,0,0,0,248);
			SetShotDataA(1,120,0.1,NULL,0,0,0,248);
			SetShotDataA(1,160,0.2,NULL,0,0,0,248);
			SetShotDataA(1,180,0.3,NULL,0,0,0,248);
			SetShotDataA(1,200,0.4,NULL,0,0,0,248);
			SetShotDataA(1,220,0.5,NULL,0,0,0,248);
			SetShotDataA(1,240,0.6,NULL,0,0,0,248);
			SetShotDataA(1,260,0.7,NULL,0,0,0,248);
			SetShotDataA(1,280,0.8,NULL,0,0,0,248);
			SetShotDataA(1,300,0.9,NULL,0,0,0,248);
			SetShotDataA(1,320,1.0,NULL,0,0,0,248);
			SetShotDataA(1,340,1.1,NULL,0,0,0,248);
		
				
				FireShot(1);
  
  
  }
  
  ys=360;PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  loop(59){
 yield;
  ys+=3;
   //PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
		mm3+=24.633;
  CreateShotA(1,GetX-45*sin(ys), GetY+45*cos(ys),5);
		SetShotDataA(1,0,0,270+mm3,0,0,0,250);
			SetShotDataA(1,120,0.1,NULL,0,0,0,250);
			SetShotDataA(1,160,0.2,NULL,0,0,0,250);
			SetShotDataA(1,180,0.3,NULL,0,0,0,250);
			SetShotDataA(1,200,0.4,NULL,0,0,0,250);
			SetShotDataA(1,220,0.5,NULL,0,0,0,250);
			SetShotDataA(1,240,0.6,NULL,0,0,0,250);
			SetShotDataA(1,260,0.7,NULL,0,0,0,250);
			SetShotDataA(1,280,0.8,NULL,0,0,0,250);
			SetShotDataA(1,300,0.9,NULL,0,0,0,250);
			SetShotDataA(1,320,1.0,NULL,0,0,0,250);
			SetShotDataA(1,340,1.1,NULL,0,0,0,250);
		
				
				FireShot(1);
  
  CreateShotA(1,GetX+45*sin(ys), GetY+45*cos(ys),5);
		SetShotDataA(1,0,0,270-mm3,0,0,0,250);
			SetShotDataA(1,120,0.1,NULL,0,0,0,250);
			SetShotDataA(1,160,0.2,NULL,0,0,0,250);
			SetShotDataA(1,180,0.3,NULL,0,0,0,250);
			SetShotDataA(1,200,0.4,NULL,0,0,0,250);
			SetShotDataA(1,220,0.5,NULL,0,0,0,250);
			SetShotDataA(1,240,0.6,NULL,0,0,0,250);
			SetShotDataA(1,260,0.7,NULL,0,0,0,250);
			SetShotDataA(1,280,0.8,NULL,0,0,0,250);
			SetShotDataA(1,300,0.9,NULL,0,0,0,250);
			SetShotDataA(1,320,1.0,NULL,0,0,0,250);
			SetShotDataA(1,340,1.1,NULL,0,0,0,250);
		
				
				FireShot(1);
  
  
  
  }
  
  blow;
  let anan=0;
  let anan2=0;
  xs=0;ys=0;
  loop(15){
    CreateShot01(GetX,GetY,1.4,anan+180,204,10);
  CreateShot01(GetX,GetY,1.2,anan+180,204,10);
  
  CreateShot01(GetX,GetY,1,anan,206,10);
  CreateShot01(GetX,GetY,0.8,anan,206,10);
  anan+=360/15;
  }anan2+=21.5234;
  
  
  
  }
  

  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);
 
  }
  
  let wa=500;
  
  
  
  
  task blow{
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,5);
	Obj_SetAngle(obj,90+rand(-20,20));
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,229);
	ObjShot_SetDelay(obj,10);
	
	gf;let ry=0;
	task gf{
	
	
	
	loop(15){
		 wait(3);ry+=13.56754;
		 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
		 CreateShot01(Obj_GetX(obj),Obj_GetY(obj),1,Obj_GetAngle(obj)+ry,158,30);
		 CreateShot01(Obj_GetX(obj),Obj_GetY(obj),1,Obj_GetAngle(obj)-ry,158,30);
		 CreateShot01(Obj_GetX(obj),Obj_GetY(obj),1,Obj_GetAngle(obj)+180-5,150,0);
		 CreateShot01(Obj_GetX(obj),Obj_GetY(obj),1,Obj_GetAngle(obj)+180+5,150,0);
		 //CreateShot01(Obj_GetX(obj)-xy,Obj_GetY(obj),rand(0.1,0.2),270+rand(-5,5),56,10);
		
		}
	
	
	
	}
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);

let xy=0;let sp=0;let sp2=0;
  if(Obj_GetY(obj)>GetClipMaxY) 
         {
		 
		 
		 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_playerdead.wav");
		 
		  
		 loop(15){
		 xy+=4;
		 CreateShot01(Obj_GetX(obj)+xy,Obj_GetY(obj),rand(0.4,0.6),270+rand(-20,20),56,10);
		 CreateShot01(Obj_GetX(obj)-xy,Obj_GetY(obj),rand(0.4,0.6),270+rand(-20,20),56,10);
		
		}
		loop(20){
		 xy+=4;
		 CreateShot01(Obj_GetX(obj)+xy,Obj_GetY(obj),rand(0.2,0.4),270+rand(-10,10),56,10);
		 CreateShot01(Obj_GetX(obj)-xy,Obj_GetY(obj),rand(0.2,0.4),270+rand(-10,10),56,10);
		
		}
		loop(45){
		 xy+=4;
		 CreateShot01(Obj_GetX(obj)+xy,Obj_GetY(obj),rand(0.1,0.2),270+rand(-5,5),56,10);
		 CreateShot01(Obj_GetX(obj)-xy,Obj_GetY(obj),rand(0.1,0.2),270+rand(-5,5),56,10);
		
		}
		
		yield;
ObjShot_FadeDelete(obj)		;
         break;
                    }
  
  
  }
  
  
  
  }
  
  
  
}






////////////////////////////
