//#TouhouDanmakufu[Plural]
#ScriptVersion[3]
#System["./default_system/Default_System.txt"]
#Player["./player/Marisa.txt"]
#Title["Boss2"]
#Text["Boss2"]

#include "./Functions.txt"
#include "./Effects.txt"
#include "./Sounds.txt"

@Initialize
{
	SetCommonData("scriptID", GetOwnScriptID);

	SetPlayerClip(10, 10, GetStgFrameWidth - 10, GetStgFrameHeight - 10);

		
	TPlural;

}

@Event
{
	alternative (GetEventType())
		case (EV_USER + 1) {				//create item
			let arguments = GetEventArgument(0);
			let type = arguments[0];
			let x = arguments[2];
			let y = arguments[3];
			let points = arguments[1];
		}
		case (EV_USER + 2) {				//create plural effect, includes: SUMMON_CIRCLE, FROG_OVERLAY, CONCENTRATION_CIRCLE, EXPLOSION, LIGHT_EFFECT, BULLET_BREAK
			let arguments = GetEventArgument(0);
			let effectType = arguments[0];
			
			if (effectType == SUMMON_CIRCLE) {SetCommonData("summonCircle", true); bossSummonCircle(102, 3, 105, 0.2); bossSummonCircle2(102, 3, 105, 0.2);}  //diameter, spin, pulse period, pulse amplitude
			if (effectType == FROG_OVERLAY) {SetCommonData("frogOverlay", true); frogOverlay(128, 105, 0.15);}  //diameter, spin, pulse period, pulse amplitude
			if (effectType == CONCENTRATION_CIRCLE) {concentrationCircle(arguments[1], arguments[2], arguments[3], arguments[4]);}  //x, y, dAlpha, dScale
			if (effectType == EXPLOSION) {explosionEffect(arguments[1], arguments[2], arguments[3], arguments[4]);}  //x, y, dAlpha, dScale
			if (effectType == LIGHT_EFFECT) {lightEffect(arguments[1], arguments[2], arguments[3], arguments[4], arguments[5], arguments[6], arguments[7]);} //x, y, sScale, frames, r, g, b
			if (effectType == BULLET_BREAK) {bulletBreak(arguments[1], arguments[2], arguments[3])}  //x, y, scale
		}
		case (EV_USER + 3) {				//delete plural effect
			let arguments = GetEventArgument(0);
			let effectType = arguments[0];
			
			if (effectType == SUMMON_CIRCLE) {SetCommonData("summonCircle", false);}
			if (effectType == FROG_OVERLAY) {SetCommonData("frogOverlay", false);}
		}
}

@MainLoop
{
	yield;
}

task TPlural
{
	let current = GetCurrentScriptDirectory;
	let scene = ObjEnemyBossScene_Create; 
	
	if(GetCommonData("Player0", true)) {
	ObjEnemyBossScene_Add(scene, 0, current ~ "./Boss3IntroReimu.txt");
	}
	if(GetCommonData("Player1", true)) {
	ObjEnemyBossScene_Add(scene, 0, current ~ "./Boss3IntroMarisa.txt");
	}
	if(GetCommonData("Player2", true)) {

	}
	ObjEnemyBossScene_Add(scene, 0, current ~ "./Boss3NS1E.txt");
	ObjEnemyBossScene_Add(scene, 0, current ~ "./Boss3S1E.txt");
	ObjEnemyBossScene_Add(scene, 1, current ~ "./Boss3NS2E.txt");
	ObjEnemyBossScene_Add(scene, 1, current ~ "./Boss3S2E.txt");
	ObjEnemyBossScene_Add(scene, 2, current ~ "./Boss3NS3E.txt");
	ObjEnemyBossScene_Add(scene, 2, current ~ "./Boss3S3E.txt");
	play(1, 40);
	if(GetCommonData("Player0", true)) {
	ObjEnemyBossScene_Add(scene, 2, current ~ "./Boss3OutroReimu.txt");
	}
	if(GetCommonData("Player1", true)) {
	ObjEnemyBossScene_Add(scene, 2, current ~ "./Boss3OutroMarisa.txt");
	}
	if(GetCommonData("Player2", true)) {

	}
		
	ObjEnemyBossScene_Regist(scene);
	
	while (!Obj_IsDeleted(scene)) {
		yield;
	}
	
	DeleteShotAll(TYPE_ALL, TYPE_IMMEDIATE);
	SetAutoDeleteObject(true);
	wait(120);
	
	CloseScript(GetOwnScriptID());
	return;
}

