task OtherModeItemTask
{
	ScoreItemdraw;
	SectionScoreItemdraw;
	OtherModeBombExtend;
	StageDeleteBulletCheck;
	OtherPlayerExtendSystem;
	BombOverExtend;
loop
{
	MSDScoreItemCount+=GetPoint;
	MSDSectionScoreItemCount+=GetPoint;
	if(PurityRate>1)
	{
	PurityRateCount+=GetPoint/2;
	}
	AddPoint(-GetPoint);
	if(OnBomb)
	{
		if(MSDSectionScoreItemCount>5000)
		{
		MSDSectionScoreItemCount-=trunc(MSDSectionScoreItemCount/5000)+1;
		}
		else if(MSDSectionScoreItemCount>0)
		{
		MSDSectionScoreItemCount-=1;
		}
	}
	if(GetCommonDataDefault("BurstStop",false)==false)
	{//走行点
	AddScore(floor(SpiritRank/1000)*100);
	}
	if(GetCommonDataDefault("TrueBossLastAttack",false)==true && GetCommonDataDefault("BossLife",0)>0)
	{
		if(!OnBomb && GetTimeOfPlayerInvincibility==0 && GetTimeOfSuperNaturalBorder==0)
		{
		SpiritCounter+=1000/600;
		}
	}
yield;
}
}

task BombOverExtend
{
loop
{
	if(GetPlayerBomb>=9)
	{
		AddBomb(-1);

	//	SetPlayerInvincibility(240);
		CreateEnemyFromFile(csd~"SystemEnemy/Invincibility.txt",GetClipMaxX+16,GetCenterY-128,2,90,1);
		BulletErase(180);
		AddScoreSystem;
		AchievementNotice(58);
	}
	task AddScoreSystem
	{
		AddScore(10000000);
	}
yield;
}
}

let PurityRate=0;
let PurityRateCount=0;

task CheckPurityRate
{
let ItemCheck=0;//共通データの配列の長さをチェックする変数
let XY=[];//共通データの書き換えにワンクッション置くための変数
//let ItemPerFrame=60;//１フレームあたりの最大アイテム生成数（処理落ち対策）
loop
{
	ItemCheck=length(GetCommonDataDefault("PurityRateArray",[]));//毎フレーム共通データの長さチェック
	if(ItemCheck>0)
	{//配列に中身がある（アイテム発生フラグ立っている）場合の処理
		loop
		{
			XY=GetCommonDataDefault("PurityRateArray",[]);//共通データ内容を変数に渡す

			PurityRateChange(XY[0]);

			XY=erase(XY, 0);

			if(length(XY)==0)
			{//削除後の配列が空になった場合
				SetCommonData("PurityRateArray",[]);//共通データを空にして
				break;//アイテム生成ループ脱出
			}
			else
			{
				SetCommonData("PurityRateArray",XY);
			}//配列が空でない場合共通データに変更後の配列を渡す
		}
	}
yield;
}
}

task PurityRateChange(Rate)
{
	if(PurityRate<=Rate && Rate>1)
	{
		if(PurityRateCount<30)
		{
		PurityRateCount=30;
		}
		PurityRate=Rate;
	}
}

task PurityRateDifine
{
loop
{
	if(PurityRateCount==0)
	{
		PurityRate=1;
	}
	PurityRateCount-=1;
	if(GetTimeOfSuperNaturalBorder>0)
	{
		PurityRateCount-=(0.5+2.5*SpiritRank/10000)/1.5;
	}
	if(OnBomb)
	{
		PurityRateCount-=1;
		if(GetTimeOfSuperNaturalBorder>0)
		{
			PurityRateCount-=(0.5+2.5*SpiritRank/10000)/1.5;
		}
	}
	if(PurityRateCount<0){PurityRateCount=0;}
	SetCommonData("PURITYRATE",PurityRate);
yield;
}
}



task PRdraw//ボーナスポイント表示のタスク
{
	let bx=GetClipMinX+56-56;
	let by=GetClipMaxY-14;
	let by2=GetClipMinY+52;
	let TempRate=[0,0,0];
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}
let Bnum=[];
loop(3){Bnum=Bnum~[0];}
loop{
if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
	if(by2<GetClipMinY+92-20)
	{
	by2+=0.5;
	}
}
else
{
	if(by2>GetClipMinY+72-20)
	{
	by2-=0.5;
	}
}
let Rate=PurityRate*10;

