
#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 ~ "KE.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let cir2 = GetCurrentScriptDirectory ~ "circle.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
  let co=rand_int(1,5);
  let sp1= GetCurrentScriptDirectory ~ "spbg2.png";
  let sp2q= GetCurrentScriptDirectory ~ "sp2q5.png";
  let sp2= GetCurrentScriptDirectory ~ "sp25.png";
  let sp22= GetCurrentScriptDirectory ~ "spbg15.png";
  let spn= GetCurrentScriptDirectory ~ "sn8.png";
   let warr= GetCurrentScriptDirectory ~ "war2.png";
   let warrr= GetCurrentScriptDirectory ~ "war3.png";
  
   let Cut = GetCurrentScriptDirectory ~ "KeCut.png";
 #include_function ".\function_cutin.txt"
 //#include_function ".\fam1.txt"
  #include_function ".\Halo.txt"
   let imagefile4 = GetCurrentScriptDirectory ~ "1q.png";
  @Initialize { 
  
  
  SetEffectForZeroLife(60,120,1);
  //CreateAura01("RED",0,2);
   LoadUserShotData(qwe);
    SetLife(4500);
	SetTimer(40);
    //SetY(-120);
	SetCommonData("begin",0);
	
	CreateEventFromScript("test");
	yim;
    LoadGraphic(imgNue);
    LoadGraphic(warr);
    LoadGraphic(warrr);
    LoadGraphic(cir);
    LoadGraphic(cir2);
    LoadGraphic(Cut);
    LoadGraphic(imagefile4);
    LoadGraphic(sp1);
    LoadGraphic(spn);
    LoadGraphic(sp2);
    LoadGraphic(sp2q);
    LoadGraphic(sp22);
    // SetDurableSpellCard;
	 gro;
    InitializeAnimationData;
	  MagicCircle(false);
  
    Animate("nue", "idle", true);
   mus;d;
    ShowOffNueAnimation;
    // CreateAura01;
  }
  
  task yim{loop{yield;
  
   if(GetTimer<11&&GetTimer>=0){PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_timeout.wav");wait(60);}
 
  }}
  
  
 let da=0;
  task d{
  loop{
  
  if(da==0){
  SetDamageRate(0,0);}
   if(da==1){
  SetDamageRate(80,50);}
  
  yield;
  }}
  
  
  @MainLoop {
  
  SetCollisionA(GetX,GetY,30);
  SetCollisionB(GetX,GetY-40,20);
  SetCollisionB(GetX,GetY,30);
  SetCollisionB(GetX,GetY+10,30);
    yield ;
   
    }
  let wave=0;
  let x=0;
  let tt=0;
  let xx=0;
  let aa=0;
  let yy=0;
  
  task u{
  b;
  c;
  
  
  task c{
  wait(70);
  loop(13){
  yield;
  yy+=7.6;
  }
  
  loop(10){
  yield;
  yy+=4;
  }
  loop(10){
  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.033333;
  }
  }
  
  a;
  loop(90){
  yield;
  aa+=2.8;
  }
  
  
  
  }let ss=0;
  
   let x=0;let al=0;let si=0;
  let al1=0;let si1=0;
  task gro{
  gro2;
  loop(120){
  yield;
  al+=0.6;
  si+=0.003;
  }
  
  }
   task gro2{
  
  loop(190){
  wait(2);
  al1+=0.8;
  si1+=0.0015;
  }
  
  }
  
  task slime{
  
  loop{
  yield;
  
  if(GetKeyState(VK_SHOT)== KEY_HOLD ){
  

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

  CreateShot01(GetPlayerX-10,GetPlayerY-30,rand(0.2,0.6),rand(0,360),176,10);
  CreateShot01(GetPlayerX+10,GetPlayerY-30,rand(0.2,0.6),rand(0,360),176,10);
  
  }
  
  }
  
  }
  
  
  
task inca{wait(10);loop(175){yield;wa2+=4.5;}}
task deca{wait(60);loop(50){yield;wa2+=-4.5;}wa2=0;}
  
  
  @DrawLoop {
     
   if(tt==0){SetTimer(99);}
   
	    SetTexture(cir);SetAlpha(gral);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(1.9+sin(wave)*0.2,1.9+sin(wave)*0.2);


	SetGraphicAngle(0, 0, -x);
	DrawGraphic(GetX,GetY);
	
	
	    SetTexture(cir);SetAlpha(gral);
 
SetGraphicRect(0,0,128,127);
SetGraphicScale(1.9+sin(wave)*0.2,1.9+sin(wave)*0.2);

wave+=3;x+=2;
	SetGraphicAngle(0, 0, x);
	DrawGraphic(GetX,GetY);
  
  
	 
	 
     SetTexture(spn);SetAlpha(aa);
 SetGraphicRect(0,0,648,80);
	
	SetGraphicScale(2.6-ss,2.7-ss);


	SetGraphicAngle(0,-xx, 0);
	DrawGraphic(GetCenterX+5,GetCenterY-yy+30);
	 
	 
  
      
   
	   
  
  
     SetTexture(imgNue);SetAlpha(255);
 SetGraphicRect(0,0,0,0);
	
	SetGraphicScale(0.8,0.8);


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

   h+=4;
  
  
  
  SetGraphicAngle(0, 0, 0);
SetGraphicScale(0.8,0.8);
   
   
   
   
   
   
   
   
   ////////
   
   
	SetTexture(warr);SetAlpha(wa2);
 
	SetGraphicRect(0,0,8210+wx,36);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY+40);

	 wx+=2;
	
	
	
   SetTexture(warrr);SetAlpha(wa2);
 
	SetGraphicRect(0,0,8210-wx*1.5,36);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY);
	
   SetTexture(warr);SetAlpha(wa2);
 
	SetGraphicRect(0,0,8210-wx,36);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY-40);

   
  
   
   
    SetTexture(warr);SetAlpha(wa2);
 
	SetGraphicRect(0,0,8210-wx,36);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 90);
	DrawGraphic(GetClipMinX+50,GetCenterY);
   
   
    SetTexture(warr);SetAlpha(wa2);
 
	SetGraphicRect(0,0,8210+wx,36);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 90);
	DrawGraphic(GetClipMaxX-50,GetCenterY);
   
   
   
   
   
   
   
   //DrawText("Tenxka Shin",GetClipMinX,30,15,255);
  }let h=0;let ann=0;
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue1.mp3");}
  
  let gral=0;
  let gral2=0;
  
  let et2=0;
  let woo=90;
  
 
  
  
  
  
  
  
  
  
  task heart{
  
  let gr=0;
  
  //253
  
  
  
  
loop(20){
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");

  loop(20){
 CreateShotA(1,GetX, GetY,10);
		
		 SetShotDataA(1, 0, 2, gral2+et2, 2, 0,0, 197);
		 SetShotDataA(1, 60, 2, NULL, 1, 0,0, 197);
		 SetShotDataA(1, 120, 1, NULL, 0.3, 0,0, 197);
		 SetShotDataA(1, 121, 1, NULL, 0, 0,0, 197);

				FireShot(1);
  gral2+=360/20;
  }et2+=16.345;
  wait(woo);
  woo+=-9;
  if(woo<20){woo=20;}
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");

  loop(20){
 CreateShotA(1,GetX, GetY,10);
		
		 SetShotDataA(1, 0, 2, gral2-et2, -2, 0,0, 253);
		 SetShotDataA(1, 60, 2, NULL, -1, 0,0, 253);
		 SetShotDataA(1, 120, 1, NULL, -0.3, 0,0, 253);
		 SetShotDataA(1, 121, 1, NULL, 0, 0,0, 253);

				FireShot(1);
  gral2+=360/20;
  }et2+=16.345;
   wait(woo);
  
  }
  wait(60);
  let aaa=0;
  let wad=180;

  
  loop(6){
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");

	ShootShape(GetX, GetY, 1, 90+aaa,  39+gr,11, 3, 10);
	ShootShape(GetX, GetY, 1, 270+aaa,  39+gr, 11, 3, 10);
	ShootShape(GetX, GetY, 2, 45, 39+(gr+1), 11, 4, 15);
	aaa+=16.3455;
	
	wait(120);
  gr+=1;
  if(gr>12){gr=0;}
  
	
	}
	
	
	let aaa2=0;
  loop(6){
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");

	ShootShape(GetX, GetY,  0.8, 90+aaa,  69+gr,11, 5, 10);
	ShootShape(GetX, GetY,  1, 90+180+aaa,  69+(gr+1),11, 5, 10);
	
	aaa+=19.3455;
	//aaa2+=3.3455;
	
	wait(120);
  gr+=1;
  if(gr>12){gr=0;}
  
	
	}
	
	
	 loop(3){
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");

	ShootShape(GetX, GetY,  0.8, 90-aaa,  82+gr,11, 8, 10);
	
	
	aaa+=19.3455;
	aaa2+=3.3455;
	
	wait(120);
  gr+=1;
  if(gr>12){gr=0;}
  
	
	}
	
	 loop{
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");

	ShootShape(GetX, GetY,  0.8, 90-aaa,  82+gr,11, 8, 9);
	ShootShape(GetX, GetY,  1, 90-90-aaa-aaa/2,  82+(gr+1),11, 8, 9);
	ShootShape(GetX, GetY,  1.2, 90-180-aaa-aaa/3,  82+(gr+2),11, 8, 9);
	
	
	aaa+=19.3455;
	aaa2+=3.3455;
	
	wait(120);
  gr+=1;
  if(gr>12){gr=0;}
  
	
	}
	
  //ShootShape(x, y, speed, angle, graphic, delay, corners, bullets)
  }
  
  
  
  
  
   @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);
	
	
	  SetTexture(sp2);SetAlpha(185);
 
	SetGraphicRect(0,0,864,600);
	SetGraphicScale(1,1);


	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX-77,GetCenterY);
	
	
	
	 SetTexture(sp2q);SetAlpha(65);
 
	SetGraphicRect(0,0,-684,848+cx);
	SetGraphicScale(1,1);

