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

script_enemy_main {
  #include_function ".\AnimationLib.dnh"
  let imgNue = GetCurrentScriptDirectory ~ "KE.png";
  let qwe = GetCurrentScriptDirectory ~ "supershot.txt";
 let cir = GetCurrentScriptDirectory ~ "circle.png";
 let cha = GetCurrentScriptDirectory ~ "ch.png";
  @Initialize {
   LoadUserShotData(qwe);
    SetLife(4500);
    SetY(-120);
    LoadGraphic(imgNue);
    LoadGraphic(cir);
    LoadGraphic(cha);
    SetTimer(40);
    InitializeAnimationData;
	
  
    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+=5;
	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);
    DrawAnimatedSprite("nue", GetX, GetY);
  }
  
 
  task mus{PlayMusic(GetCurrentScriptDirectory ~ ".\Sounds\Keine.mp3");}
  @Finalize {
    DeleteGraphic(imgNue);
   
  }
  let angle=270;let sp=3;let a=0;let angle2=0;let xx=610;let yy=0;let an=0;let spd=1;
 
 
  task ShowOffNueAnimation {
  
    wait(20);
    loop {
	SetMovePosition03(GetClipMaxX-rand(250, 50), GetClipMinY+rand(80, 120), 20, 4);
       SetNueMoveAnimation("right");
      
      yield ;
      while(GetSpeed>0.1){yield;}
	
	  
	  wait(10);
	  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_option.wav");
      CreateEnemyFromScript("fam",GetX,GetY,0,0,0);
      CreateEnemyFromScript("fam2",GetX,GetY,0,0,0);
      CreateEnemyFromScript("fam3",GetX,GetY,0,0,0);
      CreateEnemyFromScript("fam4",GetX,GetY,0,0,0);
	 y=0;
    
      wait(90);
      wait(90);
      
      
      SetMovePosition03(GetClipMinX+rand(50, 120), GetClipMinY+rand(80, 120), 20, 4);
      SetNueMoveAnimation("left");
      yield ;
      while(GetSpeed>0.1){yield;}
      wait(10);
    PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_option.wav");
      CreateEnemyFromScript("fam",GetX,GetY,0,0,0);
      CreateEnemyFromScript("fam2",GetX,GetY,0,0,0);
      CreateEnemyFromScript("fam3",GetX,GetY,0,0,0);
      CreateEnemyFromScript("fam4",GetX,GetY,0,0,0);
	 y=0;
    
      wait(90);
      wait(90);
    
    
      
    }
  }
  
  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,12, 0, 0, 61, 80);
    SetAnimationFrame("nue", "idle", 1, imgNue,12, 68, 0, 61+61, 80);
    SetAnimationFrame("nue", "idle", 2, imgNue, 12, 68+68, 0, 61+61+61, 80);
    SetAnimationFrame("nue", "idle", 3, imgNue, 12, 68+68+66, 0, 61+61+61+61, 80);
   
    
    CreateAnimation("nue", "start move right", 4);
    SetAnimationFrame("nue", "start move right", 0, imgNue, 8, 0, 80, 63, 159);
    SetAnimationFrame("nue", "start move right", 1, imgNue, 8, 63, 79, 128, 158);
    SetAnimationFrame("nue", "start move right", 2, imgNue, 8, 131, 82, 196, 157);
    SetAnimationFrame("nue", "start move right", 3, imgNue, 8, 194, 85, 253, 152);
    
    CreateAnimation("nue", "stop move right", 3);
    SetAnimationFrame("nue", "stop move right", 0, imgNue, 4, 131, 82, 196, 157);
    SetAnimationFrame("nue", "stop move right", 1, imgNue, 4, 63, 79, 128, 158);
    SetAnimationFrame("nue", "stop move right", 2, imgNue, 4, 0, 80, 63, 159);
    
    CreateAnimation("nue", "start move left", 4);
    SetAnimationFrame("nue", "start move left", 0, imgNue, 8, 195, 240, 255, 316);
    SetAnimationFrame("nue", "start move left", 1, imgNue, 8, 129, 240, 194, 314);
    SetAnimationFrame("nue", "start move left", 2, imgNue, 8, 65, 240, 130, 315);
    SetAnimationFrame("nue", "start move left", 3, imgNue, 8, 0, 240, 66, 313);
    
    CreateAnimation("nue", "stop move left", 3);
    SetAnimationFrame("nue", "stop move left", 0, imgNue, 4, 65, 240, 130, 315);
    SetAnimationFrame("nue", "stop move left", 1, imgNue, 4, 129, 240, 194, 314);
    SetAnimationFrame("nue", "stop move left", 2, imgNue, 4, 195, 240, 255, 316);
    
    CreateAnimation("nue", "start cast", 4);
    SetAnimationFrame("nue", "start cast", 0, imgNue, 6, 0,160,64,240);
    SetAnimationFrame("nue", "start cast", 1, imgNue, 6, 67,159,132,237);
    SetAnimationFrame("nue", "start cast", 2, imgNue, 6, 129,160,194,237);
    SetAnimationFrame("nue", "start cast", 3, imgNue, 6, 195,158,255,234);
  
    
    CreateAnimation("nue", "stop cast", 3);
    SetAnimationFrame("nue", "stop cast", 0, imgNue, 4, 129,160,194,237);
    SetAnimationFrame("nue", "stop cast", 1, imgNue, 4, 67,159,132,237);
  
    SetAnimationFrame("nue", "stop cast", 2, imgNue, 4, 0,160,64,240);
 
  }
}








