sub StageAllClearAchievementCheck
{//計14
				if(GetCommonDataDefault("MSDPlayer",false)==true)
				{
					if(GetCommonDataDefault("PLAYERTYPE","A")=="A")
					{
						AchievementNotice(0);
					}
					else if(GetCommonDataDefault("PLAYERTYPE","A")=="B")
					{
						AchievementNotice(1);
					}
					if(GetCommonDataDefault("PLAYERTYPE","A")=="C")
					{
						AchievementNotice(2);
					}
					if(GetCommonDataEx(NsScore,NsAchievement[0]))
					{
					if(GetCommonDataEx(NsScore,NsAchievement[1]))
					{
					if(GetCommonDataEx(NsScore,NsAchievement[2]))
					{
					
						AchievementNotice(54);
					}
					}
					}
				}
				else
				{
						AchievementNotice(3);
				}
				alternative(SelectedDifficult)
				case("Moderate")
				{
					AchievementNotice(4);
					if(Continued==false)
					{
						AchievementNotice(5);
					}
				}
				case("Extream")
				{
					AchievementNotice(6);
					if(Continued==false)
					{
						AchievementNotice(7);
					}
				}
				
				case("Apocalypse")
				{
					AchievementNotice(8);
					if(GetCommonDataDefault("TrueBossFlag",false))
					{
					if(Continued==false)
					{
						AchievementNotice(9);
					}
					}
				}

				if(GetMissCount==0)
				{
					if(Continued==false)
					{
					AchievementNotice(51);
					}
				}
				if(GetBombCount==0)
				{
					if(Continued==false)
					{
					AchievementNotice(52);
					}
				}
				if(GetCommonDataDefault("AutoBombMode",0)==0)
				{
					if(Continued==false)
					{
					AchievementNotice(53);
					}
				}
				if(GetPlayerLife==1 && GetPlayerBomb==0)
				{
					if(Continued==false)
					{
					AchievementNotice(82);
					}
				}
}

task ScoreAchievementCheck(num,A_num)
{
if(GetCommonDataEx(NsScore,NsAchievement[A_num])){return;}
loop
{
	if(ScoreNumber2>=100000*num)
	{
		AchievementNotice(A_num);
		break;
	}
	yield;
}
}

task FreeScoreAchievementCheck(num,A_num)
{
if(GetCommonDataEx(NsScore,NsAchievement[A_num])){return;}
loop
{
	if(ScoreNumber2>=100*num)
	{
		AchievementNotice(A_num);
		break;
	}
	yield;
}
}

task AchievementOnProgress
{
if(GetCommonDataDefault("MSDPlayer",false)==false)
{
Ah_SectionMagicFragmentCheck1;		//ステージフラグメント２種
Ah_SectionMagicFragmentCheck2;
Ah_SectionMagicFragmentCheck3;
Ah_MagicFragmentCheck1;			//ステージ累計フラグメント４種
Ah_MagicFragmentCheck2;
Ah_MagicFragmentCheck3;	
Ah_RankCheck;
Ah_RankContenueCheck;
}
Ah_DontAfraid;
Ah_ThreeCoin;
Ah_BitDefeat;
Ah_EndStart;
Ah_AwakeCheck;
Ah_BitZoneCheck;
Ah_TrueBossCheck;
Ah_MissCheck;
StandbyModeCheck;
}

task Ah_SectionMagicFragmentCheck1
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[22],0)==1){return;}

loop
{
if(MSDSectionScoreItemCount>=10000)
{
	AchievementNotice(22);
	break;
}
yield;
}
}

task Ah_SectionMagicFragmentCheck2
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[23],0)==1){return;}
loop
{
if(MSDSectionScoreItemCount>=20000)
{
	AchievementNotice(23);
	break;
}
yield;
}
}
task Ah_SectionMagicFragmentCheck3
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[24],0)==1){return;}

loop
{
if(MSDSectionScoreItemCount>=40000)
{
	AchievementNotice(24);
	break;
}
yield;
}
}

task Ah_MagicFragmentCheck1
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[25],0)==1){return;}
loop
{
if(MSDScoreItemCount>=30000)
{
	AchievementNotice(25);
	break;
}
yield;
}
}

task Ah_MagicFragmentCheck2
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[26],0)==1){return;}
loop
{
if(MSDScoreItemCount>=50000)
{
	AchievementNotice(26);
	break;
}
yield;
}
}

