#TouhouDanmakufu
#Title[NonSpell02]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main { #include_function ".\Halo.txt"let xp=0.5;let ty=0;
  #include_function ".\AnimationLib.dnh"
  let imgNue = GetCurrentScriptDirectory ~ "KE.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 let cir = GetCurrentScriptDirectory ~ "circle.png";
 let cha = GetCurrentScriptDirectory ~ "ch.png";
 let back1= GetCurrentScriptDirectory ~ "bg1.png";
 let back2= GetCurrentScriptDirectory ~ "bg2.png";
 let back3= GetCurrentScriptDirectory ~ "bg3.png";
  @Initialize {CreateAura01("AZURE",0,1);
  SetCommonData("back",10);
   LoadUserShotData(qwe);
    SetLife(4500);
    
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(cha);
    SetTimer(40);
    InitializeAnimationData;
	
  SetCommonData("speed",1);
    Animate("nue", "idle", true);
   mus;
    ShowOffNueAnimation;
    
  }
  
  
  
  
  
  @MainLoop {SetCollisionA(GetX, GetY, 32);
        SetCollisionB(GetX, GetY, 16);
    yield ;
  }let wave=0;
  let x=0;let y=0;let z=0;let dir=60;let dor=60; let sa=0;
  @DrawLoop {
    
	  
    SetTexture(cir);SetAlpha(150);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(2+sin(wave)*0.2,2+sin(wave)*0.2);

wave+=3;x+=3;
	SetGraphicAngle(0, 0, x);
	DrawGraphic(GetX,GetY);
	
	
	 SetTexture(cir);SetAlpha(90);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(2.3+sin(wave)*0.2,2.3+sin(wave)*0.2);


	SetGraphicAngle(0, 0, -x);
	DrawGraphic(GetX,GetY);
	
	
	
	
   
   //////
   //GetX + dir*cos(dor), GetY + dir*sin(dor);
   

	 
  
  
 
   
    SetTexture(imgNue);SetAlpha(255);SetGraphicScale(1,1);SetRenderState(ALPHA);
	  SetGraphicAngle(y, x-x, x-x);
	   dor+=6;
    DrawAnimatedSprite("nue", GetX, GetY+5*sin(dor));
  }
  
 
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\boss3.mp3");}
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  let angle=270;let sp=0.4;let a=0;let angle2=0;let xx=610;let yy=0;let an=0;let spd=1;
 let as=0;
 let angle23=0;
 let angle55=0;
 task blast{
 
 
 }
 task asp{loop(300){yield;as+=0.001;}as=0;}
 let a2=0;let asdf=0;
  task ShowOffNueAnimation { asdf=rand(30,60);
  //PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\st.mp3");
 wait(60);
 SetMovePosition03(GetCenterX, GetCenterY-80, 20, 6);
       SetNueMoveAnimation("right");
      
      yield ;
      while(GetSpeed>0.1){yield;}
		PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_ch02.wav");
 Concentration02(30);
 Concentration02(40);
 Concentration02(30);
 Concentration02(40);
 Concentration02(30);
 Concentration02(40);
 wait(60);
	 
	  wait(20);
 
    wait(20);
	 wait(20);
	  Animate("nue", "start cast", false);
	  wait(20);
	 angle55=1;
	firet;
	
	////////////
	task firet{
	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
	ty=rand(20,340);blast;
	
	loop(60){
	CreateShot01(GetX,GetY,1,angle2,137,5);
	angle2+=360/60
	
	}
	
	loop(100){
xp+=0.03;
	PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
	bullet2(GetX,GetY,xp,angle+90+angle);
	
	angle+=3.6;
	}xp=0.5;
	
	
	}
	//////////
	  
	  
	
	 // PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
	  //wait(60);
   // Animate("nue", "stop cast", false);
	//wait(28);
	Animate("nue", "idle", false);
	 y=0;yield;
     
      wait(90);
    loop { asdf=rand(30,60);
	SetMovePosition03(GetCenterX+rand(10, 50), GetClipMinY+rand(100, 150), 20, 4);
       SetNueMoveAnimation("right");
      
      yield ;
      while(GetSpeed>0.1){yield;}
		
	 
	  wait(20);
	  Animate("nue", "start cast", false);
	  wait(20);firet;angle55=0;
	 
	
	
	  
	  
	
	 // PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_kira00.wav");
	//  wait(60);
   // Animate("nue", "stop cast", false);
	//wait(28);
	Animate("nue", "idle", false);
	 y=0;yield;
     
      wait(20);
	  //Animate("nue", "idle", false);
      
      
       asdf=rand(30,60);
     SetMovePosition03(GetCenterX-rand(10, 50), GetClipMinY+rand(100, 150), 20, 4);
      SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}
      wait(20);
	  Animate("nue", "start cast", false);
	  wait(20);firet;
	  angle55=0;
	
	 // wait(10);
    //Animate("nue", "stop cast", false);
	//wait(28);
	Animate("nue", "idle", false);
	 y=0;yield;
     
      
	  //Animate("nue", "idle", false);
      wait(20);
      
      
    
      
    }
  }
  
  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", false);
  }
  
  
  
  
  
 
  
  
  task bullet(ang,sp){
 
 
 
  
  
  
  
  let obj216=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj216,GetX-21);
	Obj_SetY(obj216,GetY-24);
	Obj_SetSpeed(obj216,sp+0.5);
	Obj_SetAngle(obj216,ang);
	ObjShot_SetBombResist(obj216,true);
	ObjShot_SetGraphic(obj216,187);