script_enemy fam{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "circle2.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(190);
 SetGraphicAngle(0,0,-dir*2);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(GetX,GetY);
	
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir);
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.3,0.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan0.wav");
    loop(20){
	
	CreateShot01(GetX,GetY,2.5,angle,230,5);
	
	angle+=360/20;
	
	}
  }
  let angle=0;
  task main{
  fire;
  f;SetMovePosition03(GetEnemyX-50,GetEnemyY+50,5,3);
  loop{yield;
  
  dir+=2;
  
  }
  
  }
  let angle2=0;
  task f{
  
  fi=1;
  
  }
  task fg{
  loop{yield;a++;}
  }
  let a=0;let s=0;let g=0;
  task fire{
  fg;
 
 

 wait(40);
  loop(20){a+=9;
  wait(10);angle2=rand(0,360);s=rand_int(1,3);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
 
  CreateShot01(GetX,GetY,3,a,60,0);
  CreateShot01(GetX,GetY,3,a+180,60,0);
  angle2+=360/350;
  
   CreateShot01(GetX,GetY,3.5,90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90+90,41,5);
  CreateShot01(GetX,GetY,3.5,0,41,5);
 
 CreateShot01(GetX,GetY,2.5,90-a/1.3,41,5);
  
  
  
  
  
  
  
  }SetLife(0);
  
  
  
  }
  
   function wait(t){
    loop(t){yield;}
  }
  }
  