cx+=0.5;
	SetGraphicAngle(0, 0, 0);
	DrawGraphic(GetCenterX,GetCenterY);
	
	
	
  
   SetAlpha(137);
   SetTexture(sp22);SetColor(255,255,255);
      SetGraphicRect(0, 0, 1111, 1111);
SetGraphicScale(1.7,1.7);
      SetGraphicAngle(0, 0,x/24);
      DrawGraphic(GetCenterX-133,GetCenterY-133);
	
  }
  
  let cx=0;
  let cx2=0;
  
  
  @Finalize {
    DeleteGraphic(imgNue);
   PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_pldead00.wav");
  }
  
  
 
   let gran=90;

  let wa2=0;
  let wx=0;
  task ShowOffNueAnimation {ForbidShot(true);
 // PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_fault.wav");
  
    FadeOutMusic(GetCurrentScriptDirectory ~ ".\Sounds\lastw.mp3",120);
  
  app;
  
  
  
  
  
  
  
  //wait(60);
   if(GetX>GetCenterX){
	SetMovePosition03(GetCenterX, GetCenterY-50, 13, 3);
      SetNueMoveAnimation("left");}
	   if(GetX<GetCenterX){
	SetMovePosition03(GetCenterX, GetCenterY-50, 13, 3);
      SetNueMoveAnimation("right");}
	    if(GetX==GetCenterX){
	SetMovePosition03(GetCenterX, GetCenterY-50, 13, 3);
      SetNueMoveAnimation("right");}
      yield ;
      while(GetSpeed>0.1){yield;}
wait(90);

loop{yield;if(GetCommonData("begin")==1){break;}}






	PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Samsara.mp3");
	
	
	  wait(90);
	  inca;
 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_alert.wav");
 
 
 wait(120);
 deca; wait(90);
	
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_power0.wav");

	 Concentration02(30);
 Concentration02(40);
 Concentration02(30);let fg=0;
 Concentration02(40);
 Concentration02(40);
 Concentration02(40);
 Concentration02(40);
 Concentration02(110);let anga=0;
 Concentration02(110);let anga=0;
 Concentration02(110);let anga=0;
 Concentration02(110);let anga=0;
 Concentration01(110);
wait(100);
wait(50);
      Animate("nue", "start cast", false);
	  wait(20);
	  
	  
	  
	  
	  SetScore(30000);
	  u;
	  cutin("NAZRIN", "",Cut,0,0,568,558);
	  //PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_boon01.wav");
	    
		 Explosion01(GetX,GetY,11,1,60);
		  Explosion01(GetX,GetY,16,1,270);
		  
		
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_cat00.wav");
  
  //
  //
  //
  let waw=120;
  LastSpell;
		//PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Samsara.mp3");

		slime;
		tt=1;
		SetTimer(110);
		wait(90);
		 
	   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);
	
    
	
	
	let asd=0;
	task lass{da=1;
	
	 task aglas{
  
  loop(23){
  
	 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  CreateShot01(GetX,GetY,2, 0+asd,123,20);
  CreateShot01(GetX,GetY,1.8, (0+asd)+5,123,20);
  CreateShot01(GetX,GetY,1.8, (0+asd)-5,123,20);
  CreateShot01(GetX,GetY,1.6, (0+asd)+10,123,20);
  CreateShot01(GetX,GetY,1.6, (0+asd)-10,123,20);
  wait(10);
  asd+=23.7234;
  }}
	 task aglas2{
  
  loop(23){
  
	 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  CreateShot01(GetX,GetY,2, 180-asd,123,20);
  CreateShot01(GetX,GetY,1.8, (180-asd)+5,123,20);
  CreateShot01(GetX,GetY,1.8, (180-asd)-5,123,20);
  CreateShot01(GetX,GetY,1.6, (180-asd)+10,123,20);
  CreateShot01(GetX,GetY,1.6, (180-asd)-10,123,20);
  wait(10);
  asd+=23.7234;
  }}
	aglas;
	
	 PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_lazer00.wav");
	
	CreateLaserA(0, GetX, GetY, 150, 20, 2,0);
SetLaserDataA(0, 0, 0, -1.9, 0, 0, 0);
SetShotKillTime(0, 260);
ascent(i in 0..60){
    ascent(j in 2..10){
        CreateShotA(1, 0, 0, 10);
        SetShotDataA(1, 0, 0, GetAngle+180+rand(-10,10), 0, 0.1,rand(1,2), 121);
        AddShot(i*6, 0, 1, j*15);
    }
}
FireShot(0);

wait(240);

	aglas2;
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_lazer00.wav");
	
	CreateLaserA(0, GetX, GetY, 150, 20, 2,0);
SetLaserDataA(0, 0, 180, 1.9, 0, 0, 0);
SetShotKillTime(0, 260);
ascent(i in 0..60){
    ascent(j in 2..10){
        CreateShotA(1, 0, 0, 10);
        SetShotDataA(1, 0, 0, -GetAngle+180+rand(-10,10), 0, 0.1,rand(1,2), 121);
        AddShot(i*6, 0, 1, j*15);
    }
}
FireShot(0);
	
	
	
	
	
	
wait(200);
  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);