Bnum[0]=trunc(Rate%10);
Bnum[1]=trunc(Rate%100/10);
Bnum[2]=trunc(Rate%1000/100);

if(Rate>10 && bx>=GetClipMinX)
{
	if(Bnum[2]==1)
	{
		MagicCounternum3(bx-12,by2,Bnum[0],0.6,1);
		MagicCounternum3(bx-28,by2,Bnum[1],0.6,1);
		MagicCounternum3(bx-39,by2,Bnum[2],0.6,1);

		MagicCounternum3(bx-50,by2,13,0.6,1);
		MagicCounternum3(bx-18,by2,10,0.6,1);
	}
	else
	{
		MagicCounternum3(bx-23,by2,Bnum[0],0.6,1);
		MagicCounternum3(bx-39,by2,Bnum[1],0.6,1);

		MagicCounternum3(bx-50,by2,13,0.6,1);
		MagicCounternum3(bx-29,by2,10,0.6,1);
	}
	if(bx<GetClipMinX+56)
	{
	bx+=2;
	}
TempRate[0]=Bnum[0];
TempRate[1]=Bnum[1];
TempRate[2]=Bnum[2];
}
else
{
	if(bx>GetClipMinX)
	{
	if(TempRate[2]==1)
	{
		MagicCounternum3(bx-12,by2,TempRate[0],0.6,2);
		MagicCounternum3(bx-28,by2,TempRate[1],0.6,2);
		MagicCounternum3(bx-39,by2,TempRate[2],0.6,2);

		MagicCounternum3(bx-50,by2,13,0.6,2);
		MagicCounternum3(bx-18,by2,10,0.6,2);
	}
	else
	{
		MagicCounternum3(bx-23,by2,TempRate[0],0.6,2);
		MagicCounternum3(bx-39,by2,TempRate[1],0.6,2);

		MagicCounternum3(bx-50,by2,13,0.6,2);
		MagicCounternum3(bx-29,by2,10,0.6,2);
	}
	bx-=2;
	}
}


		yield;
}
}

task PRCdraw//ボーナスポイント表示のタスク
{
	let bx=GetClipMinX+70+11;
	let by=GetClipMaxY-14;
	let by2=GetClipMinY+8+64-20;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}
let Bnum=[];
loop(4){Bnum=Bnum~[0];}
loop{
if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
	if(by2<GetClipMinY+28+64-20)
	{
	by2+=0.5;
	}
}
else
{
	if(by2>GetClipMinY+8+64-20)
	{
	by2-=0.5;
	}
}
Bnum[0]=trunc(PurityRateCount%10);
Bnum[1]=trunc(PurityRateCount%100/10);
Bnum[2]=trunc(PurityRateCount%1000/100);
Bnum[3]=trunc(PurityRateCount%10000/1000);

//MagicCounternum3(bx,by2,Bnum[0],0.45);


ascent(let i in 0..4)
{
	if(PurityRateCount>=10^i)
	{
		MagicCounternum3(bx-i*9,by2,Bnum[i],0.45,1);
	}
}

		yield;


}
}

