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

script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  #include_function ".\Halo.txt"
  let imgNue = GetCurrentScriptDirectory ~ "su.png";
  let cir = GetCurrentScriptDirectory ~ "circle.png";
  let arr = GetCurrentScriptDirectory ~ "arrow.png";
  SetCommonData("clear",0);
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 let a=0;
  @Initialize {
  
  //CreateAura01("AZURE",0,2);
   LoadUserShotData(qwe);
    SetLife(2500);
    //SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(arr);
    
    InitializeAnimationData;
	SetTimer(99);
  
    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;
  @DrawLoop {
     
	 
	 
	 SetTexture(arr);SetAlpha(a);
 SetGraphicRect(0,0,600,600);
	
	SetGraphicScale(0.07,0.07);


	SetGraphicAngle(0, 0, 270);
	DrawGraphic(GetPlayerX,GetPlayerY-60);
     
  
	 
	 
	 
   
  SetTexture(imgNue);SetAlpha(255);
 SetGraphicRect(0,0,0,0);
	
	SetGraphicScale(1,1);


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

   h+=4;
  }
  
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Nue1.mp3");}
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  let angle=270;let sp=3;let a=0;let angle2=0;
 
  task ShowOffNueAnimation {
  
CreateEventFromScript("test");
    wait(60);
	SetMovePosition03(GetCenterX, GetClipMinY+rand(80, 120), 20, 6);
      SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}
wait(32);
      Animate("nue", "idle", true);


loop{yield;
if(GetCommonData("clear")==1){
SetLife(0);
}
}



	  
  }
  
  
  task SetNueMoveAnimation(direction) {
    if(direction == "left"){
      Animate("nue", "start move left", false);
      yield ;
      while(GetSpeed>0.1){
        yield ;
      }
      Animate("nue", "stop move left", false);
    }
    if(direction == "right"){
      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", 4);
    SetAnimationFrame("nue", "idle", 0, imgNue, 13, 15, 2, 48, 61);
   
    SetAnimationFrame("nue", "idle", 1, imgNue, 13, 79, 3, 112, 61);
    SetAnimationFrame("nue", "idle", 2, imgNue, 13, 143, 3, 176, 61);
    SetAnimationFrame("nue", "idle", 3, imgNue, 13, 207, 3, 240, 61);
	
    
    
	
	
    CreateAnimation("nue", "start move right", 4);
    SetAnimationFrame("nue", "start move right", 0, imgNue, 8, 13, 65, 50, 124);
    SetAnimationFrame("nue", "start move right", 1, imgNue, 8, 74, 65, 114, 123);
    SetAnimationFrame("nue", "start move right", 2, imgNue, 8, 137, 66, 178, 122);
    SetAnimationFrame("nue", "start move right", 3, imgNue, 8, 197, 66, 242, 123);
   
    
    CreateAnimation("nue", "stop move right", 4);
    SetAnimationFrame("nue", "stop move right", 0,  imgNue, 8, 197, 66, 242, 123);
    SetAnimationFrame("nue", "stop move right", 1, imgNue, 8, 137, 66, 178, 122);
    SetAnimationFrame("nue", "stop move right", 2, imgNue, 8,  74, 65, 114, 123);
    SetAnimationFrame("nue", "stop move right", 3, imgNue, 8, 13, 65, 50, 124);
   
    
	
	
	
    CreateAnimation("nue", "start move left", 2);
    SetAnimationFrame("nue", "start move left", 0, imgNue, 8, 308, 132, 382, 253);
    SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 228, 134, 301, 258);
   
    
    CreateAnimation("nue", "stop move left", 2);
    SetAnimationFrame("nue", "stop move left", 0,imgNue, 8, 228, 134, 301, 258);
    SetAnimationFrame("nue", "stop move left", 1,imgNue, 8, 308, 132, 382, 253);
   
    
    CreateAnimation("nue", "start cast", 2);
    SetAnimationFrame("nue", "start cast", 0, imgNue, 6, 0,125,73,247);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 6, 79,129,153,250);
   
    
    CreateAnimation("nue", "stop cast",2);
    SetAnimationFrame("nue", "stop cast", 0, imgNue, 6, 79,129,153,250);
    SetAnimationFrame("nue", "stop cast", 1, imgNue, 6,0,125,73,247);
    
  }
}




script_event test {
 function wait(n) {loop(n){yield;} }
    let CSD = GetCurrentScriptDirectory;
    let su = CSD ~ ".\suf.png";
    let suw = CSD ~ ".\sufwtf.png";
    let suh = CSD ~ ".\sufh.png";
    let sac = CSD ~ ".\safc.png";
    let sas = CSD ~ ".\safs.png";
    let saa = CSD ~ ".\safa.png";
    let sau = CSD ~ ".\safu.png";
    let saw = CSD ~ ".\safw.png";
    let sa = CSD ~ ".\saf.png";
 
@Initialize {
        LoadGraphic(su);
        LoadGraphic(suw);
        LoadGraphic(suh);
        LoadGraphic(sac);
        LoadGraphic(sa);
		
        LoadGraphic(sas);
        LoadGraphic(saa);
        LoadGraphic(sau);
        LoadGraphic(saw);
 //SetTexture(imgReimu);
		
 }
 
@MainLoop{

TextOutA("There you are."); 

SetChar(RIGHT, su); 
SetGraphicRect(RIGHT, 0, 0, 256, 256);  
MoveChar(RIGHT, FRONT); 
TextOutA("Sanae isn't here.."); 
TextOutA("So I can deal with you."); 
TextOutA("By using my last spell card."); 

SetChar(RIGHT, suw); 
TextOutA("There's a chance that Gensokyo would be under ground though.."); 



SetChar(RIGHT, su );
TextOutA("So.."); 
TextOutA("Are you responsible for that?"); 

SetChar(RIGHT, suw); 
TextOutA("Let's find that out!"); 


MoveChar(RIGHT, BACK);

 SetCommonData("clear",1);
  
 End;           //This ends the event.

  
 
 
 }}
	
	

