#TouhouDanmakufu[Stage]
#Title[Trickysticks' Sakuya Script -Hard-]
#Text[Recommended player: Reimu B.
Seriously play as her. Reimu A is for masochists.
Anyway, you challenged Sakuya to a danmaku duel. I wonder why you're in the forest?]
#Player[REIMU]
#ScriptVersion[2]
#PlayLevel[Hard]



script_stage_main{
#include_function ".\stagestuff.txt";
	 let livepoint = 50;
   let m = -1400;
   let n = -700;
   let o = -1000;
   let acc1 = 10;
	let graze = 0;
	let reqgraze = 200;
   let acc2 = 0;
   let acc3 = 0;
   let acc4 = 0;
   let acc5 = 0;
   let acc6 = 0;
   let acc7 = 0;
   let acc8 = 0;
   let blos = 0;
   let swivel = 0;
   let swivel2 = 0;
   let random1 = 0;
   let random2 = 0;
   let random3 = 0;
   let l = 0;
   let ff = 0.5;
   let f2 = 0;
   let f3 = 0;
   let f4 = 0;
   let f5 = 0;
   let f6 = 0;
   let f7 = 0;
   let f8 = 0;
   let f = 0;
   let inv = 0;
   let nbg = GetCurrentScriptDirectory ~ "sprites\nbg1.png";
   let nbg2 = GetCurrentScriptDirectory ~ "sprites\nbg2.png";
   let nbg3 = GetCurrentScriptDirectory ~ "sprites\nbg4.png";
   let nbg4 = GetCurrentScriptDirectory ~ "sprites\nbg5.png";
   let nbg5 = GetCurrentScriptDirectory ~ "sprites\nbg2.png";
   let nbg6 = GetCurrentScriptDirectory ~ "sprites\nbg6.png";
   let depth_buffer_enable = false;
   let ST1 = GetCurrentScriptDirectory~"mu\bgm.mp3";
	@Initialize{
	LoadSE(GetCurrentScriptDirectory~"se_extend.wav");
	LoadMusic(ST1);
	stage;
	LoadGraphic(nbg);
	SetNormPoint(50);
	LoadGraphic(nbg2);
	LoadGraphic(nbg3);
	LoadGraphic(nbg4);
	LoadGraphic(nbg5);
	
	
  }




function wait(w) { loop(w){ yield; } }

function WaitForZeroEnemy{ while(GetEnemyNum() != 0){yield;} } 

task stage{
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaN1_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaN2_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaN3_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaS1_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaS2_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaS3_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaS4_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"SakuyaS5_H.txt");

PlayMusic(ST1);
LoadGraphic(nbg);
	LoadGraphic(nbg2);
	LoadGraphic(nbg3);
	LoadGraphic(nbg4);
	LoadGraphic(nbg5);
f7 = 1;
wait(120);
CreateEnemyBossFromFile(GetCurrentScriptDirectory~"SakuyaH.txt", GetCenterX+130, -90, 0, 0, 0);
wait(120);
f7 = 2;
WaitForZeroEnemy;
wait(420);
  Clear;
 
 

 }


	@MainLoop{

	
      m += 5;
      n += 5;
      o += 500;
      f += ff;
      f8 += ff;
	
     
yield;

if(GetPoint>=livepoint){
ExtendPlayer(1);
livepoint=100+livepoint;
PlaySE(GetCurrentScriptDirectory~"se_extend.wav");
SetNormPoint(livepoint);

}
  }




  @BackGround{


swivel = 10*sin(swivel2);
swivel2++;
if(GetCommonDataDefault("Stage1", 1)==1){ 
if(GetCommonDataDefault("background", 2)==1){
acc2 += 0.01;
/*
if(GetKeyState(VK_LEFT) == KEY_HOLD || GetKeyState(VK_LEFT) == KEY_PUSH){
	if(swivel<9.35){
		swivel+=0.5;
		}
	}
if(GetKeyState(VK_RIGHT) == KEY_HOLD || GetKeyState(VK_RIGHT) == KEY_PUSH){
	if(swivel>-9.35){
		swivel-=0.5;
		}
	}
*/

if (f7>= 1){ if(acc7<180){ acc7 += 1; }} 
if(f7 == 2){ if(ff<5){ ff+=0.025; } }
if(f7 == 3){ if(ff>0){ ff-=0.01;} }
      WriteZBuffer(depth_buffer_enable);
      UseZBuffer(depth_buffer_enable);
      

      SetViewTo(0, -60, 80);
      SetViewFrom(10, -90, 25+10*cos(acc7));  
      SetFog ( 300, 750, 96, 96, 96); 

      SetAlpha(255);
      SetTexture(nbg2);
      SetGraphicRect(0, 0, 512, 512);

      SetGraphicAngle(0, 0, 0);
      SetGraphicScale(1,1);
      DrawGraphic(GetCenterX, GetCenterY);   

      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg);
      SetGraphicRect(0, 0+f8+acc2, 800, 1500+f8+acc2);
      SetGraphicAngle(90, 0, 0);
      SetGraphicScale(1,1);
      DrawGraphic3D(0, -300, 600);

      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg3);
      SetGraphicRect(0, 0+f8+acc2, 512, 1500+f8+acc2);
      SetGraphicAngle(90, 0, 0);
      SetGraphicScale(0.5,1);
      DrawGraphic3D(0, -300, 600);

loop(10){
      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg4);
      SetGraphicRect(0, 0, 512, 700);
      SetGraphicAngle(0, 0, 180);
      SetGraphicScale(0.5,0.5);
      DrawGraphic3D(180, -150, 1000-f+acc6-acc2);

      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg4);
      SetGraphicRect(0, 0, 512, 700);
      SetGraphicAngle(0, 0, 180);
      SetGraphicScale(0.5,0.5);
      DrawGraphic3D(-180, -150, 1000-f+acc6-acc2);