task MagicCounternum3(x,y,num,sc,type)
{
		let scx=sc;
		let scy=sc;
		let obj0 = Obj_Create(OBJ_EFFECT);

		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		if(num==13)
		{
			num=12;
			ObjEffect_SetAngle(obj0,0,0,45);
		}
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		let Alpha=255;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		//	MagicCounternum4(x,GetClipMaxY-8-64,255-Alpha,num,sc);
		}
		if(Alpha<50){Alpha=50;}
		ObjEffect_SetVertexColor(obj0,0,Alpha,255,255,255);
		ObjEffect_SetVertexColor(obj0,1,Alpha,255,255,255);
		ObjEffect_SetVertexColor(obj0,2,Alpha,255,255,255);
		ObjEffect_SetVertexColor(obj0,3,Alpha,255,255,255);
		if(PurityRate>=4 && sc==0.6)
		{
		ObjEffect_SetVertexColor(obj0,0,Alpha,255,255,50);
		ObjEffect_SetVertexColor(obj0,1,Alpha,255,255,50);
		ObjEffect_SetVertexColor(obj0,2,Alpha,255,255,50);
		ObjEffect_SetVertexColor(obj0,3,Alpha,255,255,50);
		}
		else if(sc==0.45)
		{
		if(PurityRateCount>=100)
		{
		ObjEffect_SetVertexColor(obj0,0,Alpha,255,255,255);
		ObjEffect_SetVertexColor(obj0,1,Alpha,255,255,255);
		ObjEffect_SetVertexColor(obj0,2,Alpha,255,255,255);
		ObjEffect_SetVertexColor(obj0,3,Alpha,255,255,255);
		}
		else if(PurityRateCount>=50)
		{
		ObjEffect_SetVertexColor(obj0,0,Alpha,255,80,80);
		ObjEffect_SetVertexColor(obj0,1,Alpha,255,80,80);
		ObjEffect_SetVertexColor(obj0,2,Alpha,255,80,80);
		ObjEffect_SetVertexColor(obj0,3,Alpha,255,80,80);
		}
		else if(PurityRateCount>=0)
		{
		ObjEffect_SetVertexColor(obj0,0,Alpha,255,0,0);
		ObjEffect_SetVertexColor(obj0,1,Alpha,255,0,0);
		ObjEffect_SetVertexColor(obj0,2,Alpha,255,0,0);
		ObjEffect_SetVertexColor(obj0,3,Alpha,255,0,0);
		}
		}

		if(type==2)
		{
		ObjEffect_SetVertexColor(obj0,0,Alpha,255,0,0);
		ObjEffect_SetVertexColor(obj0,1,Alpha,255,0,0);
		ObjEffect_SetVertexColor(obj0,2,Alpha,255,0,0);
		ObjEffect_SetVertexColor(obj0,3,Alpha,255,0,0);
		}
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,3);
		wait(1);
		Obj_Delete(obj0);
}


let SpilitInvincibility=false;

task SpiritSystem
{
let miss=0;
loop
{
	if(SpiritCounter>=1000 && GetCommonData("Playermissed")==false)
	{
		if(SpiritRank>=10000)
		{
			AchievementNotice(72);
		}
		SuperNaturalBorder(600);
		let count=0;
		let ShotCount=0;
		loop(600)
		{
			SpiritCounter-=1000/600;
			count+=1;
			ShotCount=GetEnemyShotCount;
			if(GetTimeOfSuperNaturalBorder==0){break;}
			yield;
		}
		if(count==600)
		{
			if(SpiritRank>=10000)
			{
				AddScore(MSDScoreItemCount*100);
			}
			SpiritRank+=1000;
			BombForbidTask;
		}
		else
		{
			BorberBreakCount+=1;
			if(BorberBreakCount>=10){AchievementNotice(73);}
			if(ShotCount>=400){ShotCount=400;}
			SpiritRecharge(ShotCount/2);
		}
		if(SpiritRank>=10000){SpiritRank=10000;}
		SpiritCounter=0;
		CreateEnemyFromFile(csd~"SystemEnemy/SpiritInvincibility.txt",GetClipMaxX+16,GetCenterY-128,2,90,1);
	}

if(OnBomb)
{
SpiritRank-=8;
if(SpiritRank<0){SpiritRank=0;}
}

if(miss<GetMissCount)
{//ミスしたときに一回実行
	miss+=1;
	//SetPlayerInvincibility(180);
	SpiritRank/=2;
}

yield;
}


}

task BombForbidTask
{
	SpilitInvincibility=true;
	ForbidBomb(true);
	wait(30);

	SpilitInvincibility=false;
	ForbidBomb(false);
}

task SpiritRecharge(num)
{
if(num>400){num=400;}
loop(60)
{
SpiritCounter+=num/60;
yield;
}

}

task CheckShotItemPoint
{
let ItemCheck=0;
let XY=[];
let ItemPointCount=0;
loop
{
	ItemCheck=length(GetCommonDataDefault("ItemPointGain",[]));
	if(ItemCheck>0)
	{
		loop
		{
			XY=GetCommonDataDefault("ItemPointGain",[]);
			
			ItemPointCount+=XY[0];
			if(ItemPointCount>=1)
			{
				AddPoint(1);
				AddScore(10000);
				ItemPointCount-=1;
			}

			loop(1)
			{
				XY=erase(XY, 0);
			}
			if(length(XY)==0)
			{
				SetCommonData("ItemPointGain",[]);
				break;
			}
			else
			{
				SetCommonData("ItemPointGain",XY);
			}
		}
	}
yield;
}
}