task Ah_MagicFragmentCheck3
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[27],0)==1){return;}
loop
{
if(MSDScoreItemCount>=100000)
{
	AchievementNotice(27);
	break;
}
yield;
}
}

task Ah_RankCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[60],0)==1){return;}
loop
{
	if(SpiritRank>=10000)
	{
		AchievementNotice(60);
		break;
	}
yield;
}
}

task Ah_RankContenueCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[61],0)==1){return;}
let ConCount=0;
loop
{
if(SpiritRank>=9000)
{
	 ConCount+=1;
}
else
{
	 ConCount=0;
}
if(ConCount>=5400)
{
	AchievementNotice(61);
	break;
}

yield;
}
}

task Ah_DontAfraid
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[62],0)==1){return;}
loop
{
	if(GetPlayerLife==9 && GetPlayerBomb==8)
	{
		AchievementNotice(62);
		break;
	}
yield;
}
}

task Ah_ThreeCoin
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[64],0)==1){return;}
loop
{
	if(InitialContinue-GetAllowedContinueCount>=3)
	{
		AchievementNotice(64);
		break;
	}
yield;
}
}

task Ah_BitDefeat
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[88],0)==1){return;}
loop
{
	if(StageProgress==5 && GetCommonDataDefault("BitDefeatNum",0)==6)
	{
		AchievementNotice(88);
		break;
	}
yield;
}
}

task Ah_EndStart
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[90],0)==1){return;}
loop
{
	if(StageProgress==1 && GetPlayerLife==0 && GetCommonDataDefault("SELECTEDDIFFICULT","None")=="Apocalypse")
	{
		AchievementNotice(90);
		break;
	}
yield;
}
}

task Ah_AwakeCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[80],0)==1){return;}
let AwakeCount=0;
loop
{
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AwakeCount+=1;
		if(AwakeCount>=3600)
		{
			AchievementNotice(80);
			break;
		}
	}
	else
	{
		AwakeCount=0;
	}
yield;
}
}

task Ah_BitZoneCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[94],0)==1){return;}
loop
{
if(GetCommonDataDefault("BitZone",false) && GetPlayerLife==0)
{
	AchievementNotice(94);
	break;
}

yield;
}
}

task Ah_TrueBossCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[95],0)==1){return;}
loop
{
if(GetCommonDataDefault("TrueBossFlag",false) && GetPlayerLife==0)
{
	AchievementNotice(95);
	break;
}

yield;
}
}


task Ah_MissCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[97],0)==1){return;}
let miss=0;
let missFlag=false;
loop
{
if(miss<GetMissCount)
{//ミスしたときに一回実行
	miss+=1;
	MissCountCheck;
}

yield;
}
task MissCountCheck
{
	if(missFlag==false)
	{
		missFlag=true;
	}
	else
	{
		AchievementNotice(97);
	}
	loop(360)
	{
	
		yield;
	}
	missFlag=false;
}

}


task StandbyModeCheck
{
let KeyArray=[VK_UP,VK_DOWN,VK_LEFT,VK_RIGHT,VK_BOMB,VK_SHOT,VK_SKIP,VK_SLOWMOVE,VK_USER];
if(GetCommonDataDefaultEx(NsScore,NsAchievement[98],0)==1){return;}
let FreeCount=0;
loop
{
	if(FreeCheck)
	{
		FreeCount+=1;
		if(FreeCount>=600)
		{
			AchievementNotice(98);
			break;
		}
	}
	else
	{
		FreeCount=0;
	}
yield;
}

function FreeCheck
{
let num=0;
ascent(i in 0..9)
{
if(GetKeyState(KeyArray[i])==KEY_FREE)
{
num+=1;
}
}
if(num==9){return(true);}
else{return(false);}
}

}

sub InitializeAchievementCheck
{//計１５
	let Sum_Ah=0;
	ascent(i in 0..100)
	{
		Sum_Ah+=GetCommonDataEx(NsScore,NsAchievement[i]);
	}
	if(Sum_Ah>=5)
	{
		InitialContinue+=1;
	}
	if(Sum_Ah>=10)
	{
		InitialContinue+=1;
	}
	if(Sum_Ah>=15)
	{
		InitialContinue+=1;
	}
	if(Sum_Ah>=20)
	{
		InitialContinue+=1;
	}
	if(Sum_Ah>=25)
	{
		InitialContinue+=1;
	}

	if(Sum_Ah>=25)
	{
		InitialLifeMax+=1;
	}
	if(Sum_Ah>=15)
	{
		InitialBombMax+=1;
	}

	if(Sum_Ah>=50)
	{
		InitialLifeMax+=1;
	}
	if(Sum_Ah>=30)
	{
		InitialBombMax+=1;
	}

	ExpertEx(false,InitialContinue,InitialLife);
}