let gg=0;


sd;
task sd{loop(1000){gg+=14.546;yield;}}


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



	CreateLaserA(0, GetX, GetY, 300, 20, 3,0);
SetLaserDataA(0, 0, 0, -1.9, 0, 0, 0);
SetShotKillTime(0, 130);
ascent(i in 0..30){
    ascent(j in 1..9){
        CreateShotA(1, 0, 0, 10);
        SetShotDataA(1, 0, 0, GetAngle+180+gg, 0, 0.1,1, 123);
        AddShot(i*8, 0, 1, j*35);
    }
}
FireShot(0);


	
	CreateLaserA(0, GetX, GetY, 300, 20, 3,0);
SetLaserDataA(0, 0, 180, 1.9, 0, 0, 0);
SetShotKillTime(0, 130);
ascent(i in 0..30){
    ascent(j in 1..9){
        CreateShotA(1, 0, 0, 10);
        SetShotDataA(1, 0, 0, -GetAngle+180-gg, 0, 0.1,1, 123);
        AddShot(i*8, 0, 1, j*35);
    }
}
FireShot(0);
	
	
	wait(180);
	
	
	
	 Animate("nue", "start cast", false);
	  wait(20);
	 let angar=0;
	 let angar5=0;
  let angar2=0;
  
  
  
  
  task bullets{
  loop(2){
  
  
  loop(6){ PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  bull(0-angar5);
  angar5+=-360/6;
  wait(10);
  }
   wait(60);
  
  loop(6){PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  bull(180+angar5);
  angar5+=-360/6;
  wait(10);
  }
  wait(60);
  
  }
  
  ////
  
  loop(2){
  
  
  loop(12){ PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  bull2(0-angar5);
  angar5+=-360/12;
  wait(5);
  }
   wait(120);
  
  loop(12){PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  bull2(180+angar5);
  angar5+=-360/12;
  wait(5);
  }
  wait(120);
  
  }
  }
  
  
  
  
  
	bullets;
	loop(3){
	
	
		loop(20){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  loop(10){
 CreateShot01(GetX,GetY,1,angar+angar2,161,10);
  angar+=360/10;
  }angar2+=rand(0,360);
  wait(10);

  }
	
	
	
	loop(10){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  loop(10){
 CreateShot01(GetX,GetY,1,angar+angar2,161,10);
  angar+=360/10;
  }angar2+=34.723423;
  wait(10);

  }
	loop(10){
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  loop(10){
 CreateShot01(GetX,GetY,1,angar+angar2,161,10);
  angar+=360/10;
  }angar2+=-34.723423;
  wait(10);

  }
	
	
	
	}
	
	//3
	task bull(an){
	

let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,2);
	Obj_SetAngle(obj,an);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,234);
	ObjShot_SetDelay(obj,10);
	