task CheckSpirit
{
let ItemCheck=0;
let XY=[];
loop
{
	ItemCheck=length(GetCommonDataDefault("SpiritGain",[]));
	if(ItemCheck>0)
	{
		loop
		{
			XY=GetCommonDataDefault("SpiritGain",[]);
			
			if(GetTimeOfSuperNaturalBorder==0)
			{
			SpiritCounter+=XY[0];
			}
			else
			{
				SpiritRank+=XY[0]*3;
			}
			if(SpiritCounter>1000){SpiritCounter=1000;}
			if(SpiritRank>10000){SpiritRank=10000;}
			loop(1)
			{
				XY=erase(XY, 0);
			}
			if(length(XY)==0)
			{
				SetCommonData("SpiritGain",[]);
				break;
			}
			else
			{
				SetCommonData("SpiritGain",XY);
			}
		}
	}
yield;
}
}

task SpiritDraw//Powerを画面右に表示させるエフェクトタスク
{
	//let bx=GetClipMaxX+190;
	let bx=GetClipMinX+55;
	let by=GetClipMinY+415;
	let by2=GetClipMaxY-436;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
SpiritCounter=GetCommonData("PracticeStartBurstCounter");
if(SpiritCounter>10000){SpiritCounter=10000;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}
let DrawCount=600;

loop{
if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
	if(by2<GetClipMaxY-416)
	{
	by2+=0.5;
	}
}
else
{
	if(by2>GetClipMaxY-436)
	{
	by2-=0.5;
	}
}


if(DrawCount>=600)
{
ascent(i in 0..4)
{
Spiritnum2(i);
}
DrawCount=0;
}
DrawCount+=1;

	yield;

}


task Spiritnum2(digit)
{
		let x;
		let Alpha=255;
		let scx=0.8;
		let scy=0.8;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);

		ObjEffect_SetScale(obj0, scx,scy);
		ObjEffect_SetLayer(obj0,3);

		let num;

		loop(600)
		{
		num=trunc(SpiritCounter%(10^(digit+1))/(10^digit));
		x=bx-digit*15;

		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		//	Spiritnum(x,GetClipMinY+416,255-Alpha,num);
		}
		if(Alpha<50){Alpha=50;}
		if(SpiritCounter<10^digit &&digit!=0){Alpha=0;}

				ascent(i in 0..4)
				{
					ObjEffect_SetVertexColor(obj0, i, Alpha, 255, 255, 255);
				}
				if(SpiritCounter>=1000)
				{
				ascent(let i in 0..4)
				{
			//		ObjEffect_SetVertexColor(obj0,i,Alpha,ColorRed,ColorGreen,ColorBlue);
				}
				}

		Obj_SetPosition(obj0,x,by2+5);
		wait(1);
		}
		Obj_Delete(obj0);
}

}

task SpiritRankDraw
{
let RankNum=0;
let RankCounter=0;
let RushAlpha=50;
let RushAlphaC1=180;
let RushAlphaC2=75;
let RushAlphaAngle=0;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
SpiritRank=GetCommonData("PracticeStartBurstRank");
if(SpiritRank>10000){SpiritRank=10000;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None"){return;}
let RX=35;
let RY=55;
let BRnum=[0,0];
loop
{
RankBerDisplay(RX+71,RY);
RankDisplay(RX,RY,RushAlpha);

BRnum[0]=trunc(SpiritRank%10000/1000);
BRnum[1]=trunc(SpiritRank/10000);

Ranknum(RX+86,RY-5,BRnum[0]);

SetCommonData("SpiritRank",SpiritRank);

if(SpiritRank>=10000)
{
	Ranknum(RX+86-1*10,RY-5,BRnum[1]);
}

if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
	if(RY<GetClipMinY+60)
	{
	RY+=0.5;
	}
}
else
{
	if(RY>GetClipMinY+40)
	{
	RY-=0.5;
	}
}
yield;
RushAlpha=RushAlphaC1+RushAlphaC2*cos(RushAlphaAngle);
RushAlphaAngle+=6;
}
}

