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

script_enemy_main {let us=0;
  #include_function ".\AnimationLib.dnh"
 let yh=0;let yu=0;
  let imgNue2 = GetCurrentScriptDirectory ~ "sa.png";
  let imgNue = GetCurrentScriptDirectory ~ "sa.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
  let co=rand_int(1,5);
  let sp1= GetCurrentScriptDirectory ~ "bgsa2.png";
  let sp2= GetCurrentScriptDirectory ~ "bgsa.png";
  let sp22= GetCurrentScriptDirectory ~ "spbg1.png";
  let spn= GetCurrentScriptDirectory ~ "sn4.png";
  
   let Cut = GetCurrentScriptDirectory ~ "sacut.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(4500);
	SetTimer(55);
    //SetY(-120);
	yim;
    LoadGraphic(imgNue2);
    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(70,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);


	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);
	 
	 
  
      wave+=3;x+=5;
   
	  
  
  
  
  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{
  
 
	
  
      SetTexture(sp2);SetAlpha(255);
 
	SetGraphicRect(0,0,384,448);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY);
	
	  SetTexture(sp1);SetAlpha(140);
 
	SetGraphicRect(0,0,384,800+col);
	SetGraphicScale(1,1);
col+=1;

	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY);
	
	
	  
	  
	
  }
  
  let cx=0;
  let cx2=0;
  
  task wind(x,y,otk,sp,an){
  
  
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,x);
	Obj_SetY(obj,y);
	Obj_SetSpeed(obj,sp);
	Obj_SetAngle(obj,an);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,54);
	ObjShot_SetDelay(obj,10);
	
