task CheckAchievement
{//計２６
Ah_LimitCheck1;
Ah_LimitCheck2;
Ah_SectionMagicFragmentCheck1;		//ステージフラグメント２種
Ah_SectionMagicFragmentCheck2;
Ah_SectionMagicFragmentCheck3;
Ah_MagicFragmentCheck1;			//ステージ累計フラグメント４種
Ah_MagicFragmentCheck2;
Ah_MagicFragmentCheck3;		
Ah_PowerCheck;				//魔力節約
Ah_RankCheck;				//ランク１０
Ah_RankContenueCheck;				//ランク１０
Ah_MSCheck;				//マスタースパーク
Ah_CancelBonbCheck;			//キャンセルボム
Ah_BurstCheck;				//バースト回数
Ah_RushBurstCheck;			//ラッシュバースト回数
Ah_AutoBombCheck;			//オートボム回数
Ah_KakaeCheck;				//抱え神
}

function AchievementSet(type)//アイテム生成関数
{
	let XY=GetCommonDataDefault("PLAYERACHIEVEMENT",[]);//共通データ内容を変数に渡す
	XY=XY~[type];//
	SetCommonData("PLAYERACHIEVEMENT",XY);//共通データに変更後の配列を渡す
}

sub Ah_Sub_OverExtendCheck
{
	AchievementSet(58);
}

sub Ah_Sub_EscapeDeathCheck
{
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementSet(81);
	}
}

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

loop
{
if(MagicCounterLimit>=400000)
{
	AchievementSet(20);
	break;
}
yield;
}
}

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

loop
{
if(MagicCounterLimit>=800000)
{
	AchievementSet(21);
	break;
}
yield;
}
}

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

loop
{
if(SectionMagicFragment>=10000)
{
	AchievementSet(22);
	break;
}
yield;
}
}

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

loop
{
if(SectionMagicFragment>=40000)
{
	AchievementSet(24);
	break;
}
yield;
}
}

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

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

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

task Ah_PowerCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[79],0)==1){return;}
let PowerCount=0;
loop
{
	if(Power>=1000)
	{
		PowerCount+=1;
		if(PowerCount>=10800)
		{
			AchievementSet(79);
			break;
		}
	}
	else
	{
		PowerCount=0;
	}
yield;
}
}

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

yield;
}
}

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

yield;
}
}

task Ah_MSCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[68],0)==1){return;}
loop
{
if(UseMasterSparkCount>=10)
{
	AchievementSet(68);
	break;
}

yield;
}
}

task Ah_CancelBonbCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[69],0)==1){return;}
loop
{
if(UseCancelBombCount>=10)
{
	AchievementSet(69);
	break;
}

yield;
}
}


task Ah_BurstCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[70],0)==1){return;}
loop
{
if(UseBurstCount>=30)
{
	AchievementSet(70);
	break;
}

yield;
}
}


task Ah_RushBurstCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[71],0)==1){return;}
loop
{
if(UseRushBurstCount>=10)
{
	AchievementSet(71);
	break;
}

yield;
}
}

task Ah_AutoBombCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[75],0)==1){return;}
loop
{
if(UseAutoBombCount>=10)
{
	AchievementSet(75);
	break;
}

yield;
}
}

task Ah_RechargeCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[84],0)==1){return;}
yield;
loop(60)
{
	if(Power>=1000)
	{
		AchievementSet(84);
		break;
	}
	yield;
}
}

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

task Ah_KakaeCheck
{
if(GetCommonDataDefaultEx(NsScore,NsAchievement[96],0)==1){return;}
loop
{
if(KakaeBombNum>=20 && GetBombCount!=0)
{
	AchievementSet(96);
	break;
}

yield;
}
}

