#東方弾幕風[Stage]
#Title[幻想妖洞窟　Ｖｅｒ０．０９]
#Text[]
#Player[REIMU,MARISA,.\Patche\Patche\Patche.dnh]
#Image[]
#BackGround[Default]
#ScriptVersion[2]

script_stage_main{
#include_function ".\Config.txt"
#include_function ".\Stage function.txt"
#include_function ".\Patche\Library\InitializePatcheSystemOnStage.dnh"

task StageTask{//ステージタスク
	#include_function ".\StageTask.txt"
	#include_function ".\StageMainA.txt"
	#include_function ".\Config.txt"
	
	ChackMode();

	let P = ChoosePatchePlayer;
	if(IsReplay == false){SetCommonData("PLAYER",P);
	SaveCommonDataInReplayFile();}
	else if(IsReplay == true){LoadCommonDataFromReplayFile();}

	let E = GetCommonData("EASY_START");
	let N = GetCommonData("NORMAL_START");
	let H = GetCommonData("HARD_START");
	let L = GetCommonData("LUNATIC_START");


	if(GetPlayerType() == USER_PLAYER){setPlayerIndex(GetCommonData("PLAYER"));}


	let scorebonus = trunc(GetCommonData("MAGICPOINT") * GetCommonData("MAGICPOINT_BONUSRATE"));
	let spellbonus = trunc(GetCommonData("MAGICPOINT") * 4000);
	SetCommonData("SCOREBONUS",scorebonus);
	SetCommonData("SPELLBONUS",spellbonus);

	if(E == 1){
	EasyStage1;
	EasyStage2;
	EasyStage3;
	}
	if(E == 2){
	EasyStage1;
	}
	if(E == 3){
	EasyStage2;
	}
	if(E == 4){
	EasyStage3;
	}
	if(N == 1){
	NormalStage1;
	NormalStage2;
	NormalStage3;
	}
	if(N == 2){
	NormalStage1;
	}
	if(N == 3){
	NormalStage2;
	}
	if(N == 4){
	NormalStage3;
	}
	if(H == 1){
	HardStage1;
	HardStage2;
	HardStage3;
	}
	if(H == 2){
	HardStage1;
	}
	if(H == 3){
	HardStage2;
	}
	if(H == 4){
	HardStage3;
	}
	if(L == 1){
	LunaticStage1;
	LunaticStage2;
	LunaticStage3;
	}
	if(L == 2){
	LunaticStage1;
	}
	if(L == 3){
	LunaticStage2;
	}
	if(L == 4){
	LunaticStage3;
	}
	if(E >= 5||N >= 5||H >= 5||L >= 5){
	ClearStage();//未完成なのでステージ終了
	}

	ClearStage();//ステージクリア
	}

	@Initialize(){
	ExpertEx(false,3,ChoosePlayerLife());
	SetRateScoreSystemEnable(false);
	StageTask();//ステージタスク起動
	//各種システムタスク起動
	PointExtend();
	MagicPointOnStage();
	MagicPowerOnStage();
	MusicControl();
	BGControl();
	if(GetPlayerType() == USER_PLAYER){initPatche(false,true,true);}
	}
		
	@MainLoop(){
	let scorebonus = trunc(GetCommonData("MAGICPOINT") * GetCommonData("MAGICPOINT_BONUSRATE"));
	let spellbonus = trunc(GetCommonData("MAGICPOINT") * 2000);
	SetCommonData("SCOREBONUS",scorebonus);
	SetCommonData("SPELLBONUS",spellbonus);
	yield;//毎フレームタスク復帰
	}	

	@DrawTopObject{
	MagicPointDrawText();
	}

	@BackGround(){
	DrawGraphic(GetCenterX,GetCenterY);
	}
	}

	@Finalize(){
	}

}