sub StageInitializeAchievementCheck
{//計１５
	if(GetCommonDataDefaultEx(NsScore,NsAllScore3,0)>=10)
	{
		AchievementNotice(18);
	}
	if(GetCommonDataDefaultEx(NsScore,NsAllScore3,0)>=50)
	{
		AchievementNotice(19);
	}

	if(GetCommonDataDefaultEx(NsScore,NsAllFragment2,0)>=1)
	{
		AchievementNotice(28);
	}
	if(GetCommonDataDefaultEx(NsScore,NsAllFragment2,0)>=5)
	{
		AchievementNotice(29);
	}

	if(GetCommonDataDefaultEx(NsScore,NsContinueCount,0)>=30)
	{
		AchievementNotice(63);
	}

	if(GetCommonDataDefaultEx(NsScore,"NsAllDeadNum",0)>=100)
	{
		AchievementNotice(65);
	}

	if(GetCommonDataDefaultEx(NsScore,"BurstModeErazeBulletNumAM",0)>=10000)
	{
		AchievementNotice(67);
	}

	if(GetCommonDataDefaultEx(NsScore,"UseAutoBombCount",0)>=100)
	{
		AchievementNotice(74);
	}

	if(GetCommonDataDefaultEx(NsScore,"LOWSPIRALNUM",0)>=15)
	{
		AchievementNotice(76);
	}

	if(GetCommonDataDefaultEx(NsScore,"LOWSPIRALNUM",0)>=30)
	{
		AchievementNotice(77);
	}
}

sub StageFinalizeAchievementCheck
{

}


task Ah_DoubleExtendCheck
{
if(GetCommonDataDefault("DoubleExtend",false)==true)
{
	AchievementNotice(85);
}
else
{
SetCommonData("DoubleExtend",true);
wait(60);
SetCommonData("DoubleExtend",false);
}
}


sub TotalPlayCalculation
{
			let RAE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAEasy,0);
			let RBE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBEasy,0);
			let RCE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCEasy,0);
			let RDE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDEasy,0);
			let REE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuEEasy,0);
			let TE=RAE+RBE+RCE+RDE+REE;

			let RAN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuANormal,0);
			let RBN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBNormal,0);
			let RCN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCNormal,0);
			let RDN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDNormal,0);
			let REN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuENormal,0);
			let TN=RAN+RBN+RCN+RDN+REN;

			let RAH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAHard,0);
			let RBH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBHard,0);
			let RCH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCHard,0);
			let RDH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDHard,0);
			let REH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuEHard,0);
			let TH=RAH+RBH+RCH+RDH+REH;

			let RAL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuALuna,0);
			let RBL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBLuna,0);
			let RCL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCLuna,0);
			let RDL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDLuna,0);
			let REL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuELuna,0);
			let TL=RAL+RBL+RCL+RDL+REL;

			let TRA=RAE+RAN+RAH+RAL;
			let TRB=RBE+RBN+RBH+RBL;
			let TRC=RCE+RCN+RCH+RCL;
			let TRD=RDE+RDN+RDH+RDL;
			let TRE=REE+REN+REH+REL;		
			let TOTAL=TE+TN+TH+TL;

			TotalDisplay(355,180,255,255,255,255);

			if(RAE>9999){RAE=9999;}//9999でカンスト
			if(RBE>9999){RBE=9999;}
			if(RCE>9999){RCE=9999;}
			if(RDE>9999){RDE=9999;}
			if(REE>9999){REE=9999;}
			if(TE>9999){TE=9999;}
			if(RAN>9999){RAN=9999;}
			if(RBN>9999){RBN=9999;}
			if(RCN>9999){RCE=9999;}
			if(RDN>9999){RDE=9999;}
			if(REN>9999){REE=9999;}
			if(TN>9999){TN=9999;}
			if(RAH>9999){RAH=9999;}
			if(RBH>9999){RBH=9999;}
			if(RCH>9999){RCE=9999;}
			if(RDH>9999){RDE=9999;}
			if(REH>9999){REE=9999;}
			if(TH>9999){TH=9999;}
			if(RAL>9999){RAL=9999;}
			if(RBL>9999){RBL=9999;}
			if(RCL>9999){RCL=9999;}
			if(RDL>9999){RDL=9999;}
			if(REL>9999){REL=9999;}
			if(TL>9999){TL=9999;}
			if(TRA>9999){TRA=9999;}
			if(TRB>9999){TRB=9999;}
			if(TRC>9999){TRC=9999;}
			if(TRD>9999){TRD=9999;}
			if(TRE>9999){TRE=9999;}

			if(TOTAL>9999){TOTAL=9999;}
}

