#TouhouDanmakufu[Stage]
#Title["Nuclear Hell"]
#Text["Difficulty: Hot [r](warmed by nuclear fusion)"]
#ScriptVersion[3]
//#System["./default_system/Default_SystemFullScreen.txt"]
#System["./default_system/Default_System.txt"]
#include "./default_system/MS_Index.txt"
#include "./default_system/MS_Enemy.txt"

@Initialize{
SetPlayerLife(3);
SetCommonData("IsStage", true);
STAGE;
BGM;
StageBackground;
LoadAssets;
ScoreExtend;
}

@MainLoop{
yield;
}

@Finalize{}


task ScoreExtend{
let score = 1000000;
	loop{
		if(GetScore>score){
			PlaySound(GetCurrentScriptDirectory ~ "./default_system/se/extend.wav",255);
			Extend;
			SetPlayerLife(GetPlayerLife + 1);
			score*=2;
		}
	yield;
	}
}

task BGM{
wait(60);
	let obj	= ObjSound_Create();
	ObjSound_Load(obj,GetCurrentScriptDirectory ~ "Default_System/se/bgm.mp3");
	ObjSound_SetSoundDivision(obj,SOUND_BGM);
	ObjSound_SetVolumeRate(obj,90);
	ObjSound_SetLoopEnable(obj,true);
	ObjSound_SetLoopTime(obj, 11.176, 60*2+57.283);
	ObjSound_Play(obj);

}

task STAGE{
	let obj=ObjEnemyBossScene_Create();
	/**/
        ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "./NS1.txt");
	ObjEnemyBossScene_Add(obj,1,GetCurrentScriptDirectory ~ "./SP1.txt");
	ObjEnemyBossScene_Add(obj,2,GetCurrentScriptDirectory ~ "./NS2.txt");
	ObjEnemyBossScene_Add(obj,2,GetCurrentScriptDirectory ~ "./SP2.txt");
	ObjEnemyBossScene_Add(obj,3,GetCurrentScriptDirectory ~ "./NS3.txt");
	ObjEnemyBossScene_Add(obj,3,GetCurrentScriptDirectory ~ "./SP3.txt");
	ObjEnemyBossScene_Add(obj,4,GetCurrentScriptDirectory ~ "./SP4.txt");
	ObjEnemyBossScene_Add(obj,5,GetCurrentScriptDirectory ~ "./SP5.txt");
	ObjEnemyBossScene_Add(obj,5,GetCurrentScriptDirectory ~ "./SP6.txt");
    ObjEnemyBossScene_LoadInThread(obj);
	
	TimerCountdown(obj);
	UtsuhoIsDed;
	ObjEnemyBossScene_Regist(obj);
	
    while(!Obj_IsDeleted(obj)){
        yield;
    }
	
	wait(60*4);
	CloseStgScene;
}

task UtsuhoIsDed{
	loop{
	while(GetCommonData("UtsuhoIsDed",0) < 1){yield;}
	PlaySound(GetCurrentScriptDirectory ~ "Default_System/se/death.ogg", 90);
	ScreenShake(120,15);
	Slowdown;
	loop(120){ExplodeEffectT(GetCommonData("bossx", 0), GetCommonData("bossy", 0), rand(0.5, 10), 0.6, "Cherry", [255, 10, 10], 4);}
	ascent(i in 0..6){ExplodeCircleT(GetCommonData("bossx", 0), GetCommonData("bossy", 0), 60, i*12, 0);}
	loop(40){CreateItemU1(1, GetCommonData("bossx", 0)+rand(-100, 100), GetCommonData("bossy", 0)+rand(-100, 100), 1000);}
	CreateItemU1(3, GetCommonData("bossx", 0), GetCommonData("bossy", 0), 1000);
	SetCommonData("UtsuhoIsDed",0);
	yield;
	}
}

task Slowdown{
StartSlow(TARGET_ALL, 15);
wait(20);
StopSlow(TARGET_ALL);
}