#東方弾幕風[Player]	//自機スクリプトであることを示します
#ScriptVersion[2]	//スクリプトバージョン2が必須です
#Menu[三月精]		//自機選択画面で表示されるメニューです
#Text[Ver.1.05
攻撃威力：★★★☆☆〜★★★★★
攻撃範囲：★★☆☆☆〜★★★★★
高速密度：★★★★☆
低速密度：★☆☆☆☆
特殊能力：バトンタッチ
＊ユーザーキーでキャラ交代。
特殊能力：オーバードライブ
＊ゲージが溜まると能力が上昇。
]	//自機選択画面で表示されるテキストです
#Image[.\img\image_Sangatusei.png]
#ReplayName[Sagatsu]	//リプレイ選択時に表示される文字です。8文字以内です。

script_player_main
{
	let current=GetCurrentScriptDirectory();//カレントディレクトリを取得
	let imgSangatusei=current~"img\Sangatusei.png";
	let CutSangatusei1=current~"img\Cutin_Sangatusei.png";
	let CutSangatusei2=current~"img\cutin_sunny.png";
	let CutSangatusei3=current~"img\cutin_luna.png";
	let CutSangatusei4=current~"img\cutin_star.png";
	let shotCount=-1;//弾を連続で発射するための変数
	let bNextShot=false;//ちょん押しでも自弾を連続発射するための変数(説明しづらい)
	let SubShot=false;
	let angle=270;
	let Type=1;
	let Cstop=false;
	let Anime=0;
	let SNSP=0;
	let LUSP=0;
	let STSP=0;
	let SNSP2=0;
	let LUSP2=0;
	let STSP2=0;
	let Gcount=0;
	let GcountA=0;
	let GcountB=0;
	let GcountC=0;
	let FlagA=false;
	let FlagB=false;
	let FlagC=false;
	let FlagD=false;
	let FOD=current~"se\FOD.wav";
	let imgAngle=0;
	let imgAlpha=0;
	let imgSize=0;
	let imgR=0;
	let imgG=0;
	let imgB=0;

	let LockID=-1;
	let minID;
	let maxID;

	let Checker=[];
	ascent(i in 0..257)
	{
		Checker=Checker~[Obj_Create(OBJ_LASER)];
		Obj_Delete(Checker[i]);
	}

	@Initialize
	{	
		//自機の初期化時に一回だけ呼び出される部分です
		LoadGraphic(imgSangatusei);
		SetSpeed(4,1.5);//移動速度を設定
		SetRibirthFrame(7);
		SetInitialBombCount(3);
		LoadPlayerShotData(current~"SangatuseiShotData.txt");
		SetItemCollectLine(125);//アイテム回収ラインを設定
		SetCommonData("HYPER",angle);
	}
	
	@MainLoop
	{
		if(FlagA==true&&FlagB==true&&FlagC==true&&FlagD==false){
			OVER(1);
			OVER(2);
			OVER(3);
			FlagD=true;
		} else if(FlagD==true){
			CollectItems;
			imgAngle+=4;
			if(imgAngle>=360){imgAngle=0;}
			imgAlpha+=2;
			if(imgAlpha>=100){imgAlpha=100;}
			imgSize+=0.2;
			if(imgSize>=1){imgSize=1;}
		} else if(FlagA==false||FlagB==false||FlagC==false){
			imgAngle=0;
			imgSize=0;
			imgAlpha=0;
			FlagD=false;}
		if(Type==1)
		{
			imgR=255;
			imgG=150;
			imgB=50;
		if(SNSP<100&&FlagA==false)
		{
			SNSP=GetGraze-Gcount;
		if(SNSP>=50&&SNSP<100){SNSP2=1;} else if(SNSP<50){SNSP2=0;}
		} else if(SNSP>99.9&&FlagA==false)
		{
			SNSP2=2;
			FlagA=true;
			PlaySE(FOD);
		}
		}
		else if(Type==2)
		{
			imgR=255;
			imgG=255;
			imgB=50;
		if(LUSP<100&&FlagB==false)
		{
			LUSP=GetGraze-Gcount;
		if(LUSP>=50&&LUSP<100){LUSP2=1;} else if(LUSP<50){LUSP2=0;}
		} else if(LUSP>99.9&&FlagB==false)
		{
			LUSP2=2;
			FlagB=true;
			PlaySE(FOD);
		}
		}
		else
		{
			imgR=50;
			imgG=50;
			imgB=255;
		if(STSP<100&&FlagC==false)
		{
			STSP=GetGraze-Gcount;
		if(STSP>=50&&LUSP<100){STSP2=1;} else if(STSP<50){STSP2=0;}
		} else if(STSP>99.9&&FlagC==false)
		{
			STSP2=2;
			FlagC=true;
			PlaySE(FOD);
		}
		}

	ascent(enemy in EnumEnemyBegin..EnumEnemyEnd)
	{
		let LockID=EnumEnemyGetID(enemy);
		let enemyX=GetEnemyInfo(LockID,ENEMY_X);
		let enemyY=GetEnemyInfo(LockID,ENEMY_Y);
	}
		SetPlayerLifeImage(imgSangatusei,Type*119+4,0,Type*119+34,37);//残機数の画像
	if(!OnBomb){
		if((GetKeyState(VK_SHOT)==KEY_PUSH||GetKeyState(VK_SHOT)==KEY_HOLD||bNextShot==true)&&shotCount==-1)
		{
			shotCount=0;
			bNextShot=false;
		}
		if(GetKeyState(VK_SHOT)==KEY_HOLD&&shotCount>0)
		{
			bNextShot=true;
		}

	if(!OnMissed&&!OnEvent){
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH||GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{	//低速移動時の自弾
			if(shotCount%4==0)
			{
				PlaySE("sePlayerShot01.wav");
				if(Type==1)
				{
				MainShot(268,11,-15,9,10,6);
				MainShot(270,11,0,9,10,6);
				MainShot(272,11,15,9,10,6);
				}
				else if(Type==2)
				{
				MainShot(270,31,-15,9,12,4+SNSP2);
				MainShot(270,31,0,9,15,4+SNSP2);
				MainShot(270,31,15,9,12,4+SNSP2);
				}
				else
				{
				MainShot(265,21,-1,9,10,4+SNSP2);
				MainShot(270,21,0,9,10,4+SNSP2);
				MainShot(275,21,1,9,10,4+SNSP2);
				}
			}

			if(Type==1)
			{
				if(shotCount%40==0)
				{
				ShotSn(STSP2);
				}
				if(shotCount%40==11&&LUSP2>0)
				{
				ShotSn(STSP2);
				}
				if(shotCount%40==22&&LUSP2>1)
				{
				ShotSn(STSP2);
				}
			}
			if(shotCount%8==0)
			{
				if(Type==2)
				{
				ShotLu(1+SNSP2,STSP2);
				ShotLu(1+SNSP2,STSP2);
				}
				else if(Type==0)
				{
				SubShot=!SubShot;
				if(SubShot)
				{
					ShotSt(9,1+SNSP2,60);
					ShotSt(-9,1+SNSP2,120);
					if(LUSP2>0){ShotSt(9,1+SNSP2,300);
					ShotSt(-9,1+SNSP2,240);}
					if(LUSP2>1){ShotSt(9,1+SNSP2,0);
					ShotSt(-9,1+SNSP2,180);}
				}
				}
			}
		}
		else
		{	//高速移動自の自弾発射
			if(shotCount%4==0)
			{
				PlaySE("sePlayerShot01.wav");
				if(Type==1)
				{
				MainShot(268,11,-15,9,10,6);
				MainShot(270,11,0,9,10,6);
				MainShot(272,11,15,9,10,6);
				}
				else if(Type==2)
				{
				MainShot(270,31,-15,9,10,4+SNSP2);
				MainShot(270,31,0,9,13,4+SNSP2);
				MainShot(270,31,15,9,10,4+SNSP2);
				}
				else
				{
				MainShot(265,21,-1,9,10,4+SNSP2);
				MainShot(270,21,0,9,10,4+SNSP2);
				MainShot(275,21,1,9,10,4+SNSP2);
				}
			}

			if(Type==1)
			{
				if(shotCount%40==0)
				{
				ShotSn(STSP2);
				}
				if(shotCount%40==11&&LUSP2>0)
				{
				ShotSn(STSP2);
				}
				if(shotCount%40==22&&LUSP2>1)
				{
				ShotSn(STSP2);
				}
			}
			if(shotCount%8==0)
			{
				if(Type==2)
				{
				ShotLu(1+SNSP2,STSP2);
				ShotLu(1+SNSP2,STSP2);
				}
				else if(Type==0)
				{
				SubShot=!SubShot;
				if(SubShot)
				{
					ShotSt(-9,1+SNSP2,240);
					ShotSt(9,1+SNSP2,300);
					if(LUSP2>0){ShotSt(9,1+SNSP2,60);
					ShotSt(-9,1+SNSP2,120);}
					if(LUSP2>1){ShotSt(9,1+SNSP2,0);
					ShotSt(-9,1+SNSP2,180);}
					}
				}
			}
		}
	angle=270;

		if(GetKeyState(VK_USER)==KEY_PUSH&&Cstop==false){
			Cstop=true;
			cheng;
		}
	}

		if(shotCount>=0)
		{
			shotCount++;
		}
		if(shotCount==40)
		{
			shotCount=-1;
		}
		} else {shotCount=-1;}

	if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH||GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{
			if(GetKeyState(VK_LEFT)==KEY_PUSH||GetKeyState(VK_LEFT)==KEY_HOLD){angle=angle-0.2;
			SetCommonData("HYPER",angle);}
			else if(GetKeyState(VK_RIGHT)==KEY_PUSH||GetKeyState(VK_RIGHT)==KEY_HOLD){angle=angle+0.2;
			SetCommonData("HYPER",angle);}
			if(GetKeyState(VK_UP)==KEY_PUSH||GetKeyState(VK_UP)==KEY_HOLD){angle=angle-0.2;
			SetCommonData("HYPER",angle);}
			else if(GetKeyState(VK_DOWN)==KEY_PUSH||GetKeyState(VK_DOWN)==KEY_HOLD){angle=angle+0.2;
			SetCommonData("HYPER",angle);}
		}
		else
		{
			if(GetKeyState(VK_LEFT)==KEY_PUSH||GetKeyState(VK_LEFT)==KEY_HOLD){angle=angle-1;
			SetCommonData("HYPER",angle);}
			else if(GetKeyState(VK_RIGHT)==KEY_PUSH||GetKeyState(VK_RIGHT)==KEY_HOLD){angle=angle+1;
			SetCommonData("HYPER",angle);}
			if(GetKeyState(VK_UP)==KEY_PUSH||GetKeyState(VK_UP)==KEY_HOLD){angle=angle-1;
			SetCommonData("HYPER",angle);}
			else if(GetKeyState(VK_DOWN)==KEY_PUSH||GetKeyState(VK_DOWN)==KEY_HOLD){angle=angle+1;
			SetCommonData("HYPER",angle);}
		}
		SetIntersectionCircle(GetPlayerX,GetPlayerY,1.5);//当たり判定登録
		Specialty;
		minID=EnumEnemyBegin;
		maxID=EnumEnemyEnd;
		yield;
	}

task cheng{
	PlaySE("seSuperNaturalBorder2.wav");
	loop(5){Anime=Anime+0.2;
		yield;}
	Type++;
	Gcount=GetGraze;
		if(Type>2){Type=0;}
	loop(5){Anime=Anime-0.2;
		yield;}
	Cstop=false;
	SetCommonData("ShotP",0);
}

    task OVER(AP){
		let obj=Obj_Create(OBJ_EFFECT);
		let big1=0;
		let big2=0;
		let csd=GetCurrentScriptDirectory;
		let imgSangatusei=current~"img\Sangatusei.png";

		ObjEffect_SetLayer(obj,3);
		ObjEffect_SetTexture(obj,imgSangatusei);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetRenderState(obj,ALPHA);
		Obj_SetPosition(obj,GetCenterX,GetCenterY-100);

		ObjEffect_SetVertexXY(obj,0,-144,-19);
		ObjEffect_SetVertexXY(obj,1,-144,19);
		ObjEffect_SetVertexXY(obj,2,144,-19);
		ObjEffect_SetVertexXY(obj,3,144,19);

		ObjEffect_SetVertexUV(obj,0,0,104);
		ObjEffect_SetVertexUV(obj,1,0,141);
		ObjEffect_SetVertexUV(obj,2,283,104);
		ObjEffect_SetVertexUV(obj,3,283,141);

		PlaySE("seSuperNaturalBorder1.wav");
        loop(25){
		big1++;
		ObjEffect_SetScale(obj,big1*0.04,2-big1*0.04);
		ObjEffect_SetVertexColor(obj,0,200,255,255,255);
		ObjEffect_SetVertexColor(obj,1,200,255,255,255);
		ObjEffect_SetVertexColor(obj,2,200,255,255,255);
		ObjEffect_SetVertexColor(obj,3,200,255,255,255);
		yield;
		}
        loop(25){yield;}
        loop(50){
		big2++;
		ObjEffect_SetScale(obj,1+0.004*AP*big2,1+0.004*AP*big2);
		ObjEffect_SetVertexColor(obj,0,200-4*big2,255,255,255);
		ObjEffect_SetVertexColor(obj,1,200-4*big2,255,255,255);
		ObjEffect_SetVertexColor(obj,2,200-4*big2,255,255,255);
		ObjEffect_SetVertexColor(obj,3,200-4*big2,255,255,255);
		yield;
		}
		Obj_Delete(obj);
	}

task MainShot(Angle,GP,SX,SY,SP,SS){
	let obj=Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX+SX,GetPlayerY-SY);
	Obj_SetSpeed(obj,SP);
	Obj_SetAngle(obj,Angle);
	ObjShot_SetDamage(obj,SS);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,GP);
	Obj_SetAlpha(obj,155);

	while(!Obj_BeDeleted(obj))
	{
	if(Obj_IsIntersected(obj)){
		Obj_SetSpeed(obj,0.5);
		ObjShot_FadeDelete(obj);
		}
	yield;
	}
}