acc6 -= 110;
}
acc6 = 0;

if (f > 110)
	{
	f = 0;
	}


if (acc1 > 0){
acc1 -= 0.01;
}
if (acc3 < 100){
acc3 += 0.1;
}
acc5 = acc2;
f2 += 4;
f3++;
f4++;
f5 += 0.4;
}
yield;
}
if(GetCommonDataDefault("background", 2)==2){
if(f7 == 2){ if(ff<5){ ff+=0.05;} }
if(f7 == 3){ if(ff>0){ ff-=0.01;} }
SetAlpha(255);
SetTexture(nbg);
SetGraphicRect(0, 0-f, 800, 1500-f);
SetGraphicScale(0.55, 0.55);
DrawGraphic(GetCenterX, GetCenterY);

SetTexture(nbg3);
SetGraphicRect(0, 0-f, 800, 1500-f);
SetGraphicScale(0.55, 0.55);
DrawGraphic(GetCenterX+85, GetCenterY);

yield;
}

else if(GetCommonDataDefault("Stage2", 3)==2){
if(GetCommonDataDefault("background", 2)==1){
acc2 += 0.1;
if (f7 == 1){if(acc7 < 180){acc7 += 1;}} 
      WriteZBuffer(depth_buffer_enable);
      UseZBuffer(depth_buffer_enable);
      

      SetViewTo(0, -200, 80);
      SetViewFrom(10, -90, 10);  
      SetFog ( 50, 750, 119, 136, 153); 

      SetAlpha(255);
      SetTexture(nbg5);
      SetGraphicRect(0, 0, 512, 512);

      SetGraphicAngle(0, 0, 0);
      SetGraphicScale(1,1);
      DrawGraphic(GetCenterX, GetCenterY);   

      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg);
      SetGraphicRect(0, 0+f+acc2, 800, 1500+f+acc2);
      SetGraphicAngle(90, 0, 0);
      SetGraphicScale(1,1);
      DrawGraphic3D(0, -300, 600);

      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg3);
      SetGraphicRect(0, 0+f+acc2, 512, 1500+f+acc2);
      SetGraphicAngle(90, 0, 0);
      SetGraphicScale(0.5,1);
      DrawGraphic3D(0, -300, 600);

loop(74){
      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg2);
      SetGraphicRect(1, 1, 256, 256);
      SetGraphicAngle(0, 0, 180);
      SetGraphicScale(-0.6,0.6);
      DrawGraphic3D(100, -200, 15000-f+acc6-acc2);
      SetGraphicScale(0.6,0.6);
      DrawGraphic3D(-100, -200, 15000-f+acc6-acc2);
      SetGraphicAngle(0, 0, 180+60);
      SetGraphicScale(-0.7,0.7);
      DrawGraphic3D(100, -120, 15000-f+acc6-acc2-100);
      SetGraphicAngle(0, 0, 180-60);
      SetGraphicScale(0.7,0.7);
      DrawGraphic3D(-100, -120, 15000-f+acc6-acc2-100);

      SetAlpha(255);
      SetRenderState(ALPHA);
      SetTexture(nbg4);
      SetGraphicRect(0, 0, 96, 255);
      SetGraphicAngle(0, 0, 180);
      SetGraphicScale(0.5,0.5);
      DrawGraphic3D(80, -250, 15000-f+acc6-acc2-100);
      SetGraphicScale(-0.5,0.5);
      DrawGraphic3D(-80, -250, 15000-f+acc6-acc2-100);
acc6 -= 200;
}
acc4 = 0;
acc6 = 0;


if (acc1 > 0){
acc1 -= 0.01;
}
if (acc3 < 100){
acc3 += 0.1;
}
acc5 = acc2;
f2 += 4;
f3++;
f4++;
f5 += 0.4;

   yield;
}

}
}



@DrawTopObject {

}

  @Finalize{
    
}
}