task Ranknum(x,y,num)
{
		let scx=0.4;
		let scy=0.4;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		let Alpha=255;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}

		let R=255;let G=255;let B=255;

		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,3);
		yield;
		Obj_Delete(obj0);
}



task RankBerDisplay(x,y)//ライフバーの枠の設定
{
	//let BossLifeMax=GetEnemyLife;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -71, -5);
		ObjEffect_SetVertexXY(obj, 1, 0,  -5);
		ObjEffect_SetVertexXY(obj, 2, 0, 5);
		ObjEffect_SetVertexXY(obj, 3,  -71,  5);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  11);
		ObjEffect_SetVertexUV(obj, 1,  148, 11);
		ObjEffect_SetVertexUV(obj, 2, 148,  21);
		ObjEffect_SetVertexUV(obj, 3, 6, 21);
		ObjEffect_SetLayer(obj,3);
		ObjEffect_SetScale(obj, 1,0.6);



		Obj_SetPosition(obj,x,y);

		let Alpha=50;
		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}
			ascent(i in 0..4)
			{
				ObjEffect_SetVertexColor(obj, i, Alpha, 255, 255, 255);
			}

			yield;
		Obj_Delete(obj);
}

task RankDisplay(x,y,Alpha)//ライフバーのバー部分の設定
{
		let scale=2.5;

		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgBer);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, 0, -3);
		ObjEffect_SetVertexXY(obj, 1, 71,  -3);
		ObjEffect_SetVertexXY(obj, 2, 71, 3);
		ObjEffect_SetVertexXY(obj, 3,  0,  3);
		
		ObjEffect_SetVertexUV(obj, 0,  6,  27);
		ObjEffect_SetVertexUV(obj, 1,  148, 27);
		ObjEffect_SetVertexUV(obj, 2, 148,  33);
		ObjEffect_SetVertexUV(obj, 3, 6, 33);
		ObjEffect_SetLayer(obj,3);

		ascent(let i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,150,255,255,255);
		}

		Obj_SetPosition(obj,x,y);

		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha*=255/255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha*=(255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150))/255;
		}

		if(Alpha<50){Alpha=50;}
			let RankCounter=SpiritRank%1000;
			if(SpiritRank>=10000){RankCounter=999;}

			scale=RankCounter/1000;
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj,i,Alpha,255*(SpiritRank/10000),0,255-255*(SpiritRank/10000));
			}
			ObjEffect_SetScale(obj, scale,0.6);
			yield;
		Obj_Delete(obj);
}

task StageCheckShot
{
let ForbitCounter=0;
loop
{
	if(GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD || GetKeyState(VK_USER)==KEY_PUSH || GetKeyState(VK_USER)==KEY_HOLD)
	{
		ForbitCounter=0;
		ForbidShot(false);
	}
	else
	{
		ForbitCounter+=1;
	}
	if(ForbitCounter>=10)
	{
		ForbidShot(true);
	}
yield;
}
}

task BorderOfLifeLimit
{//喰らいボム受付時間を制限する
let BorderCount=0;
loop
{
	if(OnPlayerMissed || GetPlayerLife==0)
	{
		BorderCount+=1;
	}
	else
	{
		BorderCount=0;
	}
	if(BorderCount>20)
	{
		ForbidBomb(true);
		MissedBombCount+=GetPlayerBomb;
		while(OnPlayerMissed || GetPlayerLife==0){yield;}
		if(GetTimeOfPlayerInvincibility<=180)
		{
		CreateEnemyFromFile(csd~"SystemEnemy/Invincibility.txt",GetClipMaxX+16,GetCenterY-128,2,90,1);
		}

		BulletErase(120);
		wait(1);
		AddBomb(-GetPlayerBomb+InitialBomb);
	}
	else if(!SpilitInvincibility)
	{
		ForbidBomb(false);
	}
yield;
}
}

task BulletErase(time)
{
loop(time)
{
DeleteEnemyShot(SHOT);
yield;
}
}

