#TouhouDanmakufu[Stage]
#ScriptVersion[3]
#Title["stage1"]
#Text["stage"]
#System["./my_system/My_system.txt"]
#include "script/default_system/Default_ShotConst.txt"
#include "script/sample/nociception/my_system/BGMtasks.txt"
#include "./enemy1.txt"
#include "./enemy2.txt"
#include "./enemy3.txt"
#include "./enemy4.txt"
#include "./enemy8.txt"
#include "./3dstage1.txt"
#include "./titletask.txt"
 
 
let stageMusic = true;
 
@Initialize
{
    TStage();
    renderStage;
    scrollStage;
    stagetitle;
   
   
 
 
  SetPlayerLife(6);
 
 
}
@MainLoop
{
 
if (GetPlayerState() == STATE_END) {
wait(20); CloseStgScene(); }
    yield;
}
@Finalize
{
}
task TStage
{ playSTG1;
   
 
wait(100);
 
     
      CreateStageEnemy2(100, 2, 0, 180);
     
      CreateStageEnemy2(200, 2, 0, 333);
     
      CreateStageEnemy2(300, 2, 0, 444);
      wait(500);
      DeleteShotAll(TYPE_ALL, TYPE_ITEM);
      wait(130);
      CreateStageEnemy1(100, 2, 0, 180);
      wait(30);
      CreateStageEnemy1(200, 2, 0, 333);
      wait(30);
      CreateStageEnemy1(300, 2, 0, 444);
      CreateStageEnemy2(100, 2, 0, 180);
      wait(30);
      CreateStageEnemy2(200, 2, 0, 333);
      wait(30);
      CreateStageEnemy2(300, 2, 0, 444);
       CreateStageEnemy1(100, 2, 0, 180);
      wait(30);
      CreateStageEnemy1(200, 2, 0, 333);
      wait(30);
      CreateStageEnemy1(300, 2, 0, 444);
      CreateStageEnemy2(100, 2, 0, 180);
      wait(30);
      CreateStageEnemy2(200, 2, 0, 333);
      wait(30);
      CreateStageEnemy2(300, 2, 0, 444);
      wait(200);
      DeleteShotAll(TYPE_ALL, TYPE_ITEM);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(30);
      CreateStageEnemy32(400, 2, 180, 0);
      wait(20);
      CreateStageEnemy32(400, 2, 200, 0);
      wait(20);
      CreateStageEnemy32(400, 2, 220, 0);
      wait(100);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(30);
      CreateStageEnemy32(400, 2, 180, 0);
      wait(20);
      CreateStageEnemy32(400, 2, 200, 0);
      wait(20);
      CreateStageEnemy32(400, 2, 220, 0);
      wait(30);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(20);
      CreateStageEnemy3(0, 2, 0, 0);
      wait(100);
      CreateStageEnemy4(200, -2, 3, 180);
      CreateStageEnemy8(400, 400, 1, 2);
      wait(50);
      CreateStageEnemy8(400, 400, 1, 2);
      wait(50);
      CreateStageEnemy8(400, 400, 1, 2);
      wait(50);
      CreateStageEnemy8(400, 400, 1, 2);
      CreateStageEnemy4(200, -2, 3, 180);
     
     
      wait(520);
 
       let dir = GetCurrentScriptDirectory();
 
    let path = dir ~ "Plural3.txt";
   
   
    let idScript = LoadScriptInThread(path);
    loop(60){yield;}
    StartScript(idScript);
    stageMusic = false;
 
   
   
    while(!IsCloseScript(idScript) && GetPlayerState() != STATE_END)
    {  
   
        yield;
    }
   
    loop(240){yield;}
   
    CloseStgScene();
 
     
}
 
@Event {
    alternative(GetEventType())
    case(EV_PAUSE_ENTER){
           
            ObjSound_Stop(bgm);
       
       
    }
            case(EV_PAUSE_LEAVE){
    if(stageMusic){    
            ObjSound_Play(bgm);
            }
       
       
    }
	
	//pause code by jackie 
   
}

 
 
