#TouhouDanmakufu[Stage]
#Title[Grimoire of Marisa Full]
#Text[Fight for your life!]
#BackGround[User(.\img\BG.png,0,0)]
#Player[FREE]
#ScriptVersion[2]

script_stage_main{
let csd = GetCurrentScriptDirectory; 
let BossDeath = csd~"se/BossDeath.wav";
function Wait(let frames){ loop(frames){yield;}}
@Initialize{
	LoadSE(BossDeath);
	stage;
	}
 @MainLoop{
	yield;
	}
@Finalize{}
task stage{
	function WaitForZeroEnemy{ while(GetEnemyNum != 0){yield;} }
	Wait(60);
	CreateEnemyBossFromFile(GetCurrentScriptDirectory~"_Marisa.txt",GetCenterX,0,-5,90,NULL);
	WaitForZeroEnemy;
	PlaySE(BossDeath);
	if(Continued==true){CreateEventFromScript("End1");}
	else {CreateEventFromScript("End2");}
	yield;
	}
}

script_event End1{
	let MariNorm=GetCurrentScriptDirectory~"img\MariNorm.png";
	let MariSmug=GetCurrentScriptDirectory~"img\MariSmug.png";
	@Initialize{
		LoadGraphic(MariNorm);
		LoadGraphic(MariSmug);
	}
	@MainLoop{
		SetChar(RIGHT,MariSmug);SetGraphicRect(RIGHT,0,0,128,256);
		MoveChar(RIGHT,FRONT);
		TextOutA("\c[RED]So, how did you like\nmy new spells?");
		MoveChar(RIGHT,BACK);
		TextOutA("\c[BLUE]I think my hair's\non fire.");
		TextOutA("\c[BLUE]I guess that means your\nspells were good.");
		MoveChar(RIGHT,FRONT);
		SetChar(RIGHT,MariNorm);SetGraphicRect(RIGHT,0,0,128,256);
		TextOutA("\c[RED]Excellent! I knew you'd like them~");
		MoveChar(RIGHT,BACK);
		TextOutA("\c[BLUE]I didn-");
		MoveChar(RIGHT,FRONT);
		TextOutA("\c[RED]Time to test them out on someone else~!");
		SetChar(RIGHT,MariSmug);SetGraphicRect(RIGHT,0,0,0,0);
		MoveChar(RIGHT,BACK);
		TextOutA("\c[BLUE]Jeez, she's insane...");
		StageClear;
	}
	@Finalize{
	}
}

script_event End2{
	let MariDefeated=GetCurrentScriptDirectory~"img\MariDefeated.png";
	@Initialize{
		LoadGraphic(MariDefeated);
	}
	@MainLoop{	
		TextOutA("\c[RED]K-Kyah~!");
		SetChar(RIGHT,MariDefeated);SetGraphicRect(RIGHT,0,0,128,256);
		MoveChar(RIGHT,BACK);
		TextOutA("\c[BLUE]Your spells are too lazy.");
		TextOutA("\c[BLUE]Try not to copy stuff from other\npeople.");
		MoveChar(RIGHT,FRONT);
		TextOutA("\c[RED]You think I'd write a book on other\npeople's spells for nothing?");
		MoveChar(RIGHT,BACK);
		TextOutA("\c[BLUE]Books are for reading, not for crazy\nspell experiments.");
		MoveChar(RIGHT,FRONT);
		TextOutA("\c[RED]Damn...");
		StageClear;
	}
	@Finalize{
	}
}