#TouhouDanmakufu[Stage]
#ScriptVersion[3]
#Title["stage3"]
#Text["stage3"]
#System["./my_system/My_system.txt"]
#include "script/default_system/Default_ShotConst.txt"
#include "./enemy2.txt"
#include "./enemyball.txt"
#include "./3dstage3.txt"
#include "./titletask3.txt"



@Initialize
{
    TStage();
	renderStage;
	scrollStage;
	stagetitle3;

}
@MainLoop
{
if (GetPlayerState() == STATE_END) { 
wait(20); CloseStgScene(); }
    yield;
}
@Finalize
{
}
task TStage
{  let pathmidboss = GetCurrentScriptDirectory() ~ "./midbossplural1.txt";
	  let midbossScript = LoadScriptInThread(pathmidboss);
	  let pathmidboss2 = GetCurrentScriptDirectory() ~ "./midbossplural2.txt";
	  let midbossScript2 = LoadScriptInThread(pathmidboss2);

  wait(100);

CreateStageEnemy22(0, 0, 3, 30);
	CreateStageEnemy22(-10, 60, 3, 30);
	CreateStageEnemy22(-20, 120, 3, 30);
	wait(90);
	CreateStageEnemy23(360, 0, 3, +180);
	CreateStageEnemy23(370, 60, 3, +180);
	CreateStageEnemy23(380, 120, 3, +180);
	
	wait(440);
	CreateStageEnemyBall(180, 120, 3, 0);
	wait(20);
	CreateStageEnemyBall2(100, 120, 3, 0);
	wait(20);
	CreateStageEnemyBall2(260, 120, 3, 0);
	wait(200);
	CreateStageEnemyBall3(180, 120, 3, 0);
	wait(20);
	CreateStageEnemyBall4(100, 100, 3, 0);
	wait(20);
	CreateStageEnemyBall4(260, 100, 3, 0);
	wait(300);
	CreateStageEnemyBall(180, 120, 3, 0);
	wait(20);
	CreateStageEnemyBall2(100, 120, 3, 0);
	wait(20);
	CreateStageEnemyBall2(260, 120, 3, 0);
	wait(20);
	CreateStageEnemyBall3(180, 160, 3, 0);
	wait(20);
	CreateStageEnemyBall4(100, 50, 3, 0);
	wait(20);
	CreateStageEnemyBall4(260, 50, 3, 0);
	wait(200);
	CreateStageEnemyBall(180, 50, 3, 0);
	CreateStageEnemyBall3(180, 200, 3, 0);
	CreateStageEnemyBall(220, 50, 3, 0);
	CreateStageEnemyBall3(220, 200, 3, 0);
	
	
	 wait(400);
	   
	 
	    StartScript(midbossScript);
    while(!IsCloseScript(midbossScript) && GetPlayerState() != STATE_END){
      yield;
    }
	
	
	 wait(120);
	   
	 
	    StartScript(midbossScript2);
    while(!IsCloseScript(midbossScript2) && GetPlayerState() != STATE_END){
      yield;
    }
	wait(400);
	  
	   let dir = GetCurrentScriptDirectory();
    
    let path = dir ~ "./Plural5.txt";
    let idScript = LoadScriptInThread(path);
    loop(60){yield;}//
    StartScript(idScript);
	
  
    while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
    {
        yield;
    }
}

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