ObjShot_SetDelay(obj216,5);
	while(!Obj_BeDeleted(obj216)){yield;
	Obj_SetAutoDelete(obj216,true);
	
	loop(20){
	Obj_SetSpeed(obj216,Obj_GetSpeed(obj216)-Obj_GetSpeed(obj216)/10);
  wait(5);
  }Obj_SetSpeed(obj216,0);
  wait(10);
  loop(35){
	Obj_SetSpeed(obj216,Obj_GetSpeed(obj216)+as);
  wait(1);
  }
  loop(20){
	Obj_SetSpeed(obj216,Obj_GetSpeed(obj216)-Obj_GetSpeed(obj216)/12);
  wait(5);
  }break;
  
  
  
  }}
  
  task bullet2(x,y,sp,ang){
 
 
 task asd{
 
 CreateShot01(Obj_GetX(obj2166),Obj_GetY(obj2166),1.5,Obj_GetAngle(obj2166)+asdf,55,0);
 CreateShot01(Obj_GetX(obj2166),Obj_GetY(obj2166),1.5,Obj_GetAngle(obj2166)-asdf,55,0);
 
 ObjShot_FadeDelete(obj2166);
 
 
 
 }
  
  
  
  
  let obj2166=Obj_Create(OBJ_SHOT);
	Obj_SetX(obj2166,x);
	Obj_SetY(obj2166,y);
	Obj_SetSpeed(obj2166,sp);
	Obj_SetAngle(obj2166,ang);
	ObjShot_SetBombResist(obj2166,true);
	ObjShot_SetGraphic(obj2166,121);
ObjShot_SetDelay(obj2166,5);
	while(!Obj_BeDeleted(obj2166)){yield;
	Obj_SetAutoDelete(obj2166,true);
	
	loop(20){
	Obj_SetSpeed(obj2166,Obj_GetSpeed(obj2166)-Obj_GetSpeed(obj2166)/10);
  wait(5);
  }Obj_SetSpeed(obj2166,0);
  wait(40);
  
ObjShot_SetGraphic(obj2166,55);
  loop(60){Obj_SetAngle(obj2166,Obj_GetAngle(obj2166)-6);
	Obj_SetSpeed(obj2166,Obj_GetSpeed(obj2166)+0.07);
  wait(1);
  }asd;break;
  
  
  
  }}
  
  
  
  task bullet22(x,y,sp,ang){
 
 
 
  
  
  
  
  let objqwe=Obj_Create(OBJ_SHOT);
	Obj_SetX(objqwe,x);
	Obj_SetY(objqwe,y);
	Obj_SetSpeed(objqwe,sp);
	Obj_SetAngle(objqwe,ang);
	ObjShot_SetBombResist(objqwe,true);
	ObjShot_SetGraphic(objqwe,125);
ObjShot_SetDelay(objqwe,5);
	while(!Obj_BeDeleted(objqwe)){yield;
	Obj_SetAutoDelete(objqwe,true);
	
	loop(20){
	Obj_SetSpeed(objqwe,Obj_GetSpeed(objqwe)-Obj_GetSpeed(objqwe)/10);
  wait(5);
  }Obj_SetSpeed(objqwe,0);
  wait(40);
  
ObjShot_SetGraphic(objqwe,60);
 loop(60){
 Obj_SetSpeed(objqwe,Obj_GetSpeed(objqwe)+0.07);
 Obj_SetAngle(objqwe,Obj_GetAngle(objqwe)+6);
  wait(1);
  }break;
  
  
  
  }}
  
  
  task fire(angle6){
  bullet(angle6-24,1.4);
  bullet(angle6-16,1.6);
  bullet(angle6-8,1.8);
  bullet(angle6,2);
  bullet(angle6+8,1.8);
  bullet(angle6+16,1.6);
  bullet(angle6+24,1.4);
  
  
  bullet(angle6-15,1.1);
  bullet(angle6-10,1.3);
  bullet(angle6-5,1.5);
  bullet(angle6,1.7);
  bullet(angle6+5,1.5);
  bullet(angle6+10,1.3);
  bullet(angle6+15,1.1);
  
  
  
  }
  
  
  
  function wait(t){
    loop(t){yield;}
  }
  
