#TouhouDanmakufu[Stage]
#Title[Marisa stage]
#Text[My Second!]
#Image[./Moon.png]
#BGM[./bgm5.ogg]
#Player[FREE]
#ScriptVersion[2]
#PlayLevel[Hard]

script_stage_main{
let bgm5 = GetCurrentScriptDirectory~"bgm5.mp3";
let background = GetCurrentScriptDirectory~"moon.png";

 function Wait(let frames){
   loop(frames){yield;}
 }
 function WaitForZeroEnemy{
  while(GetEnemyNum != 0){yield;}
 }

 function WaitForEventEnd{
while(OnEvent){yield;}
}
 task stage2{
	DeleteSE("se\seEnemyExplode01.wav");
	DeleteSE("se\seUseSpellCard.wav");
	CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt");
  CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt");
  CompileEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt");
  CompileEnemyFromFile(GetCurrentScriptDirectory~"EnemyA.txt");
  CompileEnemyFromFile(GetCurrentScriptDirectory~"EnemyAH.txt");
	CompileEnemyFromFile(GetCurrentScriptDirectory~"EnemyB.txt");
	CompileEnemyFromFile(GetCurrentScriptDirectory~"EnemyBH.txt");
	CompileEnemyFromFile(GetCurrentScriptDirectory~"EnemyC.txt");
  Wait(180);
  
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX, 0, 0, 0, 0);
  WaitForZeroEnemy;
	Wait(120);
	 CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-30, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+30, 0, 0, 0, 0);
  WaitForZeroEnemy;
	Wait(120);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+30, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-30, 0, 0, 0, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+60, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-60, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+90, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-90, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+120, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-120, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+150, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-150, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+180, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-180, 0, 0, 0, 0);


 
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	WaitForZeroEnemy;
	Wait(60);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+20, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-20, 0, 0, 0, 0);
CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+40, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-40, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+60, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-60, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+80, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-80, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+100, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-100, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+120, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-120, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+140, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-140, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+160, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-160, 0, 0, 0, 0);
  WaitForZeroEnemy;
	Wait(60);
	WaitForZeroEnemy;
	Wait(120);
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"MariPlural.txt", 0, 0, 0, 0, 0);
	WaitForZeroEnemy;
	CreateEventFromScript("ma");
	WaitForEventEnd;
	WaitForZeroEnemy;
	Wait(60);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyA.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(315);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyB.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	Wait(315);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyA.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyB.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyA.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyB.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+60, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-60, 0, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+80, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-80, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+100, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-100, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+120, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-120, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+140, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-140, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX+160, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy1.txt", GetCenterX-160, 0, 0, 0, 0);
  WaitForZeroEnemy;
	Wait(60);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyA.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyB.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyA.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyB.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy2.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"Enemy3.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyAH.txt", GetClipMaxX, GetClipMinY+10, 0, 0, 0);
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyBH.txt", GetClipMinX, GetClipMinY+10, 0, 0, 0);
	Wait(30);
	WaitForZeroEnemy;
	CreateEnemyFromFile(GetCurrentScriptDirectory~"EnemyC.txt", GetCenterX, GetClipMinY+10, 0, 0, 0);
	WaitForZeroEnemy;
	FadeOutMusic(GetCurrentScriptDirectory~"bgm5.ogg", 4);
	Wait(360);
	 CreateEnemyBossFromFile(GetCurrentScriptDirectory~"secbossplural.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
	CreateEventFromScript("moo");
	Wait(60);
	WaitForEventEnd;
 
  Clear;
	
 }

  @Initialize{
LoadGraphic(background);
LoadMusic(bgm5);
PlayMusic(bgm5);

 stage2;
  }
 @MainLoop{
   yield;
  }
  
@BackGround{
   SetTexture(background);
   SetGraphicRect(0, 0, 512, 512);
   DrawGraphic(GetCenterX, GetCenterY);
   
}


  @Finalize{

  }
}

script_event ma{
let reimu = GetCurrentScriptDirectory ~ ("reimu.png");
let marisa=GetCurrentScriptDirectory ~ ("marisa.png");
let marisasweat = GetCurrentScriptDirectory ~ ("MariSweatdrop.png");
let secant =GetCurrentScriptDirectory~ ("\cutin2.png");

@Initialize{
  LoadGraphic(reimu);
  LoadGraphic(secant);
	LoadGraphic(marisa);
	LoadGraphic(marisasweat);
 }

@MainLoop{
SetChar(LEFT, reimu);                 
SetGraphicRect(LEFT, 128, 0, 256, 256);           
MoveChar(LEFT, FRONT);                                      
MoveChar(RIGHT, BACK);
TextOutA("\c[RED] You ARE ordinary.");
SetChar(RIGHT, marisasweat); 
SetGraphicRect(RIGHT, 0, 0, 128, 257);
MoveChar(LEFT, BACK);
MoveChar(RIGHT, FRONT);                          
TextOutA("\c[WHITE] I'll get revenge!");           
End;           //This ends the event. REMEMBER ME!
SetStep(1);
}

 @Finalize{
  
 }
}