sp;

task sp{loop(20){Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);wait(5);}
wait(30);
Obj_SetAngle(obj, atan2(GetPlayerY - Obj_GetY(obj), GetPlayerX - Obj_GetX(obj)));
loop(30){Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.1);wait(3);}
}
	
	
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	wait(10);
	 CreateShot01(Obj_GetX(obj),Obj_GetY(obj),8,0,196,30);
	}
	}
	///
	
	task bull2(an){
	

let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,2);
	Obj_SetAngle(obj,an);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,233);
	ObjShot_SetDelay(obj,10);
	
sp;

task sp{loop(20){Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);wait(5);}
wait(30);
Obj_SetAngle(obj, atan2(GetPlayerY - Obj_GetY(obj), GetPlayerX - Obj_GetX(obj)));
loop(30){Obj_SetSpeed(obj,Obj_GetSpeed(obj)+0.1);wait(2);}
}
	
	
	while(!Obj_BeDeleted(obj)){yield;
	Obj_SetAutoDelete(obj,true);
	wait(10);
	 CreateShot01(Obj_GetX(obj),Obj_GetY(obj),8,0,200,30);
	}
	}
	
	
	///
	
	wait(120);
	
	heart;
	
	
	
	
	
	
	}
	
	
	
	
	
	
	
	
	
	
	
	

	Animate("nue", "start cast", false);
	  wait(20);
	  ////////////
	  
