#TouhouDanmakufu[Stage]
#ScriptVersion[3]
#Title["Inversed Ideology"]
#Text["For LoCAA9: [r] Miracle Mallet Contest."]

let GCSD = GetCurrentScriptDirectory;
let blanket;
let lightimg = GCSD~"./img/light.png";
let al = 0;
let alswitch = -4;

@Initialize{
	
	AddArchiveFile(GCSD~"img.dat");
	AddArchiveFile(GCSD~"sounds.dat");
	AddArchiveFile(GCSD~"code.dat");
	LoadTexture(lightimg);
	
	SetPlayerLife(10);
	SetPlayerSpell(3);
	SetForbidPlayerShot(true);
	SetForbidPlayerSpell(true);
	StartScript(LoadScript(GCSD ~ "./code/SoundLib.txt"));
	StartScript(LoadScript(GCSD ~ "./code/SpellThings.txt"));
	StartScript(LoadScript(GCSD ~ "./code/EffectScript.txt"));
	StartScript(LoadScript(GCSD ~ "./code/ManageBGM.txt"));
	StartShotScript(GCSD ~ "./code/ShotScript.dnh");
	BeginningDialogue;
	
	blanket = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(blanket,lightimg);
	Obj_SetRenderPriorityI(blanket,79);
	ObjSprite2D_SetSourceRect(blanket,0,0,10,10);
	ObjSprite2D_SetDestRect(blanket,0,0,GetStgFrameWidth,GetStgFrameHeight);
	ObjRender_SetAlpha(blanket,0);
}

@MainLoop{
	al+=alswitch;
	if(al > 255){al=255;}
	if(al < 0){al=0;}
	ObjRender_SetAlpha(blanket,al);
	yield;
}

@Event{
	alternative(GetEventType)
	case(EV_USER + 70){alswitch=4;}
	case(EV_USER + 71){alswitch=-4;}
}

task BeginningDialogue{
	
	let startcut = LoadScript(GCSD~"./code/StartCutscene.txt");
	StartScript(startcut);
	while(!IsCloseScript(startcut)){yield;}
	StartPlural;
	
}

task StartPlural{
	
	let plural = LoadScript(GCSD~"./code/Plural.txt");
	StartScript(plural);
	alswitch=-4;
	while(!IsCloseScript(plural)){yield;}
	CloseStgScene;
	
}