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

script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  #include_function ".\Halo.txt"
  let imgNue = GetCurrentScriptDirectory ~ "KE.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let cir2 = GetCurrentScriptDirectory ~ "circle2.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 
  @Initialize {
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_cardget.wav");
  CreateAura01("RED",0,2);
   LoadUserShotData(qwe);
    SetLife(2500);
    //SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(cir2);
    //PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Tenxka's Theme.mp3");
    InitializeAnimationData;
	SetTimer(28);
  d;
    Animate("nue", "idle", true);
   mus;
    ShowOffNueAnimation;
    
  }let aq=0;
  let aaaa=0;
  let anglet=0;
  let anglet2=0;
  
  
 let da=0;
  task d{
  loop{
  
  if(da==0){
  SetDamageRate(0,0);}
   if(da==1){
  SetDamageRate(60,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 al=0;let si=0;
  let al1=0;let si1=0;
  task gro{
  
  
  }
   task gro2{
  
  
  }
  @DrawLoop {
     
   
	    SetTexture(cir);SetAlpha(200);
 
	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(200);
 
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(imgNue);SetAlpha(255);
 SetGraphicRect(0,0,0,0);
	
	SetGraphicScale(0.8,0.8);


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

   h+=4;

   
   DrawText("Tenxka Shin",GetClipMinX,30,15,255);
  }let h=0;let ann=0;
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue1.mp3");}
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  let angle=270;let sp=3;let a=0;let angle2=0;
 
  task ShowOffNueAnimation {
  
    wait(20);
	SetMovePosition03(GetCenterX, GetClipMinY+rand(80, 120), 20, 6);
      SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}

	  	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);
 Concentration02(40);
 Concentration02(30);
 Concentration02(30);
 Concentration01(80);
 Concentration01(80);
 Concentration01(80);
 Concentration01(80);
 wait(60);
 wait(60);
 
     Animate("nue", "start cast", false);
	  wait(10);
	da=1;ire2;
      wait(60);
     Animate("nue", "stop cast", false);
      wait(16);
     Animate("nue", "idle", true);
      wait(130);
      
 
	  loop{
	 // SetMovePosition03(GetX-rand(20,40), GetY+rand(-10,10), 20, 4);
     // SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}
   wait(30);Animate("nue", "idle", true);
    Animate("nue", "start cast", false);
	  wait(10);
	ire2;
      wait(30);
     Animate("nue", "stop cast", false);
      wait(16);
     Animate("nue", "idle", true);
      wait(30);
	  
	  	 // SetMovePosition03(GetX+rand(20,40), GetY+rand(-10,10), 20, 4);
     // SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}
   wait(30);Animate("nue", "idle", true);
    Animate("nue", "start cast", false);
	  wait(10);
	ire2;
      wait(30);
     Animate("nue", "stop cast", false);
      wait(16);
     Animate("nue", "idle", true);
      wait(30);
      }
   
   
  }
  
  
  let as=0;
  let as2=0;
  let as22=0;
  let as222=0;
  let f=0;
  task fire{
   as=0;
  as2=0;
   as22=0;
   as222=0;
   f=0;
  
 
    as=0;
  as2=0;
   as22=0;
   as222=0;
   f=0;
  
 
  
 
  as+=30;
  as22+=6-as222*10;
  
  as222-=0.05;
 
  f+=rand(0,360);
  
  as222=0;
  
  
  
  
  }
  
  let sp=0;let f2=0;let spp=0;let angg=0;
  task ire2{
    
	 
	 loop(6){ PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  loop(20){
  
  CreateShot01(GetX, GetY-12,1.5,as2+f,207,10);
 
  as2+=360/20;
  }f+=1.6234;
  wait(10);
}


loop(20){ PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
  loop(3){
  
  CreateShot01(GetX, GetY-12,1.5,sp+f2,124,15);
  CreateShot01(GetX, GetY-12,1.5,sp-f2,124,15);
 
 
 CreateShot01(GetX, GetY-12,1,sp+f2,125,15);
  CreateShot01(GetX, GetY-12,1,sp-f2,125,15);
 
  sp+=360/3;
  }f2+=6.42345678;
  wait(5);
}f2+=22.4536;

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

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

      


	
	
	}}