lass;
	  
	  
	  ////////////////////
	  wait(30); 
		  Animate("nue", "stop cast", false);
	 wait(20);
	   Animate("nue", "idle", true);
	 
		
		

    }
  
  task SetNueMoveAnimation(direction) {
  
     if(direction == "left"){ann=180;
      Animate("nue", "start move right", false);
      yield ;
      while(GetSpeed>0.1){
        yield ;
      }
      Animate("nue", "stop move right", false);
    }
   
  
   
    if(direction == "right"){ann=0;
      Animate("nue", "start move right", false);
      yield ;
      while(GetSpeed>0.1){
        yield ;
      }
      Animate("nue", "stop move right", false);
    }
    wait(18);ann=0;
    Animate("nue", "idle", true);
  }
  
  function wait(t){
    loop(t){yield;}
  }
 
  sub InitializeAnimationData {
     CreateAnimation("nue", "idle", 4);
    SetAnimationFrame("nue", "idle", 0, imgNue, rand_int(60,180),15, 10, 138, 176);

    SetAnimationFrame("nue", "idle", 1, imgNue, 12, 148,7, 272, 174);
    SetAnimationFrame("nue", "idle", 2, imgNue, 12, 283, 5, 410, 172);
     SetAnimationFrame("nue", "idle", 3, imgNue, 12, 148,7, 272, 174);
    
	
	
    CreateAnimation("nue", "start move right", 2);
    SetAnimationFrame("nue", "start move right", 0, imgNue, 8, 22, 185, 142, 351);
    SetAnimationFrame("nue", "start move right", 1, imgNue, 8, 156, 184, 277, 351);
   
    
    CreateAnimation("nue", "stop move right", 2);
    SetAnimationFrame("nue", "stop move right", 0,  imgNue, 8, 156, 184, 277, 351);
    SetAnimationFrame("nue", "stop move right", 1,  imgNue,8, 22, 185, 142, 351);
   
    
	
	
	
    CreateAnimation("nue", "start move left", 2);
    SetAnimationFrame("nue", "start move left", 0, imgNue, 8, 6, 285, 127, 408);
    SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 141, 286, 259, 407);
   
    
    CreateAnimation("nue", "stop move left", 2);
    SetAnimationFrame("nue", "stop move left", 0,imgNue, 8, 141, 286, 259, 407);
    SetAnimationFrame("nue", "stop move left", 1,imgNue, 8, 6, 285, 127, 408);
   
    
    CreateAnimation("nue", "start cast", 2);
   
    SetAnimationFrame("nue", "start cast", 0, imgNue, 12, 148,7, 272, 174);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 12, 283, 5, 410, 172);
   
    
    CreateAnimation("nue", "stop cast",2);
    SetAnimationFrame("nue", "stop cast", 0,imgNue, 12, 283, 5, 410, 172);
    SetAnimationFrame("nue", "stop cast", 1,imgNue, 12, 148,7, 272, 174);
    
  } let wa=500;
 let yt=0;
  
  
  let waw=3;
  
  let ana=0;
  let ana2=0;
  let ana3=0;
  task fi{
  
  
  loop(40){
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  
  
  
  
//CreateShot01(GetX+18, GetY-13,rand(1.5,1.8),315-ana2,204,10);




 CreateShotA(1,GetX+18, GetY-13,30);
		SetShotDataA(1,0,rand(1.5,1.8),315-ana,rand(0,-0.7),0,0,204);
		SetShotDataA(1,180,NULL,NULL,0,0,0,204);

				FireShot(1);

  
  
  if(waw<10){
  
 CreateShotA(1,GetX+18, GetY-13,10);
		SetShotDataA(1,0,rand(1.5,1.8),315-ana,rand(0,-0.7),0,0,204);
	SetShotDataA(1,180,NULL,NULL,0,0,0,204);
				FireShot(1);

				
 CreateShotA(1,GetX+18, GetY-13,10);
		SetShotDataA(1,0,rand(0.5,1.8),315-ana,rand(0,-0.3),0,0,204);
	SetShotDataA(1,180,NULL,NULL,0,0,0,204);
				FireShot(1);

  }
  
  
  ana2+=ana3;
  ana+=ana3/1.5;
  ana3+=0.9824435;
  
  
  
  wait(waw);
  waw+=-3;
  if(waw<2){waw=2;}
  }
  fir;
  
   waw=3;
  
   ana=0;
   ana2=0;
   ana3=0;
  
  
  
  }
  
  
  
  
  /////////////////////////////////
  /////////////////////////
  //////////////////
  ///////////
  //(c)Blargel
  //VVVVVVVVVVVVVVVVVVVVVVV
 task ShootShape(x, y, speed, angle, graphic, delay, corners, bullets){
  let Corners = [];
  let SideBullets = [];
  ascent(i in 0..corners){
    let obj = Obj_Create(OBJ_SHOT);
    Corners = Corners ~ [obj];
    
    Obj_SetPosition(obj, x, y);
    Obj_SetSpeed(obj, speed);
    Obj_SetAngle(obj, angle+i*(360/corners));
    ObjShot_SetGraphic(obj, graphic);
    ObjShot_SetDelay(obj, delay);
    
    Obj_SetAlpha(obj, 0);
    Obj_SetCollisionToPlayer(obj, false);
    Obj_SetAutoDelete(obj, false);
  }
  
  ascent(i in 0..corners){
    if(i==corners-1){
      let Side = BulletLine(Corners[i], Corners[0]);
      SideBullets = SideBullets ~ [Side];
    }
    else {
      let Side = BulletLine(Corners[i], Corners[i+1]);
      SideBullets = SideBullets ~ [Side];
    }
  }
  
  while(length(SideBullets) > 0){
    descent(i in 0..length(SideBullets)){
      if(SideBullets[i] == [0]){
        SideBullets = erase(SideBullets, i);
      }
      else {
        let tempArray = SideBullets[i];
        descent(j in 1..length(tempArray)){
          if(Obj_BeDeleted(tempArray[j])){
            tempArray = erase(tempArray, j);
          }
        }
        SideBullets[i] = tempArray;
      }
    }
    yield;
  }
  
  ascent(i in 0..corners){
    Obj_Delete(Corners[i]);
  }
  
  function BulletLine(obj1, obj2){
    let SideBullets = [0];
    let DummyArray = [0];
    ascent(i in 0..bullets){
      let obj = Obj_Create(OBJ_SHOT);
      SideBullets = SideBullets ~ [obj];
      DummyArray = DummyArray ~ [0];
      
      ObjShot_SetGraphic(obj, graphic);
      ObjShot_SetDelay(obj, delay);
    }
    RealTask;
    return SideBullets;
    
    task RealTask {
      while(SideBullets != DummyArray){
        let x1 = Obj_GetX(obj1);
        let y1 = Obj_GetY(obj1);
        let x2 = Obj_GetX(obj2);
        let y2 = Obj_GetY(obj2);
        let distance = ((x1-x2)^2 + (y1-y2)^2)^0.5;
        let interval = distance/bullets;
        let angle = atan2(y2-y1, x2-x1);
        descent(i in 1..length(SideBullets)){
          if(Obj_BeDeleted(SideBullets[i])){
            SideBullets[i] = 0;
          }
          else {
            let xo = Obj_GetX(SideBullets[i]);
            let yo = Obj_GetY(SideBullets[i]);
            
            Obj_SetPosition(SideBullets[i], x1+cos(angle)*interval*i, y1+sin(angle)*interval*i);
            
            let xn = Obj_GetX(SideBullets[i]);
            let yn = Obj_GetY(SideBullets[i]);
            let newangle = atan2(yn-yo, xn-xo);
            
            Obj_SetAngle(SideBullets[i], newangle);
          }
        }
        yield;
      }
    }
  }
}
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
    task fi2{
  
  
  loop(40){
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  
  
 


 CreateShotA(1,GetX-18, GetY-13,30);
		SetShotDataA(1,0,rand(1.5,1.8),315-90+ana,rand(0,0.7),0,0,203);
		SetShotDataA(1,180,NULL,NULL,0,0,0,203);

				FireShot(1);

  
  
  if(waw<10){
  
 CreateShotA(1,GetX-18, GetY-13,10);
		SetShotDataA(1,0,rand(1.5,1.8),315-90+ana,rand(0,0.7),0,0,203);
	SetShotDataA(1,180,NULL,NULL,0,0,0,203);
				FireShot(1);

				
 CreateShotA(1,GetX-18, GetY-13,10);
		SetShotDataA(1,0,rand(0.5,1.8),315-90+ana,rand(0,0.3),0,0,203);
	SetShotDataA(1,180,NULL,NULL,0,0,0,203);
				FireShot(1);

  }
  
  
  
  
  ana2+=ana3;
  ana+=ana3/1.5;
  ana3+=0.9824435;
  
  
  
  wait(waw);
  waw+=-3;
  if(waw<2){waw=2;}
  }
  fir;
  
     waw=3;
  
   ana=0;
   ana2=0;
   ana3=0;
  
  
  
  }
  
  
  
  task app{
  
  
  loop{
 
 if(GetEventStep==3){
 app2;
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_power1.wav");
  
  task app2{loop(90){gran+=-1;yield;}}
  loop(120){
  gral+=1;
  
  wait(2);
  
  }CreateAura01("RED",0,2);break;
  }
  
  
  yield;
  }
  
  }
  
  
  let yt2=0;
  task fir{
  
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_don00.wav");
  loop(12){
  ob(yt+yt2,1.5);
  yt2+=360/12;
}  
  yt+=23.5433;
  }
  let anga=0;
