#TouhouDanmakufu[Stage]
#Title[Stage5]
#Text[complete!1]
#Player[REIMU]
#PlayLevel[lunetik]
#ScriptVersion[2]

script_stage_main{
let D = GetCurrentScriptDirectory;
let bgm = D ~ "bgm\dreem batlle.wav";

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

 task stage{
  Wait(120);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  Wait(120);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX-190, GetCenterY-240, 2, 45, 0);
  Wait(120);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX+200, GetCenterY-125, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  Wait(90);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  Wait(90);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  Wait(90);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX+200, GetCenterY-125, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  Wait(90);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  Wait(90);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX-190, GetCenterY-240, 2, 45, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX+200, GetCenterY-125, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX-190, GetCenterY-240, 2, 45, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX+200, GetCenterY-125, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 3.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX-190, GetCenterY-240, 2, 45, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX+200, GetCenterY-80, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX+200, GetCenterY-125, 2, 180, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"enemy 2.txt", GetCenterX-200, GetCenterY-125, 2, 0, 0);
  Wait(90);
  PlayMusic(bgm);
  Wait(40);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"Bos.txt", 0, 0, 0, 0, 0);
  WaitForZeroEnemy;
  Wait(360);
  CreateEnemyBossFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard.txt", 0, 0, 0, 0, 0);
  Wait(180);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 3.txt",0, 0, 0, 0, 0);
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 3.txt", 0, 0, 0, 0, 0);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(60);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(30);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(30);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(30);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(30);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"fiynull spppppelkard 2.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  Wait(10);
  WaitForZeroEnemy;
  Wait(600);
  DeleteMusic(bgm);
  Wait(200);
  CreateEnemyFromFile(GetCurrentScriptDirectory~"odur fainal spel!.txt", GetCenterX-200, GetCenterY-50, 1.8, 0, 0);
  WaitForZeroEnemy;
  Wait(50);
  Clear;
 }
 @Initialize{
 stage;
LoadMusic(bgm);
  }
 @MainLoop{yield;}
 @Background{}
 @Finalize{}
}