task ShotSn(ST){
	let obj=Obj_Create(OBJ_LASER);
	Obj_SetPosition(obj,GetPlayerX+rand(-40,40),480);
	ObjLaser_SetLength(obj,480);
	ObjLaser_SetWidth(obj,10+ST*2);
	ObjLaser_SetSource(obj,false);
	Obj_SetAngle(obj,270);
	ObjShot_SetDamage(obj,1);
	ObjShot_SetPenetration(obj,10000);
	ObjShot_SetGraphic(obj,12);
	ObjShot_SetDelay(obj,0);
	loop(10){yield;}
		ObjShot_FadeDelete(obj);
	}

task ShotLu(D,C){
	let speed=0;
	let obj=Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
	Obj_SetAngle(obj,rand(45,135));
	ObjShot_SetDamage(obj,D);
	ObjShot_SetPenetration(obj,50);
	ObjShot_SetGraphic(obj,32);
	Obj_SetAlpha(obj,155);

	Obj_SetAutoDelete(obj,false);

	loop(20){
		Obj_SetSpeed(obj,4-speed);
		speed=speed-0.1;
		yield;}
	if(C==2){Obj_SetAngle(obj,270);}
		else if(C==1){Obj_SetAngle(obj,rand(260,280));}
		else {Obj_SetAngle(obj,rand(250,290));}
	loop(50){
		Obj_SetSpeed(obj,speed);
		speed=speed+0.5;
		yield;}
	Obj_SetAutoDelete(obj,true);
	break;
	}

