#TouhouDanmakufu[Stage]
#Title["Jealous Green Eyes"]
#Text["Difficulty: Warm"]
#ScriptVersion[3]
#System["./default_system/Default_System.txt"]
#Background["./default_System/Default_Background.txt"]
#include"./default_system/Default_Index.txt"

@Initialize{
Difficulty(3);
SetCommonData("GetStageScriptID", GetOwnScriptID());
STAGE;
}

@MainLoop{
if(GetPlayerState()==STATE_END){
	loop(60){yield;}
	CloseStgScene();
}

yield;
}

//GetCommonData("BossX", 0);
//GetCommonData("BossY", 0);

@Event {
	alternative(GetEventType)
	case(EV_USER_STAGE) {
	let ar = GetEventArgument(0);
	if(ar[0]==true){ascent(i in 0..1){Vortex(GetCommonData("BossX", 0), GetCommonData("BossY", 0), 0.1, 0.06+i/50, 255, -10, [0, 255, 12], 6+i);}PlaySound("explode",255,0);}
	if(ar[1]==true){ascent(i in 0..10){Particle(GetCommonData("BossX", 0), GetCommonData("BossY", 0), rand(1, 8), rand(0,360), 0.5, rand(0,360), "Cherry", [0, 255, 12], 4);}}	
	if(ar[2]==true){ascent(i in 0..15){CreateItemU1(1,GetCommonData("BossX", 0)+rand(-50, 50), GetCommonData("BossY", 0)+rand(-50, 50), 1000);}}	
	if(ar[3]==true){ascent(i in 0..4){Vortex(GetCommonData("BossX", 0), GetCommonData("BossY", 0), 0.1, 0.06+i/50, 255, -3, [0, 255, 12], 6+i);}PlaySound("explodebig",255,0);}
	if(ar[4]==true){ascent(i in 0..45){Particle(GetCommonData("BossX", 0), GetCommonData("BossY", 0), rand(1, 15), rand(0,360), 0.5, rand(0,360), "Cherry", [0, 255, 12], 4);}}	
	if(ar[5]==true){Screenshake(60, 5); Slowdown(60);}
	}
}

@Finalize{}

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 ~ "./SP3.txt");
	ObjEnemyBossScene_LoadInThread(obj);
	ObjEnemyBossScene_Regist(obj);
	
    while(!Obj_IsDeleted(obj)){
        yield;
    }
	
	loop(120){yield;}
	StageClear(1000000);
	loop(90){yield;}
	if(GetCommonData("GotHighScore", 0) == 1){Highscore;}
	loop(90){yield;}
	SaveCommonDataAreaA2("HighScore",GetCurrentScriptDirectory ~ "./default_system/score.dat");
	loop(30){yield;}
	CloseStgScene;
}