#TouhouDanmakufu[Stage]
#Title[Trickysticks' Contest Entry]
#Text[Note: Please play as Reimu B.
There is an odd disturbance around the Nameless Path.
Reimu sets out to investigate. 
I wonder what oddity she'll find there?]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{
	let ST1 = GetCurrentScriptDirectory ~ "Stage\SunnyMid\mu\bgm.mp3";
	let f7on = true;
	let argument = 1;
	let f = 0;
	let var = 0;
	let ff = 5;
	let livepoint = 100;
	 let nbg = GetCurrentScriptDirectory ~ "Stage\ef\nbg1.png";
   	let nbg3 = GetCurrentScriptDirectory ~ "Stage\ef\nbg3.png";
	@Initialize{
	LoadSE(GetCurrentScriptDirectory~"extend.wav");
	LoadMusic(ST1);
	stage1;
	assert(GetPlayerType==REIMU_B, "Please play as Reimu B. Or else. Seriously, I went through the effort of making the script raise an error if you don't. Just play as her.");
     
  }




function ToFormatString(n){
	let dummystring = ToString(n);
	let dummystring2 = "";
	loop(7){
		dummystring = erase(dummystring,(length(dummystring)-1));
	}
	ascent(i in 0..length(dummystring)){
		if((length(dummystring)-i)%3==0 && i!=0){
			dummystring2 = dummystring2 ~ ",";
		}
		if(i==0){
			dummystring2 = ToString(dummystring[0]);
		}else{
			dummystring2 = dummystring2 ~ ToString(dummystring[i]);
		}
	}
	return dummystring2;
}

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

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

task stage1{
LoadGraphic(nbg);
LoadGraphic(nbg3);
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt");  
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1H.txt");   
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt");   
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\SunnyMid\SunnyConvo.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\SunnyMid\SunnyN1_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\SunnyMid\SunnyS1_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\YuyukoBoss\YuyukoN1_H.txt");
CompileEnemyFromFile(GetCurrentScriptDirectory~"Stage\YuyukoBoss\YuyukoS1_H.txt");

SetShotAutoDeleteClip(10, 10, 10, 10);
 PlayMusic(ST1);

	DeleteSE("se\seEnemyExplode01.wav");
	DeleteSE("se\seUseSpellCard.wav");
wait(240);
loop(16){
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1H.txt", GetCenterX, GetClipMinY-50+var, 0, 0, argument);
var+=2.5;
wait(20);
argument=argument*-1;
}
wait(90);

loop(8){
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1H.txt", GetCenterX+((var*2)*argument), GetClipMinY-50+var, 0, 0, argument);
var+=2.5;
wait(10);
argument=argument*-1;
}
wait(120);
var=0;
loop(5){
argument=0;
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1H.txt", GetClipMinX+40+(var*10), GetClipMinY-20, 0, 0, argument);
var+=2.5*4;
wait(0);
argument=0;
}
wait(120);
var=0;
loop(5){
argument=0;
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1H.txt", GetClipMinX+65+(var*10), GetClipMinY-20, 0, 0, argument);
var+=2.5*4;
wait(0);
argument=0;
}
wait(240);

loop(2){
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", 0.5*(GetClipMaxX+GetCenterX), GetClipMinY-30, 0, 0, 0);
wait(75);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", 0.5*(GetClipMinX+GetCenterX), GetClipMinY-30, 0, 0, 0);
wait(120);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", GetCenterX, GetClipMinY-30, 0, 0, 1+argument);
wait(100);
argument++;
}

wait(240);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMaxX, GetClipMinY-30, 0, 0, 1);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMinX, GetClipMinY-30, 0, 0, -1);
wait(300);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMaxX-50, GetClipMinY-30, 0, 0, 1);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMinX+50, GetClipMinY-30, 0, 0, -1);
wait(180);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMaxX-125, GetClipMinY-30, 0, 0, 1);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMinX+125, GetClipMinY-30, 0, 0, -1);
wait(240);
loop(1){
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMinX+20, GetClipMaxY+10, 0, 0, 2);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetClipMaxX-20, GetClipMaxY+10, 0, 0, 2);
wait(210);
}
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1M.txt", GetCenterX, GetClipMinY-30, 0, 0, 3);

WaitForZeroEnemy;
wait(180);
	DeleteEnemyShotToItem(ALL);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage\SunnyMid\SunnyH.txt", GetCenterX, -75, 0, 0, 0);
	WaitForZeroEnemy;
wait(180);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", GetClipMinX+60, GetClipMinY-30, 0, 0, 3);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", GetClipMaxX-60, GetClipMinY-30, 0, 0, 3);
wait(540);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", GetCenterX+60, GetClipMinY-30, 0, 0, 4);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", GetCenterX-60, GetClipMinY-30, 0, 0, 4);
wait(480);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Stage\Enemy\Fairy1L.txt", GetCenterX, GetClipMinY-30, 0, 0, 5);
WaitForZeroEnemy;
wait(120);
CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Stage\YuyukoBoss\YuyukoH.txt", GetCenterX+130, -90, 0, 0, 0);

	WaitForZeroEnemy;
wait(180);
  Clear;
 
 

 }


	@MainLoop{

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


yield;

}



SetNormPoint(livepoint);

	
     
yield;
  }




  @BackGround{

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;
f+=ff;
}

@DrawTopObject {

}

  @Finalize{
    
}
}