let anga2=0;
   task ob(an,sp){
  
  
let obj=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj,GetX);
	Obj_SetY(obj,GetY);
	Obj_SetSpeed(obj,sp);
	Obj_SetAngle(obj,an);
	ObjShot_SetBombResist(obj,true);
	ObjShot_SetGraphic(obj,201);
	ObjShot_SetDelay(obj,10);
	yield;
	//v;
let vv=0;
///////////////////
/*
	loop(20){Obj_SetSpeed(obj,Obj_GetSpeed(obj)-0.1);wait(5);}
	Obj_SetSpeed(obj,1);
	while(!Obj_BeDeleted(obj))
{
       Obj_SetPosition(obj,GetEnemyX+60*cos(vv),GetEnemyY+60*sin(vv));
       vv++;
       yield;
}
	*/
///////////////////////

task lss{

 let qw1 = Obj_Create(OBJ_LASER);
    // initial settings
   Obj_SetPosition   (qw1, Obj_GetX(obj), Obj_GetY(obj));
   Obj_SetAngle(qw1,atan2(GetPlayerY - Obj_GetY(qw1), GetPlayerX - Obj_GetX(qw1)));
    ObjLaser_SetWidth (qw1, -5);
	//Obj_SetCollisionToPlayer(qw1,false);
    ObjLaser_SetLength (qw1, 280);
    ObjShot_SetGraphic(qw1, 5);
    ObjShot_SetDelay(qw1, 15);
    ObjLaser_SetSource(qw1, false);
  let anglel=0;
  while(!Obj_BeDeleted(qw1)){yield;
	Obj_SetAutoDelete(qw1,true);
wait(60);
 
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_slash.wav"); 
//ObjShot_SetGraphic(qw1, 245);
  loop(15){yield;
 ObjLaser_SetWidth (qw1, ObjLaser_GetWidth(qw1)+2);
  }
  ObjShot_FadeDelete(qw1);
  break;
}}