wait(30);
 loop(20){
  Obj_SetAngle(obj,Obj_GetAngle(obj)+otk);
  wait(3);
  }
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	
 
  loop(40){
  Obj_SetAngle(obj,Obj_GetAngle(obj)-otk);
  wait(3);
  }
  loop(40){
  Obj_SetAngle(obj,Obj_GetAngle(obj)+otk);
  wait(3);
  }
  
  }}
  
  
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  
  
 
  

  let po=6;
  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");
		
		
		
		CreateEnemyFromScript("fam1",GetX,GetY,0,0,0);
		CreateEnemyFromScript("fam2",GetX,GetY,0,0,0);
		
		 wait(20); 
		  Animate("nue", "stop cast", false);
	  wait(20);
	   Animate("nue", "idle", true);
	   
	   wait(60);
	   
	   
	   SetMovePosition03(GetCenterX, GetCenterY-120, 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(40);
let yh=0;

PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");

loop(50){
//.//drop(GetClipMinX+yh,GetCenterY-150);
drop(GetClipMinX+yh,GetCenterY-120);




wait(2);
yh+=10;
}

spi1;
spi2;

thr;

wait(120);
fgw;

  }
  let mm3=0;
  let xs=0;
  let ys=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, 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, 64, 65, 118, 125);
    SetAnimationFrame("nue", "start move right", 2, imgNue2, 1, 130, 65, 182, 122);
    SetAnimationFrame("nue", "start move right", 3, imgNue2, 8, 195, 65, 246, 122);
    
    CreateAnimation("nue", "stop move right", 4);
    SetAnimationFrame("nue", "stop move right", 0, imgNue2, 4, 195, 65, 246, 122);
    SetAnimationFrame("nue", "stop move right", 1, imgNue2, 4,  130, 65, 182, 122);
    SetAnimationFrame("nue", "stop move right", 2, imgNue2, 4,  64, 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 cast", 3);
    SetAnimationFrame("nue", "start cast", 0, imgNue2, 6, 10,147,46,215);
    SetAnimationFrame("nue", "start cast", 1, imgNue2, 6, 74,139,110,215);
    SetAnimationFrame("nue", "start cast", 2, imgNue2, 6, 138,131,174,215);
   
    
    
    CreateAnimation("nue", "stop cast", 3);
    SetAnimationFrame("nue", "stop cast", 0, imgNue2, 6, 138,131,174,215);
    SetAnimationFrame("nue", "stop cast", 1, imgNue2,  6, 74,139,110,215);
    SetAnimationFrame("nue", "stop cast", 2, imgNue2, 6, 10,147,46,215);
    

 
  }
  let asd=0;
  let wa=500;
  
  
  
  
  let asd2=0;
  
  
  
  
  
  
  
  let angle=0;
  let angle2=0;
  let angle22=0;
  let angle1=0;
  let spp=0;
  
  let ff=0;
  let fff=0;
  
  task fgw{
  
  
  }
  
  task thr{
 
  
  }
  let sx=0;
  let sy=0;let syy=0;let waw=120;
  task spi2{
  wait(360);
  loop{PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
   loop(60){
  
  CreateShotA(1,GetX, GetY,5);
		SetShotDataA(1,0,4,90+90+45+angle2+angle22,-13,0,0,185);
			SetShotDataA(1,30,3,NULL,-12,0,0,185);
			SetShotDataA(1,40,2,NULL,-11,0,0,185);
			SetShotDataA(1,50,1.2,NULL,-0.2,0,0,185);
			
		
				
				FireShot(1);
				
				angle2+=360/60;
  }angle2=0;angle22+=26.23498;
  
  
  if(waw<20){waw=20;}
  wait(waw);
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
   loop(60){
  
  CreateShotA(1,GetX, GetY,5);
		SetShotDataA(1,0,4,90+90+45+angle2+angle22,-13,0,0,185);
			SetShotDataA(1,30,3,NULL,12,0,0,185);
			SetShotDataA(1,40,2,NULL,11,0,0,185);
			SetShotDataA(1,50,1.2,NULL,0.2,0,0,185);
			
		
				
				FireShot(1);
				
				angle2+=360/60;
  }angle2=0;angle22+=26.23498;
  
  
  if(waw<20){waw=20;}
  wait(waw);
  }
  
  }
  
  let step=0;
  task spi1{
  
  wait(120);
  
  loop{
  
  
  loop(10){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  step+=2;
  angle1+=13.23435;
  loop(3){
  CreateShotA(1,GetX, GetY,5);
		SetShotDataA(1,0,4,angle+angle1,3,0,0,26);
			SetShotDataA(1,30,3,NULL,2,0,0,26);
			SetShotDataA(1,40,2,NULL,1,0,0,26);
			SetShotDataA(1,50,1,NULL,0,0,0,26);
			
		
				
				FireShot(1);
				
				angle+=360/3;
  }
  
  wait(5);}
  
  
  
   loop(10){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  step+=2;
  angle1+=49.23435;
  loop(3){
  CreateShotA(1,GetX, GetY,5);
		SetShotDataA(1,0,4,angle-angle1,-3,0,0,26);
			SetShotDataA(1,30,3,NULL,-2,0,0,26);
			SetShotDataA(1,40,2,NULL,-1,0,0,26);
			SetShotDataA(1,50,1,NULL,0,0,0,26);
			
		
				
				FireShot(1);
				
				angle+=360/3;
  }
  
  wait(5);}
  
  
  if(step>100){
  
   loop(10){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  angle1+=49.23435;
  loop(3){
  CreateShotA(1,GetX, GetY,5);
		SetShotDataA(1,0,4,angle-angle1,-6,0,0,26);
			SetShotDataA(1,30,3,NULL,-5,0,0,26);
			SetShotDataA(1,40,2,NULL,-3,0,0,26);
			SetShotDataA(1,50,1,NULL,0,0,0,26);
			
		
				
				FireShot(1);
				
				angle+=360/3;
  }
  
  wait(5);}}
  
  
  
  if(step>150){
  
   loop(10){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  angle1+=49.23435;
  loop(3){
  CreateShotA(1,GetX, GetY,5);
		SetShotDataA(1,0,4,angle+angle1,5,0,0,27);
			SetShotDataA(1,30,3,NULL,4,0,0,27);
			SetShotDataA(1,40,2,NULL,13,0,0,27);
			SetShotDataA(1,50,1,NULL,0,0,0,27);
			
		
				
				FireShot(1);
				
				angle+=360/3;
  }
  
  wait(5);}}
  
  }
  
  
  
  
  }
  
  
  
  
  
  
  let asss=0;
  task drop(x,y){
  
  
  
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,x);
	Obj_SetY(obj,y);
	Obj_SetSpeed(obj,1);
	Obj_SetAngle(obj,90);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,153);
	ObjShot_SetDelay(obj,5);
	
	
