function RealToIntString(let num){
	let lp=floor(log10(num))+1;
	let lp1=lp
	if(lp==0){result="0"}
	else{
		result="";
		loop(lp){
			result=result~ stringarray[num%(10^lp1)-num%(10^(lp1-1))/(10^(lp1-1))];
			lp1--;
			}
		}
	}
function ESkip{
	ascent(i in 0..ECharaNum){
		if(GetPlayerScriptName==EventCharacters[i]){
			EventSkip     =  EventSkipFlag;
			break;
			}
		else{	EventSkip     =  true;}
		}
	SetCommonData("EventSkipFlag",EventSkip);
	yield;
	AddBomb(initialbomb-GetPlayerBomb);
}
function StageOver1{
	event=true;
	loop(90){yield;}
	ForbidShot(event);
	ForbidBomb(event);
	bGraze=GetGraze-bGraze;
	bPoint=GetPoint-bPoint;
	bSpellGetNumber=GetCommonDataDefault("SPELLGET",0)-bSpellGetNumber;
	AnotherBonus=NoMissBonus*(stagenum+modenum);
	TotalBonus=(1000*(stagenum+modenum)+100*bPoint+150*bGraze)+AnotherBonus;
	IsClear=true;
	loop(100){
		AddScore(TotalBonus/100);
		yield;
		}
	while(GetKeyState(VK_SHOT) != KEYPUSH){yield;}
	IsClear=false;
	event=false;
	ForbidShot(event);
	ForbidBomb(event);
	bGraze=GetGraze;
	bPoint=GetPoint;
	bSpellGetNumber=GetCommonDataDefault("SPELLGET",0);
	}
function StageOver2{
	event=true;
	loop(90){yield;}
	ForbidShot(event);
	ForbidBomb(event);
	bGraze=GetGraze-bGraze;
	bPoint=GetPoint-bPoint;
	bSpellGetNumber=GetCommonDataDefault("SPELLGET",0)-bSpellGetNumber;
	AnotherBonus=NoContinueBonus*(stagenum+modenum);
	Penalty=200*misscountforstage;
	TotalBonus=(1000*(stagenum+modenum)+100*bPoint+150*bGraze+AnotherBonus)-Penalty;
	IsClear=true;
	loop(100){
		AddScore(TotalBonus/100);
		yield;
		}
	while(GetKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	IsClear=false;
	event=false;
	ForbidShot(event);
	ForbidBomb(event);
	bGraze=GetGraze;
	bPoint=GetPoint;
	bSpellGetNumber=GetCommonDataDefault("SPELLGET",0);
	}
function StageOver3{
	event=true;
	loop(90){yield;}
	ForbidShot(event);
	ForbidBomb(event);
	bGraze=GetGraze-bGraze;
	bPoint=GetPoint-bPoint;
	bSpellGetNumber=GetCommonDataDefault("SPELLGET",0)-bSpellGetNumber;
	Penalty1=200*misscountforstage;
	Penalty2=300*contcountforstage;
	TotalBonus(1000*(stagenum+modenum)+100*bPoint+150*bGraze)-Penalty1-Penalty2;
	IsClear=true;
	loop(100){
		AddScore(TotalBonus/100);
		yield;
		}
	while(GetKeyState(VK_SHOT)!=KEY_PUSH){yield;}
	IsClear=false;
	event=false;
	ForbidShot(event);
	ForbidBomb(event);
	bGraze=GetGraze;
	bPoint=GetPoint;
	bSpellGetNumber=GetCommonDataDefault("SPELLGET",0);
	}
task Rdraws1{
	SetFontColor(200,255,220,180,240,200);
	DrawText("Stage Result",52,128,16,255);
	DrawText("Stage Bonus      :"~RealToIntString(1000*(stagenum+modenum)),70,160,16,255);
	DrawText("Point        "~RealToIntString(bPoint)~" : "~RealToIntString(100*bPoint),70,176,16,255);
	DrawText("Graze        "~RealToIntString(bGraze)~" : "~RealToIntString(150*bGraze),70,192,16,255);
	DrawText("NoMiss Clear Bonus   : "~RealToIntString(AnotherBonus),70,208,16,255);
	DrawText("Push Shot Key!",178,376,24,255);
	DrawText(" Total Bonus : "~RealToIntString(TotalBonus),70,272,16,255);
	DrawText("Push Shot Key!",178,376,24,255);
	}
task Rdraws2{
	SetFontColor(200,255,220,180,240,200);
	DrawText("Stage Result",52,128,16,255);
	DrawText("Stage Bonus      :"~RealToIntString(1000*(stagenum+modenum)),70,160,16,255);
	DrawText("Point        "~RealToIntString(bPoint)~" : "~RealToIntString(100*bPoint),70,176,16,255);
	DrawText("Graze        "~RealToIntString(bGraze)~" : "~RealToIntString(150*bGraze),70,192,16,255);
	DrawText("NoContinue Clear Bonus   : "~RealToIntString(AnotherBonus),70,208,16,255);
	DrawText("Miss Penalty : "~RealToIntString(Penalty)~",70,224,16,255);
	DrawText("Push Shot Key!",178,376,24,255);
	DrawText(" Total Bonus : "~RealToIntString(TotalBonus),70,272,16,255);
	DrawText("Push Shot Key!",178,376,24,255);
	}
task Rdraws3{
	SetFontColor(200,255,220,180,240,200);
	DrawText("Stage Result",52,128,16,255);
	DrawText("Stage Bonus      :"~RealToIntString(1000*(stagenum+modenum)),70,160,16,255);
	DrawText("Point        "~RealToIntString(bPoint)~" : "~RealToIntString(100*bPoint),70,176,16,255);
	DrawText("Graze        "~RealToIntString(bGraze)~" : "~RealToIntString(150*bGraze),70,192,16,255);
	DrawText("Miss Penalty : "~RealToIntString(Penalty1)~",70,208,16,255);
	DrawText("Continue Penalty : "~RealToIntString(Penalty2)~",70,224,16,255);
	DrawText("Push Shot Key!",178,376,24,255);
	DrawText(" Total Bonus : "~RealToIntString(TotalBonus),70,272,16,255);
	DrawText("Push Shot Key!",178,376,24,255);
	}
task BGMcontrol{
	let BGMChecker=GetCommonDataDefault("BGMPLAYNumber",0);
	loop{
		while(BGMChecker==GetCommonDataDefault("BGMPLAYNumber",0)){yield;}
		DeleteMusic(BGMSet[BGMChecker%BGMNum]);
		BGMChecker=GetCommonDataDefault("BGMPLAYNumber",0);
		LoadMusic(BGMSet[BGMChecker%BGMNum]);
		PlayMusic(BGMSet[BGMChecker%BGMNum]);
		}
	}
task EndVision{
	let cx=GetCenterX;
	let cy=GetCenterY;
	SetFontColor(255,128,128,255,128,128);
	DrawText("Thank You For Playing This Game",cx,cy,24,255);
	}