sub InitializeAnimationData {
 CreateAnimation("nue", "idle", 1);
    SetAnimationFrame("nue", "idle", 0, imgNue,38, 10, 10, 55, 75);
  
   
    
    CreateAnimation("nue", "start move right", 4);
  SetAnimationFrame("nue", "start move right", 0, imgNue, 8, 13,86, 56, 158);
	SetAnimationFrame("nue", "start move right", 1, imgNue, 8, 77,86, 120, 154);
	
	SetAnimationFrame("nue", "start move right", 2, imgNue, 8, 138,82, 185, 154);
	SetAnimationFrame("nue", "start move right", 3, imgNue, 8, 200,82, 249, 151);
    
    CreateAnimation("nue", "stop move right", 4);
   SetAnimationFrame("nue", "stop move right", 0, imgNue, 8, 200,82, 249, 151);
   SetAnimationFrame("nue", "stop move right", 1, imgNue, 8, 138,82, 185, 154);
   SetAnimationFrame("nue", "stop move right", 2, imgNue, 8, 77,86, 120, 154);
   SetAnimationFrame("nue", "stop move right", 3, imgNue, 8, 13,86, 56, 158);
   
   
   
   
     
    CreateAnimation("nue", "start move left", 4);
  SetAnimationFrame("nue", "start move left", 0, imgNue, 8, 462,88, 506, 156);
	SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 398,85, 441, 154);
	
	SetAnimationFrame("nue", "start move left", 2, imgNue, 8, 334,82, 382, 154);
	SetAnimationFrame("nue", "start move left", 3, imgNue, 8, 270,82, 318, 151);
    
   
    CreateAnimation("nue", "stop move left", 4);
   SetAnimationFrame("nue", "stop move left", 0, imgNue, 8, 270,82, 318, 151);
   SetAnimationFrame("nue", "stop move left", 1,imgNue, 8, 334,82, 382, 154);
   SetAnimationFrame("nue", "stop move left", 2, imgNue, 8, 398,85, 441, 154);
   SetAnimationFrame("nue", "stop move left", 3, imgNue, 8, 462,88, 506, 156);
   
   
   
   
    CreateAnimation("nue", "start cast", 4);
    SetAnimationFrame("nue", "start cast", 0, imgNue, 7   , 12, 162,55,235);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 7    ,70, 166,120,235);
	
    SetAnimationFrame("nue", "start cast", 2, imgNue, 7    ,133, 165,184,234);
    SetAnimationFrame("nue", "start cast", 3, imgNue, 7    ,196, 165,247,235);
    
   

    
    CreateAnimation("nue", "stop cast", 4);
    SetAnimationFrame("nue", "stop cast", 0, imgNue, 7    ,196, 165,247,235);
  SetAnimationFrame("nue", "stop cast", 1,imgNue, 9    ,133, 165,184,234);
  SetAnimationFrame("nue", "stop cast", 2,imgNue, 9    ,70, 166,120,235);
  SetAnimationFrame("nue", "stop cast", 3, imgNue, 9   , 12, 162,55,235);
  
  }
}




////////