task brek{


lss;
PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
loop(10){

CreateShot01(Obj_GetX(obj),Obj_GetY(obj),0.6,anga+anga2,38,15);
anga+=360/10;
}anga2+=14.7645;


}

task fdd{while(!Obj_BeDeleted(obj)){
yield;wait(10);CreateShot01(Obj_GetX(obj),Obj_GetY(obj),17,anga+anga2,119,20);
}}
fdd;
//
//CreateShot01(Obj_GetX(obj),Obj_GetY(obj),17,anga+anga2,119,20);
while(!Obj_BeDeleted(obj)){
yield;

if(Obj_GetX(obj)<GetClipMinX){
brek;wait(2);
Obj_Delete(obj);


}



if(Obj_GetX(obj)>GetClipMaxX){
brek;wait(2);
Obj_Delete(obj);


}




if(Obj_GetY(obj)<GetClipMinY){
brek;wait(2);
Obj_Delete(obj);


}



if(Obj_GetY(obj)>GetClipMaxY){
brek;wait(2);
Obj_Delete(obj);


}



}








}}







  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
  
}






////////////////////////////
script_event test {
 function wait(n) {loop(n){yield;} }
    let CSD = GetCurrentScriptDirectory;
	
	
    let Tn = CSD ~ ".\Tn.png";
    let Tsm = CSD ~ ".\Tsm.png";
    let Tang = CSD ~ ".\Tang.png";
    let Tann = CSD ~ ".\Tann.png";

	
	
	
    let Rneut = CSD ~ ".\ren.png";
    let Rwtf = CSD ~ ".\rew.png";
    let Rfun = CSD ~ ".\ref.png";
    let Rconf = CSD ~ ".\rec.png";
    let Rhappy = CSD ~ ".\reh.png";
    let Rs = CSD ~ ".\res.png";
    let Ra = CSD ~ ".\rea.png";
 
@Initialize {
        LoadGraphic(Tang);
        LoadGraphic(Tann);
        LoadGraphic(Tn);
        LoadGraphic(Tsm);
    
        LoadGraphic(Ra);
        LoadGraphic(Rneut);
        LoadGraphic(Rwtf);
        LoadGraphic(Rfun);
        LoadGraphic(Rconf);
        LoadGraphic(Rhappy);
        LoadGraphic(Rs);
 //SetTexture(imgReimu);
		
 }
 
@MainLoop{ MoveChar(LEFT, FRONT);    
 SetChar(LEFT, Rfun);                 //Set the player's character on the left side, with the graphic you've told it to display.
 SetChar(RIGHT, Tn);                 //Set the player's character on the left side, with the graphic you've told it to display.
 SetGraphicRect(LEFT, 0, 0, 245, 280);           //The region you're displaying of the graphic for the player character, just like SetGraphicRect.
 
 SetGraphicRect(RIGHT, 0, 0, 245, 280);       


MoveChar(LEFT, FRONT); 
 DeleteName(RIGHT); 
TextOutA("Finally~"); 
 
SetChar(LEFT, Rs);  
TextOutA("Ugh..My weapon is sticky now.."); 
SetChar(LEFT, Rconf);  
TextOutA("Thanks to these snails."); 

MoveChar(LEFT, BACK);


  SetStep(3);
 
MoveChar(RIGHT, BACK);  
 MoveChar(LEFT, BACK); 
 
TextOutA("Did you say something?"); SetStep(2);
 
 
 
 
MoveChar(LEFT, FRONT); 
 

 
 

SetChar(LEFT, Ra);  
TextOutA("What?You are still alive?"); 

MoveChar(LEFT, BACK);
 
 
SetChar(RIGHT, Tn);  
MoveChar(RIGHT, FRONT);
TextOutA("Well..actually,it wasn't my last-"); 

MoveChar(RIGHT, BACK);


MoveChar(LEFT, FRONT);
SetChar(LEFT, Rconf);  
TextOutA("Yeah,Yeah.Let me defeat you already."); 

MoveChar(LEFT, BACK);

 
 
 
SetChar(RIGHT, Tann);  
MoveChar(RIGHT, FRONT);
TextOutA("..."); 

MoveChar(RIGHT, BACK);
 
 
 

MoveChar(LEFT, FRONT);
SetChar(LEFT, Rs);  
TextOutA("Oh,right."); 

SetChar(LEFT, Rwtf);  
TextOutA("What!?Another spellcard!?"); 
SetChar(LEFT, Rfun);
TextOutA("It would be fun!"); 

MoveChar(LEFT, BACK);
 
 
 
 
SetChar(RIGHT, Tsm);  
MoveChar(RIGHT, FRONT);
TextOutA("Tee-hee~"); 

SetChar(RIGHT, Tang);  
TextOutA("It won't be easy!"); 


MoveChar(RIGHT, BACK);
 
 
MoveChar(LEFT, FRONT);
SetChar(LEFT, Rneut);  
TextOutA("..."); 
SetChar(LEFT, Rconf);  
TextOutA("..Yeah."); 
MoveChar(LEFT, BACK);
 SetCommonData("begin",1);
 
  wait(120);
 End;           //This ends the event.

  
 
 
 }}
	