sub StageTotalPlayCalculation
{
			let RAE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAEasy,0);
			let RBE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBEasy,0);
			let RCE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCEasy,0);
			let RDE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDEasy,0);
			let REE=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuEEasy,0);
			let TE=RAE+RBE+RCE+RDE+REE;

			let RAN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuANormal,0);
			let RBN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBNormal,0);
			let RCN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCNormal,0);
			let RDN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDNormal,0);
			let REN=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuENormal,0);
			let TN=RAN+RBN+RCN+RDN+REN;

			let RAH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuAHard,0);
			let RBH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBHard,0);
			let RCH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCHard,0);
			let RDH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDHard,0);
			let REH=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuEHard,0);
			let TH=RAH+RBH+RCH+RDH+REH;

			let RAL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuALuna,0);
			let RBL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuBLuna,0);
			let RCL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuCLuna,0);
			let RDL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuDLuna,0);
			let REL=GetCommonDataDefaultEx(NsScore,NsFrequencyReimuELuna,0);
			let TL=RAL+RBL+RCL+RDL+REL;

			let TRA=RAE+RAN+RAH+RAL;
			let TRB=RBE+RBN+RBH+RBL;
			let TRC=RCE+RCN+RCH+RCL;
			let TRD=RDE+RDN+RDH+RDL;
			let TRE=REE+REN+REH+REL;		
			let TOTAL=TE+TN+TH+TL;

			TotalDisplay(355,180,255,255,255,255);

			if(RAE>9999){RAE=9999;}//9999でカンスト
			if(RBE>9999){RBE=9999;}
			if(RCE>9999){RCE=9999;}
			if(RDE>9999){RDE=9999;}
			if(REE>9999){REE=9999;}
			if(TE>9999){TE=9999;}
			if(RAN>9999){RAN=9999;}
			if(RBN>9999){RBN=9999;}
			if(RCN>9999){RCE=9999;}
			if(RDN>9999){RDE=9999;}
			if(REN>9999){REE=9999;}
			if(TN>9999){TN=9999;}
			if(RAH>9999){RAH=9999;}
			if(RBH>9999){RBH=9999;}
			if(RCH>9999){RCE=9999;}
			if(RDH>9999){RDE=9999;}
			if(REH>9999){REE=9999;}
			if(TH>9999){TH=9999;}
			if(RAL>9999){RAL=9999;}
			if(RBL>9999){RBL=9999;}
			if(RCL>9999){RCL=9999;}
			if(RDL>9999){RDL=9999;}
			if(REL>9999){REL=9999;}
			if(TL>9999){TL=9999;}
			if(TRA>9999){TRA=9999;}
			if(TRB>9999){TRB=9999;}
			if(TRC>9999){TRC=9999;}
			if(TRD>9999){TRD=9999;}
			if(TRE>9999){TRE=9999;}

			if(TOTAL>9999){TOTAL=9999;}
	let Acount=0;
	if(TOTAL>=50)
	{
		AchievementNotice(30);
		Acount+=1;
	}
	if(TOTAL>=100)
	{
		AchievementNotice(31);
	}
	if(TOTAL>=500)
	{
		AchievementNotice(32);

	}
	if(TOTAL>=1000)
	{
		AchievementNotice(33);
		Acount+=1;
	}
	if(PlayTime/3600>=1)
	{
		AchievementNotice(34);
		Acount+=1;
	}
	if(PlayTime/3600>=3)
	{
		AchievementNotice(35);
	}
	if(PlayTime/3600>=5)
	{
		AchievementNotice(36);
	}
	if(PlayTime/3600>=10)
	{
		AchievementNotice(37);
		Acount+=1;
	}
	if(Acount>=2)
	{
		AchievementNotice(38);
	}
	if(Acount>=4)
	{
		AchievementNotice(39);
	}
}