task StageDeleteBulletCheck
{
let Dnum;
let Dx;
let Dy;

loop
{
	if(GetCommonDataDefault("DeleteBulletNum",0)>0)
	{
		Dnum=GetCommonDataDefault("DeleteBulletNum",0);
		Dx=GetCommonDataDefault("DeleteBulletX",0);
		Dy=GetCommonDataDefault("DeleteBulletY",0);
		//if(Dnum>200){Dnum=200;}
		MSDScoreItemCount+=Dnum;
		MSDSectionScoreItemCount+=Dnum;
		if(GetTimeOfSuperNaturalBorder>0)
		{
			SpiritRank+=Dnum*2;
			if(SpiritRank>10000){SpiritRank=10000;}
			DeleteShotNumdraw(Dnum*2,Dx,Dy,1);
		}
		else
		{
			if(GetKeyState(VK_SLOWMOVE)==KEY_FREE)
			{
			SpiritRank+=Dnum;
			if(SpiritRank>10000){SpiritRank=10000;}
			DeleteShotNumdraw(Dnum,Dx,Dy,1);
			}
			else
			{
			SpiritCounter+=Dnum/2;
			if(SpiritCounter>1000){SpiritCounter=1000;}
			DeleteShotNumdraw(Dnum/2,Dx,Dy,2);
			}
		}

		SetCommonData("DeleteBulletNum",0);
	}
yield;
}
}

task DeleteShotNumdraw(Dnum,x,y,type)//ボーナスポイント表示のタスク
{
if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
x=GetPlayerX;
y=GetPlayerY-30;
}
let Bnum=[];
let number=1;
loop(4){Bnum=Bnum~[0];}

Bnum[0]=trunc(Dnum%10);
Bnum[1]=trunc(Dnum%100/10);
Bnum[2]=trunc(Dnum%1000/100);
Bnum[3]=trunc(Dnum%10000/1000);

DeleteBonusnum(x-0*12,y,Bnum[0],type);

ascent(let i in 1..4)
{
	if(Dnum>=10^i)
	{
		DeleteBonusnum(x-i*12,y,Bnum[i],type);
		number=i+1;
	}
}


DeleteBonusnum(x-number*12,y,12,type);

}

task DeleteBonusnum(x,y,num,type)
{
		let Alpha=0;
		let R;let G;let B;
		if(type==1)
		{
			R=255;G=127;B=127;
		}
		if(type==2)
		{
			R=127;G=127;B=255;
		}
		if(type==3)
		{
			R=255;G=255;B=255;
		}
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		ascent(let i in 0..4)
		{	
			ObjEffect_SetVertexColor(obj0,i,Alpha,R,G,B);
		}
		
		ObjEffect_SetScale(obj0, scx,scy);
		Obj_SetPosition(obj0,x,y+5);
		ObjEffect_SetLayer(obj0,8);
		loop(30)
		{
		ascent(let i in 0..4)
		{	
			ObjEffect_SetVertexColor(obj0,i,Alpha,R,G,B);
		}
		Alpha+=8;
		Obj_SetY(obj0,Obj_GetY(obj0)-0.1);
		yield;
		}
		loop(30)
		{
		Obj_SetY(obj0,Obj_GetY(obj0)-0.1);
		yield;
		}
		loop(30)
		{
		ascent(let i in 0..4)
		{	
			ObjEffect_SetVertexColor(obj0,i,Alpha,R,G,B);
		}
		Obj_SetY(obj0,Obj_GetY(obj0)-0.1);
		Alpha-=8;
		yield;
		}
		Obj_Delete(obj0);
}


task ScoreItemdraw//ボーナスポイント表示のタスク
{
	let bx=GetClipMaxX+190;
	let by=270;
	let bx=GetClipMaxX-20;
	let by=GetClipMinY+12;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}

let DrawCount=600;

loop{
if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
	if(by<GetClipMinY+32)
	{
	by+=0.5;
	}
}
else
{
	if(by>GetClipMinY+12)
	{
	by-=0.5;
	}
}

if(DrawCount>=600)
{
ascent(i in 0..6)
{
tBonusnum(i);
}
DrawCount=0;
}
DrawCount+=1;

yield;

}

task tBonusnum(digit)
{
		let x;
		let Alpha=255;
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetScale(obj0, scx,scy);
		ObjEffect_SetLayer(obj0,3);

		let num;

		loop(600)
		{
		num=trunc(MSDScoreItemCount%(10^(digit+1))/(10^digit));
		x=bx-digit*12;

		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}
		if(MSDScoreItemCount<10^digit &&digit!=0){Alpha=0;}

		let R=150;let G=255;let B=150;
		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		Obj_SetPosition(obj0,x,by+5);
		yield;
		}
		Obj_Delete(obj0);
}

}