script_enemy fam2{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "circle2.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(190);
 SetGraphicAngle(0,0,-dir*2);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(GetX,GetY);
	
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir);
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.3,0.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
    loop(20){
	
	CreateShot01(GetX,GetY,2.5,angle,230,5);
	
	angle+=360/20;
	
	}
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan0.wav");
  }
  let angle=0;
  task main{
  fire;
  f;SetMovePosition03(GetEnemyX+50,GetEnemyY+50,5,3);
  loop{yield;
  
  dir+=2;
  
  }
  
  }
  let angle2=0;
  task f{
  
  fi=1;
  
  }
  task fg{
  loop{yield;a++;}
  }
  let a=0;let s=0;
  task fire{
  fg;
 
 

 wait(40);
  loop(20){a+=9;
  wait(10);angle2=rand(0,360);s=rand_int(1,3);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
 
  CreateShot01(GetX,GetY,3,-a,60,0);
  CreateShot01(GetX,GetY,3,-a+180,60,0);
 
  CreateShot01(GetX,GetY,3.5,90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90+90,41,5);
  CreateShot01(GetX,GetY,3.5,0,41,5);
  CreateShot01(GetX,GetY,2.5,90+a/1.3,41,5);
 
   
  
  
  
  
  }
  
  
  SetLife(0);
  
  
  
  }
  
   function wait(t){
    loop(t){yield;}
  }
  }
  


  
  ///////////
  script_enemy fam3{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "circle2.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(190);
 SetGraphicAngle(0,0,-dir*2);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(GetX,GetY);
	
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir);
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.3,0.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan0.wav");
   loop(20){
	
	CreateShot01(GetX,GetY,1.8,angle,230,5);
	
	
	angle+=360/20;
	
	}
  }
  let angle=0;
  task main{
  fire;
 f;SetMovePosition03(GetEnemyX+40,GetEnemyY-50,5,3);
  loop{yield;
  
  dir+=2;
  
  }
  
  }
  let angle2=0;
  task f{
  
  fi=1;
  
  }
  task fg{
  loop{yield;a++;}
  }
  let a=0;let s=0;
  task fire{
  fg;
 
 

 wait(40);
  loop(20){a+=5;
  wait(10);angle2=rand(0,360);s=rand_int(1,3);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
 
  CreateShot01(GetX,GetY,3,-a,60,0);
  CreateShot01(GetX,GetY,3,-a+180,60,0);
  
  
  CreateShot01(GetX,GetY,3.5,90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90+90,41,5);
  CreateShot01(GetX,GetY,3.5,0,41,5);
  CreateShot01(GetX,GetY,2.5,270-a/1.3,41,5);
  
  
  
   
  
  
  
  
  }SetLife(0);
  
  
  
  }
  
   function wait(t){
    loop(t){yield;}
  }
  }
  

script_enemy fam4{let fi=0;
    let gr = GetCurrentScriptDirectory ~ "circle2.png";
  let dir=0;
  let r=80;
  @Initialize{
  SetLife(2000);
  LoadGraphic(gr);
  main;
  }
  @MainLoop{yield;
  
  }
  @DrawLoop{
   SetTexture(gr);SetAlpha(190);
 SetGraphicAngle(0,0,-dir*2);
 
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.5,0.5);
	DrawGraphic(GetX,GetY);
	
	SetTexture(gr);SetAlpha(130);
 SetGraphicAngle(0,0,dir);
	SetGraphicRect(0,0,128,127);
	SetGraphicScale(0.3,0.3);
	DrawGraphic(GetX,GetY);
	

  }
  @Finalize{
  PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan0.wav");
  
  
  loop(20){
	
	CreateShot01(GetX,GetY,1.8,angle,230,5);
	
	
	angle+=360/20;
	
	}
  
  
  
  
  }
  let angle=0;
  task main{
  fire;
  f;SetMovePosition03(GetEnemyX-40,GetEnemyY-50,5,3);
  loop{yield;
  
  dir+=2;
  
  }
  
  }
  let angle2=0;
  task f{
  
  fi=1;
  
  }
  task fg{
  loop{yield;a++;}
  }
  let a=0;let s=0;
  task fire{
  fg;
 
 

 wait(40);
  loop(20){a+=5;
  wait(10);angle2=rand(0,360);s=rand_int(1,3);PlaySE(GetCurrentScriptDirectory ~ ".\Sounds\se_tan01.wav");
 
  CreateShot01(GetX,GetY,3,a,60,0);
  CreateShot01(GetX,GetY,3,a+180,60,0);
 
  
 CreateShot01(GetX,GetY,3.5,90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90,41,5);
  CreateShot01(GetX,GetY,3.5,90+90+90,41,5);
  CreateShot01(GetX,GetY,3.5,0,41,5);
  CreateShot01(GetX,GetY,2.5,270+a/1.3,41,5);
  
  
  
 
  
  
  }SetLife(0);
  
  
  
  }
  
   function wait(t){
    loop(t){yield;}
  }
  }
  

  
  
  
  
  
  
  











  
  
  
  
  
  
  
  
  










