
#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 {
  d;
  CreateAura01("RED",0,2);
   LoadUserShotData(qwe);
    SetLife(2500);
    //SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(cir2);
   
    InitializeAnimationData;
	SetTimer(28);
  SetCommonData("begin",0);
    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(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 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;

   if(name==1){
   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;
 let name=0;
  task ShowOffNueAnimation {
  
  
  task mov{
  loop{yield;if(GetCommonData("begin")==2){
  
  SetMovePosition03(GetCenterX, GetClipMinY+rand(80, 120), 20, 6);
      SetNueMoveAnimation("right");
      yield ;
      while(GetSpeed>0.1){yield;}
  break;}}
  }
  
  task mov2{
  loop{yield;if(GetCommonData("begin")==3){
  name=1;
  
  break;}}
  }
   task mov3{
  loop{yield;if(GetCommonData("begin")==4){
 
   PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Tenxka's Theme.mp3");

  
  break;}}
  }
  mov;
  mov2;
  mov3;
  
	CreateEventFromScript("test");
 
loop{yield;SetTimer(28);if(GetCommonData("begin")==1){break;}}
  SetTimer(28);
  
	  	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);
 Concentration02(40);
 Concentration02(30);
 Concentration02(30);
 Concentration01(80);
 Concentration01(80);
 Concentration01(80);
 Concentration01(80);
 wait(60);gro;
 wait(30);
 
	  
	  
      wait(30);
      Animate("nue", "start cast", false);
	  wait(10);da=1;
	  fire2;
      wait(120);
      Animate("nue", "stop cast", false);
      wait(16);
      Animate("nue", "idle", true);
      wait(120);
   
   
   loop{yield;
   
   
  // fire2;
   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);
	//  fire2;
      wait(60);
     // Animate("nue", "stop cast", false);
      wait(16);
      //Animate("nue", "idle", true);
      wait(30);
   
   
   
    //fire2;
   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);
	 // fire2;
      wait(60);
     // Animate("nue", "stop cast", false);
      wait(16);

      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 fire2{
  
  /*
  loop(60){
  
  CreateShot01(GetX, GetY-12,0.8,as2+f,58,10);
  CreateShot01(GetX, GetY-12,2,as2+f,60,10);
  as2+=360/60;
  }
  */
  ///////////
  
  loop{
   PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
  CreateShot01(GetX+18, GetY-12,1.8,90+f2-2,60,10);
CreateShot01(GetX+18, GetY-12,1.6,90+f2-4,60,10);
CreateShot01(GetX+18, GetY-12,1.4,90+f2-6,60,10);
CreateShot01(GetX+18, GetY-12,1.2,90+f2-8,60,10);
  
  
CreateShot01(GetX+18, GetY-12,2,90+f2,60,10);


CreateShot01(GetX+18, GetY-12,1.8,90+f2+2,60,10);
CreateShot01(GetX+18, GetY-12,1.6,90+f2+4,60,10);
CreateShot01(GetX+18, GetY-12,1.4,90+f2+6,60,10);
CreateShot01(GetX+18, GetY-12,1.2,90+f2+8,60,10);


////////////////
CreateShot01(GetX-18, GetY-12,1.8,90-f2-2,58,10);
CreateShot01(GetX-18, GetY-12,1.6,90-f2-4,58,10);
CreateShot01(GetX-18, GetY-12,1.4,90-f2-6,58,10);
CreateShot01(GetX-18, GetY-12,1.2,90-f2-8,58,10);
  
  
CreateShot01(GetX-18, GetY-12,2,90-f2,58,10);


CreateShot01(GetX-18, GetY-12,1.8,90-f2+2,58,10);
CreateShot01(GetX-18, GetY-12,1.6,90-f2+4,58,10);
CreateShot01(GetX-18, GetY-12,1.4,90-f2+6,58,10);
CreateShot01(GetX-18, GetY-12,1.2,90-f2+8,58,10);
///////


wait(5);f2+=17.934524;
}
  ///////////////
  
  
  
  
  sp+=0.1;
  wait(5);
  f+=13.352466;
  
  sp=0;
  
  
  
  }
  
  
  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));
                        
           
                    }

      


	
	
	}}

/////////////
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, Rneut);                 //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("This place is beautiful."); 
 TextOutA("But I wonder where the culprit is."); 


MoveChar(LEFT, BACK);


  SetStep(3);
 
MoveChar(RIGHT, BACK);  
 MoveChar(LEFT, BACK); 
 SetCommonData("begin",2);
TextOutA("Do you really like being here?"); SetStep(2);
 
 //SetCommonData("begin",3);
 
 
 

MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rneut); 
 
TextOutA("Yup."); 
TextOutA("But it is really easy to get lost."); 



MoveChar(LEFT, BACK);
 
 SetChar(RIGHT, Tann);  
MoveChar(RIGHT, FRONT);

TextOutA("So.."); 

MoveChar(RIGHT, BACK);

 SetCommonData("begin",3);
SetChar(RIGHT, Tann);  
MoveChar(RIGHT, FRONT);

TextOutA("I'm Tenxka Shin.And you?"); 

MoveChar(RIGHT, BACK);



MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rneut); 
TextOutA("I'm Reimu Hakurei."); 
MoveChar(LEFT, BACK);


SetChar(RIGHT, Tn);  
MoveChar(RIGHT, FRONT);

TextOutA("Nice to meet you."); 

MoveChar(RIGHT, BACK);

MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rhappy); 
TextOutA("Nice to meet you."); 
SetChar(LEFT, Rneut); 
TextOutA("(She's strong.)");
SetChar(LEFT, Rconf);  
TextOutA("(It would be a disaster if someone will meet her.)"); 
MoveChar(LEFT, BACK);


SetChar(RIGHT, Tsm);  
MoveChar(RIGHT, FRONT);
TextOutA("Are you talking to yourself?"); 
MoveChar(RIGHT, BACK);



MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rneut); 
TextOutA("Yup,that happens."); 
MoveChar(LEFT, BACK);



SetChar(RIGHT, Tann);  
MoveChar(RIGHT, FRONT);
TextOutA("Unerstand.This happens to me sometimes too."); 
MoveChar(RIGHT, BACK);

MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rconf); 
TextOutA("(Oh c'mon Reimu.You came here not for  a friendly chat.)"); 
TextOutA("(But it is a chance to learn something about her.)"); 
 SetChar(LEFT, Rneut); 
TextOutA("I've heard that someone-"); 
MoveChar(LEFT, BACK);



SetChar(RIGHT, Tann);  
MoveChar(RIGHT, FRONT);
TextOutA("Oh.Now I get it."); 
TextOutA("You are like others."); 
MoveChar(RIGHT, BACK);



MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rwtf); 
TextOutA("Wait,I-"); 
MoveChar(LEFT, BACK);



 SetCommonData("begin",4);
SetChar(RIGHT, Tann);  
MoveChar(RIGHT, FRONT);
TextOutA("I don't trust you from now on.");  
TextOutA("Now,go away!");  
MoveChar(RIGHT, BACK);



MoveChar(LEFT, FRONT); 
 SetChar(LEFT, Rconf); 
TextOutA("(Good job,me.)"); 
MoveChar(LEFT, BACK);



 SetCommonData("begin",1);
// SetCommonData("begin",0);
  wait(120);
 End;           //This ends the event.

  
 
 
 }}
	