task SectionScoreItemdraw//ボーナスポイント表示のタスク
{
	let bx=GetClipMaxX+190;
	let by=GetClipMinY+227;
	let bx=GetClipMaxX-20;
	let by=GetClipMinY+36;
wait(5);
while(GetCommonDataDefault("TitleMenu",false)){yield;}
if(GetCommonDataDefault("SELECTEDDIFFICULT","None")=="None")
{return;}

let DrawCount=600;

loop{
if(IsBossExisting || GetCommonDataDefault("IsMSDBossExisting",false))
{
	if(by<GetClipMinY+56)
	{
	by+=0.5;
	}
}
else
{
	if(by>GetClipMinY+36)
	{
	by-=0.5;
	}
}

if(DrawCount>=600)
{
ascent(i in 0..6)
{
tBonusnum(i);
}
DrawCount=0;
}
DrawCount+=1;

yield;


}

task tBonusnum(digit)
{
		let x;
		let Alpha=255;
		let scx=0.6;
		let scy=0.6;
		let obj0 = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj0,imgNumber);
		ObjEffect_SetPrimitiveType(obj0, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj0, ADD); 
		ObjEffect_CreateVertex(obj0, 4);
		ObjEffect_SetVertexXY(obj0, 0, -13, -16);
		ObjEffect_SetVertexXY(obj0, 1, 13,  -16);
		ObjEffect_SetVertexXY(obj0, 2, 13, 16);
		ObjEffect_SetVertexXY(obj0, 3,  -13,  16);
		
		ObjEffect_SetScale(obj0, scx,scy);
		ObjEffect_SetLayer(obj0,3);

		let num;

		loop(600)
		{
		num=trunc(MSDSectionScoreItemCount%(10^(digit+1))/(10^digit));
		x=bx-digit*12;

		ObjEffect_SetVertexUV(obj0, 0,  0+40*num,  6);
		ObjEffect_SetVertexUV(obj0, 1,  26+40*num, 6);
		ObjEffect_SetVertexUV(obj0, 2, 26+40*num,  38);
		ObjEffect_SetVertexUV(obj0, 3, 0+40*num, 38);

		if((GetPlayerY>GetClipMinY+150))
		{
			Alpha=255;
		}
		if((GetPlayerY<GetClipMinY+150))
		{
			Alpha=255+300*(GetPlayerY-(GetClipMinY+150))/(GetClipMinY+150);
		}
		if(Alpha<50){Alpha=50;}
		if(MSDSectionScoreItemCount<10^digit &&digit!=0){Alpha=0;}

		let R=150;let G=150;let B=255;
		ObjEffect_SetVertexColor(obj0,0,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,1,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,2,Alpha,R,G,B);
		ObjEffect_SetVertexColor(obj0,3,Alpha,R,G,B);
		
		Obj_SetPosition(obj0,x,by+5);
		yield;
		}
		Obj_Delete(obj0);
}

}

task OtherPlayerExtendSystem//エクステンドの設定
{
	while(ScoreNumber2<50 || MSDClear){yield;}
	if(StageProgress==1)
	{
		AchievementNotice(56);
	}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<150 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<300 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<500 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
	while(ScoreNumber2<750 || MSDClear){yield;}
	if(GetPlayerLife==1 && GetPlayerBomb==0)
	{
		AchievementNotice(81);
	}
	Ah_DoubleExtendCheck;
	ExtendNum+=1;
	ExtendPlayer(1);
	PlaySE("se\se1UP.wav");
}

task OtherModeBombExtend//ボムエクステンド
{
	let BombExtendNum=0;
	let BombExtendCounter=0;
	let Necessary=5000;
	loop
	{
		BombExtendCounter=MSDScoreItemCount-(Necessary*BombExtendNum);
		if(BombExtendCounter>=Necessary)
		{
			BombExtendCounter-=Necessary;
			BombExtendNum+=1;
			BombExtendTask;
		}
		yield;
	}

	task BombExtendTask
	{
		if(OnPlayerMissed)
		{
		while(OnPlayerMissed){yield;}
		wait(15);
		}
		
		PlaySE(SE[4]);
		AddBomb(1);
		Ah_DoubleExtendCheck;
	}
}