task ShotSt(pX,SP,Angle){
	let dAngle=0;
	let dcount=0;
	let obj=Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,GetPlayerX+pX,GetPlayerY);
	Obj_SetSpeed(obj,5);
	Obj_SetAngle(obj,Angle);
	ObjShot_SetDamage(obj,SP);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,22);
	Obj_SetAlpha(obj,155);

	while(!Obj_BeDeleted(obj))
	{
		let LockID=HTarget(Obj_GetX(obj),Obj_GetY(obj));
		let enemyX=GetEnemyInfo(LockID,ENEMY_X);
		let enemyY=GetEnemyInfo(LockID,ENEMY_Y);
		let toAngle=atan2(enemyY-Obj_GetY(obj),enemyX-Obj_GetX(obj));
		let scalar1=cos(Angle-toAngle);
		let scalar2=cos(dAngle);

		if(LockID>-1&&enemyX>0&&enemyX<448&&enemyY>0&&enemyY<480){
			if(dAngle<36){dAngle+=2.4;}
				if(scalar1<scalar2)
				{
					let scalarR=cos(Angle-toAngle+dAngle);
					let scalarL=cos(Angle-toAngle-dAngle);
					if(scalarR>scalarL){Angle+=dAngle;}
					else {Angle-=dAngle;}
					}
				else {Angle=toAngle;}
			Obj_SetAngle(obj,Angle);
			}
		if(Obj_IsIntersected(obj)||dcount>120){
			Obj_SetSpeed(obj,0.5);
			ObjShot_FadeDelete(obj);
			}
		dcount++;
		yield;
		}
	}

	function HTarget(x,y){
		let LockID2=-1;
		let MinDistance=1000*1000;
		ascent(enemy in EnumEnemyBegin..EnumEnemyEnd){
			let enemyID=EnumEnemyGetID(enemy);
			let enemyX=GetEnemyInfo(enemyID,ENEMY_X);
			let enemyY=GetEnemyInfo(enemyID,ENEMY_Y);
			let dx=x-enemyX;
			let dy=y-enemyY;
			let distance=dx*dx+dy*dy;
			if(enemyID==0){
				LockID2=0;
				break;
			}
			else if(MinDistance>distance){
				MinDistance=distance;
				LockID2=enemyID;
			}
		}
		return LockID2;
	}

	@Missed{
		if(OnBorderOfLife==false){
		Gcount=GetGraze;
		FlagD=false;
			if(Type==1){SNSP=0;FlagA=false;}
			else if(Type==2){LUSP=0;FlagB=false;}
			else{STSP=0;FlagC=false;}
		}
		if(GetPlayerLife<1){
		Gcount=0;
		SNSP=0;
		LUSP=0;
		STSP=0;
		SNSP2=0;
		LUSP2=0;
		STSP2=0;
		FlagA=false;
		FlagB=false;
		FlagC=false;
		FlagD=false;
		}
	}

	@SpellCard{
		if(Type==1&&FlagD==false)
		{	
		UseSpellCard("Koufu",true);
		CutIn(KOUMA,"光符「ハイパーサニースパーク」",CutSangatusei2);
		}
		else if(Type==2&&FlagD==false){
		UseSpellCard("Tukifu",true);
		CutIn(KOUMA,"月符「ルナ・チャクラム」",CutSangatusei3);
		}
		else if(Type==0&&FlagD==false){
		UseSpellCard("Hosifu",true);
		CutIn(KOUMA,"星符「シャイニングスター」",CutSangatusei4);
		}
		else if(FlagD==true){
		UseSpellCard("Sun",true);
		CutIn(KOUMA,"協力技「フェアリーブラスター」",CutSangatusei1);
		}
	}
	
	@DrawLoop
	{
		if(GetPlayerX()>288&&GetPlayerY()>410){SetAlpha(100);} else {SetAlpha(255);}
		SetTexture(imgSangatusei);
		SetGraphicAngle(0,0,0);
		SetRenderState(ALPHA);

		SetGraphicRect(253,95,352,103);
		SetGraphicScale(SNSP*0.01,1);
		DrawGraphic(312+SNSP/2,436);

		SetGraphicScale(LUSP*0.01,1);
		DrawGraphic(312+LUSP/2,446);

		SetGraphicScale(STSP*0.01,1);
		DrawGraphic(312+STSP/2,456);

		SetGraphicRect(239,59,356,93);
		SetGraphicScale(1,1);
		SetColor(255,255,255);
		DrawGraphic(357,446);

		SetAlpha(imgAlpha);
		SetGraphicRect(159,39,222,102);
		SetGraphicScale(imgSize,imgSize);
		SetGraphicAngle(0,0,imgAngle);
		SetColor(imgR,imgG,imgB);
		DrawGraphic(GetPlayerX(),GetPlayerY());
		SetGraphicScale(2-imgSize,2-imgSize);
		SetGraphicAngle(0,0,-imgAngle);
		DrawGraphic(GetPlayerX(),GetPlayerY());

		SetAlpha(255);
		SetColor(255,255,255);
		SetRenderState(ALPHA);
		SetGraphicAngle(0,0,0);
		SetGraphicScale(1+Anime,1-Anime);
		if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
		{
			SetGraphicRect(Type*119+40,0,Type*119+79,38);
		}
		else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
		{
			SetGraphicRect(Type*119+80,0,Type*119+119,38);
		}
		else 
		{
			SetGraphicRect(Type*119+0,0,Type*119+39,38);
		}
		DrawGraphic(GetPlayerX(),GetPlayerY());	
	}
	
	@Finalize
	{
		DeleteGraphic(imgSangatusei);
	}

	sub Specialty
	{
		LockID=-1;
		if(GetEnemyNum>0)
		{
			let ID=1000;
			ascent(enemy in minID..maxID)
			{
				let enemyID=EnumEnemyGetID(enemy);
				if(enemyID<ID){ID=enemyID;}
			}
			LockID=[ID,-1][ID==1000];
		}
	}
}

	script_spell Koufu
	{
		let current = GetCurrentScriptDirectory();
		let bom = current~"se\BOM2.wav";
		let i = 0;
		SetSpeed(1.5,0.5);

	@Initialize
		{
		SetPlayerInvincibility(230);//無敵時間を設定
		shoot;
		}

	@MainLoop
		{
		CollectItems;
		yield;
		}

	@Finalize
		{
		}

	task shoot{
		loop(50){yield;}
		PlaySE(bom);
		Sshot11;
		loop(5){yield;}
		loop(5){
        		let i = 0;
        		while(i<30)
        		{
        		Sshot10(i*12);
        		i++;
			}
		loop(30){yield;}
		yield;}
		loop(25){yield;}
     		SetSpeed(4,1.5);
		End;
		}

	task Sshot10(angle){
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		Obj_SetSpeed(obj,rand(3,6));
		Obj_SetAngle(obj,rand(0,360));
		ObjShot_SetDamage(obj,0.1);
		ObjShot_SetPenetration(obj,10000);
		ObjShot_SetGraphic(obj,13);
		Obj_SetAlpha(obj,155);
		}

	task Sshot11{
		let Val = [0,0,0];
		let angle = 0;
		let obj = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,GetPlayerX(),GetPlayerY());
		Obj_SetAngle(obj,GetCommonData("HYPER"));
		ObjShot_SetGraphic(obj,12);
		ObjShot_SetDamage(obj,2);
		ObjLaser_SetLength(obj,1000);
		ObjLaser_SetWidth(obj,35);
		
		Val = GetReflectData(GetPlayerX(),GetPlayerY(),GetCommonData("HYPER"));
			
		let obj2 = Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj2,Val[0],Val[1]);
		Obj_SetAngle(obj2,Val[2]);
		ObjShot_SetGraphic(obj2,12);
		ObjShot_SetDamage(obj2,2);
		ObjLaser_SetLength(obj2,1000);
		ObjLaser_SetWidth(obj2,35);
		ObjLaser_SetSource(obj2,false);

		loop(100){
		Val = GetReflectData(GetPlayerX(),GetPlayerY(),GetCommonData("HYPER"));
		Obj_SetPosition(obj,GetPlayerX(),GetPlayerY());
		Obj_SetAngle(obj,GetCommonData("HYPER"));
		Obj_SetPosition(obj2,Val[0],Val[1]);
		Obj_SetAngle(obj2,Val[2]);
		yield;}
		loop(50){
		Val = GetReflectData(GetPlayerX(),GetPlayerY(),GetCommonData("HYPER"));
		Obj_SetPosition(obj,GetPlayerX(),GetPlayerY());
		Obj_SetAngle(obj,GetCommonData("HYPER"));
		Obj_SetAlpha(obj,250-(i*5));
		Obj_SetPosition(obj2,Val[0],Val[1]);
		Obj_SetAngle(obj2,Val[2]);
		Obj_SetAlpha(obj2,250-(i*5));
		i++;
		yield;}
		let angle=270;
		SetCommonData("HYPER",angle);
		Obj_Delete(obj);
		Obj_Delete(obj2);
		#include_function ".\ReflectValue.txt"
		}
	}

	script_spell Tukifu
	{
		let current=GetCurrentScriptDirectory();
		let bom=current~"se\BOM1.wav";
		let i=0;
		SetSpeed(1.5,0.5);

	@Initialize
		{
		SetPlayerInvincibility(230);//無敵時間を設定
		shoot;
		}

	@MainLoop
		{
		CollectItems;
		yield;
		}

	@Finalize
		{
		}

	task shoot{
		loop(50){yield;}
		PlaySE(bom);
			let i=0;
			while(i<30)
        		{
        		Sshot20(i*12,12,6);
        		Sshot20(i*12,-12,-6);
        		i++;
			}
		loop(200){yield;}
		SetSpeed(4,1.5);
		End;
		}

    	task Sshot20(angle,speed,asp){
		let r = 0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetPlayerX+cos(angle)*40,GetPlayerY+sin(angle)*40);
		Obj_SetSpeed(obj,2);
		ObjShot_SetDamage(obj,0.2);
		ObjShot_SetPenetration(obj,150);
		ObjShot_SetGraphic(obj,33);
		ObjShot_SetDelay(obj,0);

		loop(100){
			Obj_SetPosition(obj,GetPlayerX+cos(angle)*40,GetPlayerY+sin(angle)*40);
			Obj_SetAngle(obj,angle);
			angle=angle+asp;
			yield;}
		loop(25){
			Obj_SetAngle(obj,angle);
			angle=angle+asp;
			yield;}
		}
	}

	script_spell Hosifu
	{
		let current=GetCurrentScriptDirectory();
		let bom=current~"se\BOM1.wav";
		let i=0;
		SetSpeed(1.5,0.5);

	@Initialize
		{
		SetPlayerInvincibility(230);//無敵時間を設定
		shoot;
		}

	@MainLoop
		{
		CollectItems;
		yield;
		}

	@Finalize
		{
		}

	task shoot{
		loop(50){yield;}
		PlaySE(bom);
			let i=0;
			while(i<5)
        		{
        		Sshot30(i*72+270,10,25);
        		Sshot30(i*72+270,7,24);
        		Sshot30(i*72+270,4,26);
        		i++;
			}
		loop(200){yield;}
		SetSpeed(4,1.5);
		End;
		}

    	task Sshot30(angle,speed,sgp){
		let r=0;
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		Obj_SetAngle(obj,angle);
		Obj_SetSpeed(obj,speed);
		ObjShot_SetDamage(obj,5);
		ObjShot_SetPenetration(obj,200);
		ObjShot_SetGraphic(obj,sgp);
		ObjShot_SetDelay(obj,0);
		loop(15){Sshot31(angle,sgp,Obj_GetX(obj),Obj_GetY(obj));
			loop(1){yield;}
			yield;}
		}

    	task Sshot31(angle,sgp,x,y){
		let obj2=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj2,x,y);
		Obj_SetAngle(obj2,angle+rand(160,200));
		Obj_SetSpeed(obj2,rand(3,5));
		ObjShot_SetDamage(obj2,0.2);
		ObjShot_SetPenetration(obj2,150);
		ObjShot_SetGraphic(obj2,sgp-3);
		ObjShot_SetDelay(obj2,0);
		PlaySE("seSuperNaturalBorder2.wav");
		}
	}

	script_spell Sun
	{
		let current=GetCurrentScriptDirectory();
		let bom=current~"se\BOM2.wav";
		let bom2=current~"se\BOM3.wav";
		let i=0;
		SetSpeed(1,0.5);

	@Initialize
		{
		SetPlayerInvincibility(280);//無敵時間を設定
		shoot;
		}

	@MainLoop
		{
		CollectItems;
		yield;
		}

	@Finalize
		{
		}

	task shoot{
		loop(50){yield;}
		PlaySE(bom);
		SshotA;
		shoot2;
		loop(10){
			loop(20){SshotC;
				yield;}
			yield;}
		loop(30){yield;}
		SetSpeed(4,1.5);
		PlaySE("seSuperNaturalBorder2.wav");
		End;
		}

	task shoot2{
		loop(15){
			square;
        		let i = 0;
        		while(i<30)
        		{
        		SshotB(i*12);
        		i++;
			}
			PlaySE(bom2);
			loop(10){yield;}
			yield;}
		}

	task SshotA{
		let obj=Obj_Create(OBJ_LASER);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		Obj_SetAngle(obj,270);
		Obj_SetAlpha(obj,250);
		ObjShot_SetDamage(obj,1.5);
		ObjShot_SetGraphic(obj,12);
		ObjShot_SetDelay(obj,0);
		ObjLaser_SetLength(obj,480);
		ObjLaser_SetWidth(obj,35);
		loop(200){
			Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
			yield;}
		Obj_Delete(obj);
	}
	task SshotB(angle){
		let obj=Obj_Create(OBJ_SHOT);
		let r=rand(0,360);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY);
		Obj_SetSpeed(obj,3);
		Obj_SetAngle(obj,angle+r);
		ObjShot_SetDamage(obj,0.5);
		ObjShot_SetPenetration(obj,10000);
		ObjShot_SetGraphic(obj,13);
		Obj_SetAlpha(obj,155);
	}
	task SshotC{
		let obj=Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj,GetPlayerX+rand(-17,17),16);
		Obj_SetSpeed(obj,rand(2,4));
		Obj_SetAngle(obj,rand(0,180));
		ObjShot_SetDamage(obj,0.5);
		ObjShot_SetPenetration(obj,10000);
		ObjShot_SetGraphic(obj,rand_int(21,26));
		Obj_SetAlpha(obj,155);
	}

	task square
	{
		let scx=0;
		let imgAngle=0;
		let obj=Obj_Create(OBJ_EFFECT);
		let current=GetCurrentScriptDirectory();
		let imgEffect2=current~"img\Sangatusei.png";
		ObjEffect_SetTexture(obj,imgEffect2);
		ObjEffect_SetPrimitiveType(obj,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_CreateVertex(obj,4);
		ObjEffect_SetRenderState(obj,ALPHA);
		ObjEffect_SetLayer(obj,2);

		ObjEffect_SetVertexXY(obj,0,-32,-32);
		ObjEffect_SetVertexXY(obj,1,-32,32);
		ObjEffect_SetVertexXY(obj,2,32,-32);
		ObjEffect_SetVertexXY(obj,3,32,32);

		ObjEffect_SetVertexUV(obj,0,159,39);
		ObjEffect_SetVertexUV(obj,1,159,102);
		ObjEffect_SetVertexUV(obj,2,222,39);
		ObjEffect_SetVertexUV(obj,3,222,102);

		loop(120){
		if(scx<1.5){scx+=0.05;}
		imgAngle+=4;
		ObjEffect_SetAngle(obj,290,rand(-5,5),imgAngle);
		ObjEffect_SetScale(obj,scx,scx);
		Obj_SetPosition(obj,GetPlayerX,GetPlayerY-imgAngle*2);
		yield;
		}
		Obj_Delete(obj);
	}
}