task spe{
loop(20){
  Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.05);
  wait(2);
  }let lo=20;
lo+=10;
 loop(lo){
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.1);
  wait(2);
  }
  loop(lo+lo){
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);
  wait(2);
  }

loop{


 loop(lo+lo){Obj_SetY(obj,Obj_GetY(obj)+0.085);
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.1);
  wait(2);
  }
   loop(lo+lo){Obj_SetY(obj,Obj_GetY(obj)+0.085);
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);
  wait(2);
  }



}


}


	
	
spe;

	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
  
  
 
 
 
 
  
  }
  }
  
  
  
   task drop2(x,y){
  
  
  
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,x);
	Obj_SetY(obj,y);
	Obj_SetSpeed(obj,1);
	Obj_SetAngle(obj,90);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,153);
	ObjShot_SetDelay(obj,5);
	
	
task spe{
loop(20){
  Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.05);
  wait(2);
  }let lo=20;
lo+=10;
 loop(lo){
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);
  wait(2);
  }
  loop(lo+lo){
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.1);
  wait(2);
  }

loop{


 loop(lo+lo){
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);
  wait(2);
  }
   loop(lo+lo){
   Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.1);
  wait(2);
  }



}


}


	
	
spe;

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






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





script_enemy fam1{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "circle3.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(150);
 SetGraphicAngle(0,0,-dir*2);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(GetX,GetY);
	 dir+=3;
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir);
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.3,0.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
  
  }
  let angle=0;
  task main{
  
 let di=0;
 
 
 loop{di+=4;
 
bu;
SetMovePosition03(GetPlayerX+100*sin(di),GetPlayerY+100*cos(di),15,4);



SetPlayerY(GetPlayerY-0.2);

if(GetKeyState(VK_SLOWMOVE)== KEY_HOLD ){

if(GetKeyState(VK_LEFT)== KEY_HOLD ){
SetPlayerX(GetPlayerX-1);}

if(GetKeyState(VK_RIGHT)== KEY_HOLD ){
SetPlayerX(GetPlayerX+1);}

if(GetKeyState(VK_UP)== KEY_HOLD ){
SetPlayerY(GetPlayerY-1);}

if(GetKeyState(VK_DOWN)== KEY_HOLD ){
SetPlayerY(GetPlayerY+1);}


}

yield;
}


}
  
  
  task bu{
  
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,0);
	Obj_SetAngle(obj,GetAngle+180);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,250);
	ObjShot_SetDelay(obj,10);
  
  wait(10);
  
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	ObjShot_FadeDelete(obj);
	}
  
  
  }
  
  
   function wait(t){
    loop(t){yield;}
  }
  }
  






script_enemy fam2{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "circle3.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(150);
 SetGraphicAngle(0,0,-dir*2);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(GetX,GetY);
	 dir+=3;
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir);
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.3,0.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
  
  }
  let angle=0;
  task main{
  
 let di=0;
 
 
 loop{di+=4;
 
bu;
SetMovePosition03(GetPlayerX-100*sin(di),GetPlayerY-100*cos(di),15,4);



yield;
}


}
  
  
  
  
  task bu{
  
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,0);
	Obj_SetAngle(obj,GetAngle+180);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,250);
	ObjShot_SetDelay(obj,10);
  
  wait(10);
  
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	ObjShot_FadeDelete(obj);
	}
  
  
  }
  
  
  
   function wait(t){
    loop(t){yield;}
  }
  }
  











