#東方弾幕風[Player]
#ScriptVersion[2] 
#Menu[姫海棠はたて]
#Text[]
#ReplayName[はたて]
script_player_main
{
	let csd = GetCurrentScriptDirectory();
	let imgPlayer = csd~"..\img\STG_Player11.png";
	let img = csd~"..\img\Aya.png";
	let imgDS = csd~"..\img\pl01.png";
	let imgSpell = csd~"..\img\HoshiShot.png";
	let imgBorder = csd~"..\img\border.png";
	let imgCamera =csd~"..\img\Aya_camera.png";
	let imgCircle =csd~"..\img\Circle.png";
	let CameraBack=csd~"..\img\Back.png";
	let CameraBack2=csd~"..\img\Back2.png";
	let Charge=50;//フィルム装填率
	let PlusCharge=0;//高速フィルム巻き時の初期ディレイ
	let FinderMode=false;//ファインダーモードかどうか
	let FinderTimeOut=false;//ファインダーモードがタイムアウトしたかどうか
	let FinderCentral=[];//焦点の中心座標Obj
	let CameraAngle=270;//カメラ角
	let CameraDir=180;//カメラの縦横
	let BossCapture=false;//ボスに当たり判定があるかどうか
	let DrawDetail=true;
	let PhotoSelectCorsol=0;

	let CharaDrawCount=0;
	let CharaLeftMoveDrawCount=0;
	let CharaRightMoveDrawCount=0;
	let DrawFrame=5;
	let CameraCoordinate;

	let snapFile=["DSHatate00","DSHatate01","DSHatate02","DSHatate03","DSHatate04","DSHatate05","DSHatate06","DSHatate07","DSHatate08","DSHatate09",
			"DSHatate10","DSHatate11","DSHatate12","DSHatate13","DSHatate14","DSHatate15","DSHatate16","DSHatate17","DSHatate18","DSHatate19",
			"DSHatate20","DSHatate21","DSHatate22","DSHatate23","DSHatate24","DSHatate25","DSHatate26","DSHatate27","DSHatate28","DSHatate29"];//SSに適当に名付け
	let photoNo=0;//何枚目かの判定。ボスを取るのに成功すると１増える
	let SE=[csd~"..\se\beep15" , csd~"..\se\power35" ,csd~"..\se\weapon00" , "0", csd~"..\se\se-033.mp3"  , csd~"..\se\power00" , csd~"..\se\kaze0102", csd~"..\se\sha01"];

	@Initialize
	{
	/*	if(DSdot==true)
		{
			SetPlayerLifeImage(img, 0, 0, 48, 48);
		}
		else
		{
	*/		SetPlayerLifeImage(imgPlayer, 0, 0, 48, 48);
	//	}
		LoadGraphic(imgPlayer);
		LoadGraphic(img);
		LoadGraphic(imgDS);
		LoadGraphic(imgSpell);
		LoadGraphic(imgBorder);
		LoadGraphic(imgCamera);
		LoadGraphic(CameraBack);
		LoadGraphic(CameraBack2);
		LoadGraphic(imgCircle);
		SetSpeed(5.5, 2.5);//自機の移動速度
		LoadPlayerShotData(csd~"..\txt\ShotData.txt");
		SetItemCollectLine(176);//アイテム回収されるy座標
		SetRebirthFrame(8);//食らいボムの有効フレーム
		SetGrazeCircle(0);
		Tmain;
	}

	task Tmain
	{
		yield;
		yield;
		Cdraw;//自機中心の陣のタスク
		Finder;//ファインダー制御
		CameraDirChange;//カメラの回転を制御
		CameraAngleChange;//カメラ角を制御
		SetSpeedChange;//スピードを三段階で制御
		ChargeFilm;//装填速度を制御
		ChargeFilmSE;
		ChargeFilmFinishSE;
		PhotoSelectChange;
	}

	@MainLoop
	{
		SetIntersectionCircle(GetPlayerX, GetPlayerY, 0);//自機の当たり判定
		yield;

		CharaDrawCount+=1;
		if(CharaDrawCount>=DrawFrame*7)
		{
			CharaDrawCount=0;
		}

		CharaLeftMoveDrawCount+=1;

		if(CharaLeftMoveDrawCount>=DrawFrame*7)
		{
			CharaLeftMoveDrawCount=DrawFrame*4;
		}
		if(GetKeyState(VK_LEFT)==KEY_FREE)
		{
			CharaLeftMoveDrawCount=0;
		}

		CharaRightMoveDrawCount+=1;

		if(CharaRightMoveDrawCount>=DrawFrame*7)
		{
			CharaRightMoveDrawCount=DrawFrame*4;
		}
		if(GetKeyState(VK_RIGHT)==KEY_FREE)
		{
			CharaRightMoveDrawCount=0;
		}
	}

	@Missed{
		MainLoop;
		if(GetCommonDataDefault("BunSpell",false)==true)
		{
			SetPlayerInvincibility(1200);
		}
		}

	@SpellCard
	{		
		AddBomb(1);
	}

	@DrawLoop
	{
	if(DSdot)
	{
		SetTexture(imgDS);
		if(FinderMode==false)
		{
			if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
			{
				if(GetCommonDataDefault("TimeStop",false)==false && GetCommonDataDefault("DefeatBoss",false)==false)
				{
				SetGraphicRect(floor(CharaLeftMoveDrawCount/DrawFrame)*32, 49, floor(CharaLeftMoveDrawCount/DrawFrame+1)*32, 97);
				}
			}
			else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
			{
				if(GetCommonDataDefault("TimeStop",false)==false && GetCommonDataDefault("DefeatBoss",false)==false)
				{
				SetGraphicRect(floor(CharaRightMoveDrawCount/DrawFrame)*32, 97, floor(CharaRightMoveDrawCount/DrawFrame+1)*32, 144);
				}
			}
			else
			{
				if(GetCommonDataDefault("TimeStop",false)==false && GetCommonDataDefault("DefeatBoss",false)==false)
				{
				SetGraphicRect(floor(CharaDrawCount/DrawFrame)*32, 1, floor(CharaDrawCount/DrawFrame+1)*32, 49);
				}
			}
		}
		else
		{
			let angle=360+atan2(Obj_GetY(CameraCoordinate)-GetPlayerY,Obj_GetX(CameraCoordinate)-GetPlayerX);
			if(angle%360>=337.5)
			{
				SetGraphicRect(0, 177, 32, 225);
			}
			else
			{
				SetGraphicRect(floor((angle%360+22.5)/45)*32, 177, floor((angle%360+22.5)/45+1)*32, 225);
			}
		}
	}
	else
	{
		SetTexture(imgPlayer);
		if((GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD) && FinderMode==false)
		{
			SetGraphicRect(10, 53, 38, 94);
		}
		else if((GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD) && FinderMode==false)
		{
			SetGraphicRect(10, 101, 38, 142);
		}
		else
		{
			SetGraphicRect(10, 2, 38, 48);
		}
	}
		SetRenderState(ALPHA);
		DrawGraphic(GetPlayerX(), GetPlayerY());//自機の描画
	atari;
	}

	@Finalize
	{
		DeleteGraphic(img);
		DeleteGraphic(imgSpell);
		DeleteGraphic(imgBorder);
	}

task Finder//ファインダーの挙動。かなり長い。
{
		let scax=1.5;
		let scay=0.84;
		let ScAngle=90;//通常時のカメラの大きさの周期変化させるための値
		let CameraRD=50;//自機からカメラ中心のまでの基本距離
		let SlowRD=0;//低速に時カメラが伸びる距離（４０まで）
		let obj=Obj_Create(OBJ_EFFECT);
		CameraCoordinate = obj;
		ObjEffect_SetTexture(obj, imgCamera);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -25, -25);
		ObjEffect_SetVertexXY(obj, 1, 25,  -25);
		ObjEffect_SetVertexXY(obj, 2, 25, 25);
		ObjEffect_SetVertexXY(obj, 3,  -25,  25);
		
		ObjEffect_SetVertexUV(obj, 0,  13,  95);
		ObjEffect_SetVertexUV(obj, 1,  87, 95);
		ObjEffect_SetVertexUV(obj, 2, 87,  169);
		ObjEffect_SetVertexUV(obj, 3, 13, 169);
		ObjEffect_SetScale(obj, scax,scay);
		ObjEffect_SetLayer(obj,3);
		ascent(let i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,200,255,200,200);
		}

		Pdraw(obj);//装填率と可能、不可能を表示するタスク
		FinderPdraw(obj);//ファインダーモード時残り時間％で表示するをタスク
		FinderCircle(obj);//カメラの中心をくるくる回ってるやつ

		let ChargeAdjust=0;//高速巻き時、カメラの位置を補正するための値
		let size=1;//あまり意味はない。コピペした元のやつにこの変数があるから宣言しただけ。値は１固定
		loop{
			if(Charge==100)//100%かどうかで若干大きさを変更
			{
				ObjEffect_SetScale(obj, scax-0.16+0.16*cos(ScAngle),scay-0.2+0.2*cos(ScAngle));
			}
			else
			{
				ObjEffect_SetScale(obj, scax-0.3+0.2*cos(ScAngle),scay-0.3+0.2*cos(ScAngle));
			}
			ScAngle+=10;
			if(FinderMode==false)
			{
				if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD) && Charge!=100)
				{
					Obj_SetPosition(obj,GetPlayerX+(CameraRD+ChargeAdjust)*cos(CameraAngle),GetPlayerY+(CameraRD+ChargeAdjust)*sin(CameraAngle));
					ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
					if(ChargeAdjust>-50)
					{
						ChargeAdjust-=10;
					}
					SlowRD=0;
				}
				else if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD) && Charge==100)
				{
					Obj_SetPosition(obj,GetPlayerX+55*cos(CameraAngle),GetPlayerY+55*sin(CameraAngle));
					ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
					SlowRD=0;
					ChargeAdjust=0;
				}
				else
				{
					Obj_SetPosition(obj,GetPlayerX+(CameraRD+SlowRD)*cos(CameraAngle),GetPlayerY+(CameraRD+SlowRD)*sin(CameraAngle));
					ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
					ChargeAdjust=0;
				}
			}
			if(Obj_GetX(obj)<=GetClipMinX)//カメラが画面外に行かないように位置補正
			{
				Obj_SetX(obj,GetClipMinX);
			}
			if(Obj_GetX(obj)>=GetClipMaxX)
			{
				Obj_SetX(obj,GetClipMaxX);
			}
			if(Obj_GetY(obj)<=GetClipMinY)
			{
				Obj_SetY(obj,GetClipMinY);
			}
			if(Obj_GetY(obj)>=GetClipMaxY)
			{
				Obj_SetY(obj,GetClipMaxY);
			}
			if(GetKeyState(VK_SHOT)==KEY_PUSH  && (GetKeyState(VK_SLOWMOVE)==KEY_FREE || GetKeyState(VK_SLOWMOVE)==KEY_PULL )  && Charge==100 && GetCommonDataDefault("LoseBoss",false)==false)
			{
				TFinderMode(obj);//ファインダーモードに移行
				ChargeDicrease;//装填率を減らしていく。ファインダーモードの残り時間を表示するために使用。
			}

			if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
			{//低速時の望遠
				if(SlowRD<40)
				{
				SlowRD+=1;
				}
			}
			else if(SlowRD>0)
			{
				SlowRD-=1;
			}
			//以下ファインダーモード
			if(FinderMode==true)
			{//ファインダーモード時は見えないように
				ascent(let i in 0..4)
				{
					ObjEffect_SetVertexColor(obj,i,0,255,255,255);
				}
				//これ以下は撮影後手元に戻るまでのコード
				while(FinderMode==true){yield;}
				ascent(let i in 0..4)
				{
					ObjEffect_SetVertexColor(obj,i,255,255,200,200);
				}
				let posX=Obj_GetX(obj);
				let posY=Obj_GetY(obj);
				loop(60)
				{
					ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
					if(Charge==100)
					{
						ObjEffect_SetScale(obj, scax-0.2+0.2*cos(ScAngle),scay-0.2+0.2*cos(ScAngle));
					}
					else
					{
						ObjEffect_SetScale(obj, scax-0.3+0.2*cos(ScAngle),scay-0.3+0.2*cos(ScAngle));
					}
					ScAngle+=10;
					if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD) && Charge!=100)
					{
						if(ChargeAdjust>-50)
						{
							ChargeAdjust-=10;
						}
						SlowRD=0;
					}
					else if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD) && Charge==100)
					{
						SlowRD=0;
						ChargeAdjust=0;
					}
					else
					{
						ChargeAdjust=0;
					}
					if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
					{
						if(SlowRD<40)
						{
						SlowRD+=1;
						}
					}
					else if(SlowRD>0)
					{
						SlowRD-=1;
					}
				yield;
				}

				loop(10)
				{
					if(Charge==100)
					{
						ObjEffect_SetScale(obj, scax-0.2+0.2*cos(ScAngle),scay-0.2+0.2*cos(ScAngle));
					}
					else
					{
						ObjEffect_SetScale(obj, scax-0.3+0.2*cos(ScAngle),scay-0.3+0.2*cos(ScAngle));
					}
					ScAngle+=10;

					if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD) && Charge!=100)
					{
						Obj_SetPosition(obj,Obj_GetX(obj)+(GetPlayerX+(CameraRD+ChargeAdjust)*cos(CameraAngle)-posX)/10,Obj_GetY(obj)+(GetPlayerY+(CameraRD+ChargeAdjust)*sin(CameraAngle)-posY)/10);
						ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
						if(ChargeAdjust>-50)
						{
							ChargeAdjust-=10;
						}
						SlowRD=0;
					}
					else if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && (GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD) && Charge==100)
					{
						Obj_SetPosition(obj,Obj_GetX(obj)+(GetPlayerX+55*cos(CameraAngle)-posX)/10,Obj_GetY(obj)+(GetPlayerY+55*sin(CameraAngle)-posY)/10);
						ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
						SlowRD=0;
						ChargeAdjust=0;
					}
					else
					{
						Obj_SetPosition(obj,Obj_GetX(obj)+(GetPlayerX+(CameraRD+SlowRD)*cos(CameraAngle)-posX)/10,Obj_GetY(obj)+(GetPlayerY+(CameraRD+SlowRD)*sin(CameraAngle)-posY)/10);
						ObjEffect_SetAngle(obj,0,0,CameraAngle+CameraDir);
						ChargeAdjust=0;
					}
					if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
					{
						if(SlowRD<40)
						{
						SlowRD+=1;
						}
					}
					else if(SlowRD>0)
					{
						SlowRD-=1;
					}

					yield;
				}
			}
			if(GetCommonDataDefault("BunSpell",false)==true)
			{
				if(Charge>=100 && Collision_Line_Circle(Obj_GetX(obj)-(5*size*25/2)*cos(CameraAngle+CameraDir-90),Obj_GetY(obj)-(5*size*25/2)*sin(CameraAngle+CameraDir-90),Obj_GetX(obj)+(5*size*25/2)*cos(CameraAngle+CameraDir-90),Obj_GetY(obj)+(5*size*25/2)*sin(CameraAngle+CameraDir-90),5*size*45,GetEnemyInfo(1,ENEMY_X),GetEnemyInfo(1,ENEMY_Y),0))
				{//即撮影でボスが撮れるとき色変更。専用スペルかどうかでボスＩＤが変わるため場合わけ		
					ObjEffect_SetVertexUV(obj, 0,  352,  95);
					ObjEffect_SetVertexUV(obj, 1,  426, 95);
					ObjEffect_SetVertexUV(obj, 2, 426,  169);
					ObjEffect_SetVertexUV(obj, 3, 352, 169);
				}
				else
				{
					ObjEffect_SetVertexUV(obj, 0,  13,  95);
					ObjEffect_SetVertexUV(obj, 1,  87, 95);
					ObjEffect_SetVertexUV(obj, 2, 87,  169);
					ObjEffect_SetVertexUV(obj, 3, 13, 169);
				}
			}
			else
			{
				if(Charge>=100 && Collision_Line_Circle(Obj_GetX(obj)-(5*size*25/2)*cos(CameraAngle+CameraDir-90),Obj_GetY(obj)-(5*size*25/2)*sin(CameraAngle+CameraDir-90),Obj_GetX(obj)+(5*size*25/2)*cos(CameraAngle+CameraDir-90),Obj_GetY(obj)+(5*size*25/2)*sin(CameraAngle+CameraDir-90),5*size*45,GetEnemyInfo(0,ENEMY_X),GetEnemyInfo(0,ENEMY_Y),0))
				{		
					ObjEffect_SetVertexUV(obj, 0,  352,  95);
					ObjEffect_SetVertexUV(obj, 1,  426, 95);
					ObjEffect_SetVertexUV(obj, 2, 426,  169);
					ObjEffect_SetVertexUV(obj, 3, 352, 169);
				}
				else
				{
					ObjEffect_SetVertexUV(obj, 0,  13,  95);
					ObjEffect_SetVertexUV(obj, 1,  87, 95);
					ObjEffect_SetVertexUV(obj, 2, 87,  169);
					ObjEffect_SetVertexUV(obj, 3, 13, 169);
				}
			}
			yield;
		}
}

task ChargeDicrease//装填率を減少させる。タイムアウトまでの時間を表示させるために使用
{
	wait(10);
	loop(20)
	{
		if(FinderMode==false){break;}
		Charge-=5;
		yield;
	}
Charge=50;
}

task FinderScale(Cobj,angle)//ファインダーモード時の４隅枠の動作、写真を取る時の殆ど黒のテクスチャもここ
{
		let scax=0.9;
		let scay=0.8;
		let CameraRD=60;
		let dis=5*((12.5*0.84)^2+(12.5*1.5)^2)^0.5;
		let finderangle=atan(-0.84/1.5)+CameraDir-90;
		let obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgCamera);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);

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

		ObjEffect_SetVertexUV(obj, 0,  0,  0);
		ObjEffect_SetVertexUV(obj, 1,  120, 0);
		ObjEffect_SetVertexUV(obj, 2, 120,  80);
		ObjEffect_SetVertexUV(obj, 3, 0, 80);

		ObjEffect_SetScale(obj, scax,scay);
		ObjEffect_SetAngle(obj,0,0,angle+CameraDir);
		ObjEffect_SetLayer(obj,6);
////////////////////////////////////////////////////////////////////////////
		let finderangle2=atan(0.84/1.5)+CameraDir-90;
		let obj2=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj2, imgCamera);
		ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj2, ADD); 
		ObjEffect_CreateVertex(obj2, 4);

		ObjEffect_SetVertexXY(obj2, 1, -24, -24);
		ObjEffect_SetVertexXY(obj2, 0, 24,  -24);
		ObjEffect_SetVertexXY(obj2, 3, 24, 24);
		ObjEffect_SetVertexXY(obj2, 2,  -24,  24);
		
		ObjEffect_SetVertexUV(obj2, 0,  0,  0);
		ObjEffect_SetVertexUV(obj2, 1,  120, 0);
		ObjEffect_SetVertexUV(obj2, 2, 120,  80);
		ObjEffect_SetVertexUV(obj2, 3, 0, 80);

		ObjEffect_SetScale(obj2, scax,scay);
		ObjEffect_SetAngle(obj2,180,0,-angle-CameraDir);
		ObjEffect_SetLayer(obj2,6);
///////////////////////////////////////////////////////////////////////////////////////////
		let finderangle3=atan(-0.84/1.5)+180+CameraDir-90;
		let obj3=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj3, imgCamera);
		ObjEffect_SetPrimitiveType(obj3, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj3, ADD); 
		ObjEffect_CreateVertex(obj3, 4);

		ObjEffect_SetVertexXY(obj3, 1, -24, -24);
		ObjEffect_SetVertexXY(obj3, 0, 24,  -24);
		ObjEffect_SetVertexXY(obj3, 3, 24, 24);
		ObjEffect_SetVertexXY(obj3, 2,  -24,  24);
		
		ObjEffect_SetVertexUV(obj3, 0,  0,  0);
		ObjEffect_SetVertexUV(obj3, 1,  120, 0);
		ObjEffect_SetVertexUV(obj3, 2, 120,  80);
		ObjEffect_SetVertexUV(obj3, 3, 0, 80);

		ObjEffect_SetScale(obj3, scax,scay);
		ObjEffect_SetAngle(obj3,0,0,angle+CameraDir+180);
		ObjEffect_SetLayer(obj3,6);
///////////////////////////////////////////////////////////////////////////////////////////
		let finderangle4=atan(0.84/1.5)+180+CameraDir-90;
		let obj4=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj4, imgCamera);
		ObjEffect_SetPrimitiveType(obj4, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj4, ADD); 
		ObjEffect_CreateVertex(obj4, 4);

		ObjEffect_SetVertexXY(obj4, 1, -24, -24);
		ObjEffect_SetVertexXY(obj4, 0, 24,  -24);
		ObjEffect_SetVertexXY(obj4, 3, 24, 24);
		ObjEffect_SetVertexXY(obj4, 2,  -24,  24);
		
		ObjEffect_SetVertexUV(obj4, 0,  0,  0);
		ObjEffect_SetVertexUV(obj4, 1,  120, 0);
		ObjEffect_SetVertexUV(obj4, 2, 120,  80);
		ObjEffect_SetVertexUV(obj4, 3, 0, 80);

		ObjEffect_SetScale(obj4, scax,scay);
		ObjEffect_SetAngle(obj4,0,180,-angle-CameraDir);
		ObjEffect_SetLayer(obj4,6);
///////////////////////////////////////////////////////////////////////////////////////////
		let BGscax=4.5;
		let BGscay=2.8;
		let finderangle5=atan(0.84/1.5)+180+CameraDir-90;
		let obj5=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj5, CameraBack);
		ObjEffect_SetPrimitiveType(obj5, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj5, ADD); 
		ObjEffect_CreateVertex(obj5, 4);

		ObjEffect_SetVertexXY(obj5, 0, -1280, -1280);
		ObjEffect_SetVertexXY(obj5, 1, 1280,  -1280);
		ObjEffect_SetVertexXY(obj5, 2, 1280, 1280);
		ObjEffect_SetVertexXY(obj5, 3,  -1280,  1280);
		
		ObjEffect_SetVertexUV(obj5, 0,  0,  0);
		ObjEffect_SetVertexUV(obj5, 1,  257, 0);
		ObjEffect_SetVertexUV(obj5, 2, 257,  257);
		ObjEffect_SetVertexUV(obj5, 3, 0, 257);

		ObjEffect_SetScale(obj5, BGscax,BGscay);
		ObjEffect_SetAngle(obj5,0,0,angle+CameraDir);
		ObjEffect_SetLayer(obj5,6);
		Obj_SetPosition(obj5,Obj_GetX(Cobj),Obj_GetY(Cobj));
			ascent(let i in 0..4)
			{
				ObjEffect_SetVertexColor(obj5,i,255,255,255,255);
				ObjEffect_SetVertexColor(obj,i,150,255,255,255);
				ObjEffect_SetVertexColor(obj2,i,150,255,255,255);
				ObjEffect_SetVertexColor(obj3,i,150,255,255,255);
				ObjEffect_SetVertexColor(obj4,i,150,255,255,255);
			}
///////////////////////////////////////////////////////////////////////////////////////
		let ringx=1.0;
		let ringy=1.0;
		let finderangle6=atan(1.15/1.5)+180+CameraDir-90;
		let obj6=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj6, imgCamera);
		ObjEffect_SetPrimitiveType(obj6, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj6, ADD); 
		ObjEffect_CreateVertex(obj6, 4);

		ObjEffect_SetVertexXY(obj6, 1, -100, -100);
		ObjEffect_SetVertexXY(obj6, 0, 100,  -100);
		ObjEffect_SetVertexXY(obj6, 3, 100, 100);
		ObjEffect_SetVertexXY(obj6, 2,  -100,  100);
		
		ObjEffect_SetVertexUV(obj6, 0,  0,  180);
		ObjEffect_SetVertexUV(obj6, 1,  300, 180);
		ObjEffect_SetVertexUV(obj6, 2, 300,  480);
		ObjEffect_SetVertexUV(obj6, 3, 0, 480);

		ObjEffect_SetScale(obj6, ringx,ringy);
		ObjEffect_SetAngle(obj6,0,180,-angle-CameraDir);
		ObjEffect_SetLayer(obj6,6);
		Obj_SetPosition(obj6,Obj_GetX(Cobj),Obj_GetY(Cobj));
///////////////////////////////////////////////////////////////////////////
	let Picdis=6*((12.5*0.84)^2+(12.5*1.5)^2)^0.5;
	let dis2=dis;
	let size=1;
///////////////////////////////////////////////////////////////////////////////////////
		ascent(let i in 0..30)
		{
			if(FinderMode==true)
			{
				Obj_SetPosition(obj,Obj_GetX(Cobj)+dis*cos(finderangle+angle-270),Obj_GetY(Cobj)+dis*sin(finderangle+angle-270));
				Obj_SetPosition(obj2,Obj_GetX(Cobj)+dis*cos(finderangle2+angle-270),Obj_GetY(Cobj)+dis*sin(finderangle2+angle-270));
				Obj_SetPosition(obj3,Obj_GetX(Cobj)+dis*cos(finderangle3+angle-270),Obj_GetY(Cobj)+dis*sin(finderangle3+angle-270));
				Obj_SetPosition(obj4,Obj_GetX(Cobj)+dis*cos(finderangle4+angle-270),Obj_GetY(Cobj)+dis*sin(finderangle4+angle-270));
				Obj_SetPosition(obj5,Obj_GetX(Cobj),Obj_GetY(Cobj));
				ObjEffect_SetScale(obj5, BGscax,BGscay);
				Obj_SetPosition(obj6,Obj_GetX(Cobj),Obj_GetY(Cobj));
				ObjEffect_SetScale(obj6, ringx,ringy);
			}
			if(GetKeyState(VK_SHOT)==KEY_PULL)
			{
				Obj_Delete(obj);
				Obj_Delete(obj2);
				Obj_Delete(obj3);
				Obj_Delete(obj4);
				Obj_Delete(obj6);
				SetCommonData("Shooting",true);//撮影する合図、これを元に他の表示が一時的に消えたりする
				wait(10);
				SetCommonData("Shooting",false);
				Obj_Delete(obj5);
				break;

			}
			if(i>=10)
			{
				dis-=(4*(12.5^2+(12.5*1.5)^2)^0.5)/200;
				BGscax-=(4.5*1/10)/20;
				BGscay-=(2.8*1/10)/20;
				ringx-=1/20;
				ringy-=1/20;
				dis2=Picdis-(i-10)*(6*((12.5*0.84)^2+(12.5*1.5)^2)^0.5)/200;
				size=dis2/Picdis;
			}
			if(GetCommonDataDefault("BunSpell",false)==true)//専用スペルかどうかで場合わけ
			{//以下撮影範囲にいるかどうかで色が変わるコード
				if(Collision_Line_Circle(Obj_GetX(Cobj)-(5*size*25/2)*cos(angle+CameraDir-90),Obj_GetY(Cobj)-(5*size*25/2)*sin(angle+CameraDir-90),Obj_GetX(Cobj)+(5*size*25/2)*cos(angle+CameraDir-90),Obj_GetY(Cobj)+(5*size*25/2)*sin(angle+CameraDir-90),5*size*45,GetEnemyInfo(1,ENEMY_X),GetEnemyInfo(1,ENEMY_Y),0))
				{
					ObjEffect_SetVertexUV(obj, 0,  340,  0);
					ObjEffect_SetVertexUV(obj, 1,  460, 0);
					ObjEffect_SetVertexUV(obj, 2, 460,  80);
					ObjEffect_SetVertexUV(obj, 3, 340, 80);
					ObjEffect_SetVertexUV(obj2, 0,  340,  0);
					ObjEffect_SetVertexUV(obj2, 1,  460, 0);
					ObjEffect_SetVertexUV(obj2, 2, 460,  80);
					ObjEffect_SetVertexUV(obj2, 3, 340, 80);
					ObjEffect_SetVertexUV(obj3, 0,  340,  0);
					ObjEffect_SetVertexUV(obj3, 1,  460, 0);
					ObjEffect_SetVertexUV(obj3, 2, 460,  80);
					ObjEffect_SetVertexUV(obj3, 3, 340, 80);
					ObjEffect_SetVertexUV(obj4, 0,  340,  0);
					ObjEffect_SetVertexUV(obj4, 1,  460, 0);
					ObjEffect_SetVertexUV(obj4, 2, 460,  80);
					ObjEffect_SetVertexUV(obj4, 3, 340, 80);
					ObjEffect_SetVertexUV(obj6, 0,  340,  180);
					ObjEffect_SetVertexUV(obj6, 1,  640, 180);
					ObjEffect_SetVertexUV(obj6, 2, 640,  480);
					ObjEffect_SetVertexUV(obj6, 3, 340, 480);
				}
				else
				{
					ObjEffect_SetVertexUV(obj, 0,  0,  0);
					ObjEffect_SetVertexUV(obj, 1,  120, 0);
					ObjEffect_SetVertexUV(obj, 2, 120,  80);
					ObjEffect_SetVertexUV(obj, 3, 0, 80);
					ObjEffect_SetVertexUV(obj2, 0,  0,  0);
					ObjEffect_SetVertexUV(obj2, 1,  120, 0);
					ObjEffect_SetVertexUV(obj2, 2, 120,  80);
					ObjEffect_SetVertexUV(obj2, 3, 0, 80);
					ObjEffect_SetVertexUV(obj3, 0,  0,  0);
					ObjEffect_SetVertexUV(obj3, 1,  120, 0);
					ObjEffect_SetVertexUV(obj3, 2, 120,  80);
					ObjEffect_SetVertexUV(obj3, 3, 0, 80);
					ObjEffect_SetVertexUV(obj4, 0,  0,  0);
					ObjEffect_SetVertexUV(obj4, 1,  120, 0);
					ObjEffect_SetVertexUV(obj4, 2, 120,  80);
					ObjEffect_SetVertexUV(obj4, 3, 0, 80);
					ObjEffect_SetVertexUV(obj6, 0,  0,  180);
					ObjEffect_SetVertexUV(obj6, 1,  300, 180);
					ObjEffect_SetVertexUV(obj6, 2, 300,  480);
					ObjEffect_SetVertexUV(obj6, 3, 0, 480);
				}
			}
			else
			{
				if(Collision_Line_Circle(Obj_GetX(Cobj)-(5*size*25/2)*cos(angle+CameraDir-90),Obj_GetY(Cobj)-(5*size*25/2)*sin(angle+CameraDir-90),Obj_GetX(Cobj)+(5*size*25/2)*cos(angle+CameraDir-90),Obj_GetY(Cobj)+(5*size*25/2)*sin(angle+CameraDir-90),5*size*45,GetEnemyInfo(0,ENEMY_X),GetEnemyInfo(0,ENEMY_Y),0))
				{
					ObjEffect_SetVertexUV(obj, 0,  340,  0);
					ObjEffect_SetVertexUV(obj, 1,  460, 0);
					ObjEffect_SetVertexUV(obj, 2, 460,  80);
					ObjEffect_SetVertexUV(obj, 3, 340, 80);
					ObjEffect_SetVertexUV(obj2, 0,  340,  0);
					ObjEffect_SetVertexUV(obj2, 1,  460, 0);
					ObjEffect_SetVertexUV(obj2, 2, 460,  80);
					ObjEffect_SetVertexUV(obj2, 3, 340, 80);
					ObjEffect_SetVertexUV(obj3, 0,  340,  0);
					ObjEffect_SetVertexUV(obj3, 1,  460, 0);
					ObjEffect_SetVertexUV(obj3, 2, 460,  80);
					ObjEffect_SetVertexUV(obj3, 3, 340, 80);
					ObjEffect_SetVertexUV(obj4, 0,  340,  0);
					ObjEffect_SetVertexUV(obj4, 1,  460, 0);
					ObjEffect_SetVertexUV(obj4, 2, 460,  80);
					ObjEffect_SetVertexUV(obj4, 3, 340, 80);
					ObjEffect_SetVertexUV(obj6, 0,  340,  180);
					ObjEffect_SetVertexUV(obj6, 1,  640, 180);
					ObjEffect_SetVertexUV(obj6, 2, 640,  480);
					ObjEffect_SetVertexUV(obj6, 3, 340, 480);
				}
				else
				{
					ObjEffect_SetVertexUV(obj, 0,  0,  0);
					ObjEffect_SetVertexUV(obj, 1,  120, 0);
					ObjEffect_SetVertexUV(obj, 2, 120,  80);
					ObjEffect_SetVertexUV(obj, 3, 0, 80);
					ObjEffect_SetVertexUV(obj2, 0,  0,  0);
					ObjEffect_SetVertexUV(obj2, 1,  120, 0);
					ObjEffect_SetVertexUV(obj2, 2, 120,  80);
					ObjEffect_SetVertexUV(obj2, 3, 0, 80);
					ObjEffect_SetVertexUV(obj3, 0,  0,  0);
					ObjEffect_SetVertexUV(obj3, 1,  120, 0);
					ObjEffect_SetVertexUV(obj3, 2, 120,  80);
					ObjEffect_SetVertexUV(obj3, 3, 0, 80);
					ObjEffect_SetVertexUV(obj4, 0,  0,  0);
					ObjEffect_SetVertexUV(obj4, 1,  120, 0);
					ObjEffect_SetVertexUV(obj4, 2, 120,  80);
					ObjEffect_SetVertexUV(obj4, 3, 0, 80);
					ObjEffect_SetVertexUV(obj6, 0,  0,  180);
					ObjEffect_SetVertexUV(obj6, 1,  300, 180);
					ObjEffect_SetVertexUV(obj6, 2, 300,  480);
					ObjEffect_SetVertexUV(obj6, 3, 0, 480);
				}
			}
			yield;	
		}
		let ad=0;
		loop(30)
		{
				ObjEffect_SetAngle(obj,0,0,angle+CameraDir+ad);
				ObjEffect_SetAngle(obj2,180,0,-angle-CameraDir+ad);
				ObjEffect_SetAngle(obj3,0,0,angle+CameraDir+180+ad);
				ObjEffect_SetAngle(obj4,0,180,-angle-CameraDir+ad);
				ad+=12;
			yield;
		}
		Obj_Delete(obj);
		Obj_Delete(obj2);
		Obj_Delete(obj3);
		Obj_Delete(obj4);
		Obj_Delete(obj5);
		Obj_Delete(obj6);
		if(FinderTimeOut){
		PlaySE(SE[0]);
		wait(10);
		DeleteSE(SE[0]);
}
}

task TFinderMode(obj)//ファインダーモードでのタスク
{
FinderScale(obj,CameraAngle);//撮影範囲を示すカメラ枠を表示
let FinderSpeed=1.8;//ファインダーモードのカメラ移動速度
Slow(1);//ファインダーモード時は1/2倍速
FinderMode=true;
FinderTimeOut=true;
let time=29;//速撮りボーナスリチャージ判定用の値
PlaySE(SE[6]);

ascent(let i in 0..30)
{
		if(GetKeyState(VK_SHOT)==KEY_PULL)
		{
			time=i;
			FinderTimeOut=false;
			Shoot(obj,i,CameraAngle);//撮影タスク、iによって撮影範囲が変わる
			break;
		}
		//以下はキー入力でカメラが動くようにするコード＆画面外にする補正用コード（ascent中）
		if((GetKeyState(VK_UP)==KEY_PUSH || GetKeyState(VK_UP)==KEY_HOLD) && GetKeyState(VK_LEFT)==KEY_FREE && GetKeyState(VK_RIGHT)==KEY_FREE)
		{
			Obj_SetPosition(obj,Obj_GetX(obj),Obj_GetY(obj)-FinderSpeed);
		}
		else if((GetKeyState(VK_DOWN)==KEY_PUSH || GetKeyState(VK_DOWN)==KEY_HOLD) && GetKeyState(VK_LEFT)==KEY_FREE && GetKeyState(VK_RIGHT)==KEY_FREE)
		{
			Obj_SetPosition(obj,Obj_GetX(obj),Obj_GetY(obj)+FinderSpeed);
		}
		else if(GetKeyState(VK_LEFT)==KEY_PUSH || GetKeyState(VK_LEFT)==KEY_HOLD)
		{
			if(GetKeyState(VK_UP)==KEY_PUSH || GetKeyState(VK_UP)==KEY_HOLD)
			{
				Obj_SetPosition(obj,Obj_GetX(obj)-FinderSpeed*(2^0.5)/2,Obj_GetY(obj)-FinderSpeed*(2^0.5)/2);
			}
			else if(GetKeyState(VK_DOWN)==KEY_PUSH || GetKeyState(VK_DOWN)==KEY_HOLD)
			{
				Obj_SetPosition(obj,Obj_GetX(obj)-FinderSpeed*(2^0.5)/2,Obj_GetY(obj)+FinderSpeed*(2^0.5)/2);
			}
			else
			{
				Obj_SetPosition(obj,Obj_GetX(obj)-FinderSpeed,Obj_GetY(obj));
			}
		}
		else if(GetKeyState(VK_RIGHT)==KEY_PUSH || GetKeyState(VK_RIGHT)==KEY_HOLD)
		{
			if(GetKeyState(VK_UP)==KEY_PUSH || GetKeyState(VK_UP)==KEY_HOLD)
			{
				Obj_SetPosition(obj,Obj_GetX(obj)+FinderSpeed*(2^0.5)/2,Obj_GetY(obj)-FinderSpeed*(2^0.5)/2);
			}
			else if(GetKeyState(VK_DOWN)==KEY_PUSH || GetKeyState(VK_DOWN)==KEY_HOLD)
			{
				Obj_SetPosition(obj,Obj_GetX(obj)+FinderSpeed*(2^0.5)/2,Obj_GetY(obj)+FinderSpeed*(2^0.5)/2);
			}
			else if(CameraAngle%360!=0)
			{
				Obj_SetPosition(obj,Obj_GetX(obj)+FinderSpeed,Obj_GetY(obj));
			}
		}
			if(Obj_GetX(obj)<=GetClipMinX)
			{
				Obj_SetX(obj,GetClipMinX);
			}
			if(Obj_GetX(obj)>=GetClipMaxX)
			{
				Obj_SetX(obj,GetClipMaxX);
			}
			if(Obj_GetY(obj)<=GetClipMinY)
			{
				Obj_SetY(obj,GetClipMinY);
			}
			if(Obj_GetY(obj)>=GetClipMaxY)
			{
				Obj_SetY(obj,GetClipMaxY);
			}
yield;
}

DeleteSE(SE[6]);

if(FinderTimeOut==true)
{
	ShootTimeOut;//撮影しなかった（時間切れ）で呼びだす
}

FinderMode=false;
Slow(0);
loop(5)//リチャージボーナスがないとき
{
if(time>10)
{
	Charge=0;
}
yield;
}
wait(30);
FinderTimeOut=false;
}

function Shoot(Cobj,time,CAngle)//弾を消したりするタスク、弾の数の判定もしている（精度悪い）
{
wait(1);//他の表示を消す時間
SaveSnapShot("snapshot\"~snapFile[photoNo]~".bmp",0,0,448,480);
yield;//スナップショットを取る時間,無いと弾消し後の写真が撮れる・・・
let dis=6*((12.5*0.84)^2+(12.5*1.5)^2)^0.5;
let finderangle=atan(0.84/1.5)+180+CameraDir-90;
	let dis2=dis;
	let size=1;
	let itemnum=0;//発生アイテム数
	let itemnumAdjust=0;//アイテム数補正

	if(!GetCommonDataDefault("BunSpell",false))
	{//専用スペル以外での簡易スコア
		let RiskPoint=80*GetEnemyShotCountEx(GetPlayerX,GetPlayerY,50,ALL);
		if(RiskPoint>=2000){RiskPoint=2000;}
		SetCommonData("RiskPoint",RiskPoint);
	}

if(time<=10)
{
	ascent(let i in 0..46)
	{
	ascent(let j in 0..26)
	{
		itemnum+=GetEnemyShotCountEx(Obj_GetX(Cobj)+dis*cos(finderangle+CAngle-270)+5*i*cos(CAngle+CameraDir)+5*j*sin(-CAngle-CameraDir),Obj_GetY(Cobj)+dis*sin(finderangle+CAngle-270)+5*i*sin(CAngle+CameraDir)+5*j*cos(-CAngle-CameraDir),5,ALL);
		itemnumAdjust=GetEnemyShotCountEx(Obj_GetX(Cobj),Obj_GetY(Cobj),125,ALL);
		DeleteEnemyShotImmediatelyInCircle(SHOT,Obj_GetX(Cobj)+dis*cos(finderangle+CAngle-270)+5*i*cos(CAngle+CameraDir)+5*j*sin(-CAngle-CameraDir),Obj_GetY(Cobj)+dis*sin(finderangle+CAngle-270)+5*i*sin(CAngle+CameraDir)+5*j*cos(-CAngle-CameraDir),5);
	}
	}
}
if(time>=11)
{
	 dis2=dis-(time-10)*(6*((12.5*0.84)^2+(12.5*1.5)^2)^0.5)/200;
	 size=dis2/dis;
	ascent(let i in 0..46)
	{
	ascent(let j in 0..26)
	{
		itemnum+=GetEnemyShotCountEx(Obj_GetX(Cobj)+dis2*cos(finderangle+CAngle-270)+5*size*i*cos(CAngle+CameraDir)+5*size*j*sin(-CAngle-CameraDir),Obj_GetY(Cobj)+dis2*sin(finderangle+CAngle-270)+5*size*i*sin(CAngle+CameraDir)+5*size*j*cos(-CAngle-CameraDir),5*size,ALL);
		itemnumAdjust=GetEnemyShotCountEx(Obj_GetX(Cobj),Obj_GetY(Cobj),125*size,ALL);
		DeleteEnemyShotImmediatelyInCircle(SHOT,Obj_GetX(Cobj)+dis2*cos(finderangle+CAngle-270)+5*size*i*cos(CAngle+CameraDir)+5*size*j*sin(-CAngle-CameraDir),Obj_GetY(Cobj)+dis2*sin(finderangle+CAngle-270)+5*size*i*sin(CAngle+CameraDir)+5*size*j*cos(-CAngle-CameraDir),5*size);
	}
	}
}
	ascent(let enemy in EnumEnemyBegin .. EnumEnemyEnd)
	{
		let enemyID = EnumEnemyGetID(enemy);
		if(Collision_Line_Circle(Obj_GetX(Cobj)-(5*size*25/2)*cos(CAngle+CameraDir-90),Obj_GetY(Cobj)-(5*size*25/2)*sin(CAngle+CameraDir-90),Obj_GetX(Cobj)+(5*size*25/2)*cos(CAngle+CameraDir-90),Obj_GetY(Cobj)+(5*size*25/2)*sin(CAngle+CameraDir-90),5*size*45,GetEnemyInfo(enemyID,ENEMY_X),GetEnemyInfo(enemyID,ENEMY_Y),0))
		{
			dummyshot(enemyID,GetEnemyInfo(enemyID,ENEMY_X),GetEnemyInfo(enemyID,ENEMY_Y));
		}
	}
if(itemnum>itemnumAdjust)
{
	itemnum=itemnumAdjust;
}
loop(itemnum)
{

	if(!GetCommonDataDefault("BunSpell",false))
	{//専用スペル以外での簡易スコア
		SetCommonData("BasePoint",GetCommonDataDefault("BasaPoint",0)+100);
	}

	let rx=rand(Obj_GetX(Cobj)-5*size*45/2,Obj_GetX(Cobj)+5*size*45/2);
	let ry=rand(Obj_GetY(Cobj)-5*size*25/2,Obj_GetY(Cobj)+5*size*25/2);
	let rdis=((rx-Obj_GetX(Cobj))^2+(ry-Obj_GetY(Cobj))^2)^0.5;
	let rangle=atan2(ry-Obj_GetY(Cobj),rx-Obj_GetX(Cobj));
	ItemCreate(Cobj,photoNo,60,75,Obj_GetX(Cobj)+rdis*cos(rangle+CAngle+CameraDir),Obj_GetY(Cobj)+rdis*sin(rangle+CAngle+CameraDir));
}

	yield;
	if(BossCapture==true)
	{	
		Photo(photoNo,Cobj,CAngle,finderangle,dis2,size);
		photoNo++;
		BossCapture=false;
	}
	else
	{
		FalsePhoto(Cobj,CAngle,finderangle,dis2,size);
	}
	SetCommonData("AllPhoto",GetCommonDataDefault("AllPhoto",0)+1);
	PlaySE(SE[4]);
TimeSlowEffect;

}

task Photo(No,Cobj,CAngle,finderangle,dis2,size)//成功時の写真を取ってから収めるまでの動作。
{
	let imgPhoto = "snapshot\"~snapFile[photoNo]~".bmp";
		LoadGraphic(imgPhoto);
		let scax=1;
		let scay=1;
		let CameraRD=60;
		let OriAngle1=atan2(GetClipMinX-Obj_GetX(Cobj),GetClipMinY-Obj_GetY(Cobj));
		let OriDis1=((GetClipMinX-Obj_GetX(Cobj))^2+((GetClipMinY-Obj_GetY(Cobj))^2))^0.5;
		let OriAngle2=atan2(GetClipMaxX-Obj_GetX(Cobj),GetClipMinY-Obj_GetY(Cobj));
		let OriDis2=((GetClipMaxX-Obj_GetX(Cobj))^2+((GetClipMinY-Obj_GetY(Cobj))^2))^0.5;
		let OriAngle3=atan2(GetClipMaxX-Obj_GetX(Cobj),GetClipMaxY-Obj_GetY(Cobj));
		let OriDis3=((GetClipMaxX-Obj_GetX(Cobj))^2+((GetClipMaxY-Obj_GetY(Cobj))^2))^0.5;
		let OriAngle4=atan2(GetClipMinX-Obj_GetX(Cobj),GetClipMaxY-Obj_GetY(Cobj));
		let OriDis4=((GetClipMinX-Obj_GetX(Cobj))^2+((GetClipMaxY-Obj_GetY(Cobj))^2))^0.5;

		let obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgPhoto);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
//X,Yはカメラの４頂点の座標。PX,PYはカメラの中心から頂点までの成分の絶対値。
//		let X=[Obj_GetX(Cobj)+dxdy(0,0,dis2,finderangle,CAngle,size),Obj_GetX(Cobj)+dxdy(45,0,dis2,finderangle,CAngle,size),Obj_GetX(Cobj)+dxdy(45,34,dis2,finderangle,CAngle,size), Obj_GetX(Cobj)+dxdy(0,34,dis2,finderangle,CAngle,size), ];
//		let Y=[Obj_GetY(Cobj)+dxdy2(0,0,dis2,finderangle,CAngle,size),Obj_GetY(Cobj)+dxdy2(45,0,dis2,finderangle,CAngle,size),  Obj_GetY(Cobj)+dxdy2(45,34,dis2,finderangle,CAngle,size), Obj_GetY(Cobj)+dxdy2(0,34,dis2,finderangle,CAngle,size)];
		let X=[Obj_GetX(Cobj)+dxdy(0,0,dis2,finderangle,CAngle,size),Obj_GetX(Cobj)+dxdy(45,0,dis2,finderangle,CAngle,size),Obj_GetX(Cobj)+dxdy(45,25,dis2,finderangle,CAngle,size), Obj_GetX(Cobj)+dxdy(0,25,dis2,finderangle,CAngle,size), ];
		let Y=[Obj_GetY(Cobj)+dxdy2(0,0,dis2,finderangle,CAngle,size),Obj_GetY(Cobj)+dxdy2(45,0,dis2,finderangle,CAngle,size),  Obj_GetY(Cobj)+dxdy2(45,25,dis2,finderangle,CAngle,size), Obj_GetY(Cobj)+dxdy2(0,25,dis2,finderangle,CAngle,size)];
		let PX=5*size*45/2;
		let PY=5*size*25/2;
//写真の切り取り方を決定するタスク。
		let CDAngle=CameraDir;
		ShootRange(obj,CAngle,CDAngle,X,Y,PX,PY,OriAngle1,OriDis1,OriAngle2,OriDis2,OriAngle3,OriDis3,OriAngle4,OriDis4);


		ObjEffect_SetScale(obj, scax,scay);
		ObjEffect_SetAngle(obj,0,0,CAngle+CameraDir);
		ObjEffect_SetLayer(obj,8);
		Obj_SetPosition(obj,Obj_GetX(Cobj),Obj_GetY(Cobj));

		let DX=GetClipMaxX+40+65*((photoNo%10)%3);
		let DY=GetCenterY+50+65*trunc((photoNo%10)/3);
		let posX=Obj_GetX(obj);
		let posY=Obj_GetY(obj);
		let loopnum=10;

		if(GetCommonDataDefault("BunSpell",false)==true)
		{
			loopnum=30;
		}

		let SnapAngle=0;
		let SnapSize=0.2;
		if(GetCommonDataDefault("BunSpell",false)==true)
		{
			SnapSize=0.4;
			if((photoNo%10)<=4)
			{
				DX=GetClipMaxX+70;
				DY=GetCenterY-170+(photoNo%10)*85;
			}
			else
			{
				DX=GetClipMaxX+155;
				DY=GetCenterY-170+((photoNo%10)-5)*85;
			}
			
		}

		AddShootingScore("HATATE",Cobj,CAngle,PX,PY,No);//スコア計算文とはたてで違うのはセルフショット判定
		Successed;//Successed!!と表示する
///////////////////////////////////////////////////////////////////////////////////
		let BGscax2=1.00;
		let BGscay2=1.00;
	//	let finderangle9=atan(1.15/1.5)+180+CameraDir-90;
		let obj9=Obj_Create(OBJ_EFFECT);
				ObjEffect_SetTexture(obj9, CameraBack2);
		ObjEffect_SetPrimitiveType(obj9, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj9, ADD); 
	//	ObjEffect_SetRenderState(obj9, MULTIPLY); 
		ObjEffect_CreateVertex(obj9, 16);

/*		ObjEffect_SetVertexXY(obj9, 0, -116, -69);
		ObjEffect_SetVertexXY(obj9, 1, -58,  -69);
		ObjEffect_SetVertexXY(obj9, 2, 0, -69);
		ObjEffect_SetVertexXY(obj9, 3,  58,  -69);
		ObjEffect_SetVertexXY(obj9, 4, 116, -69);
		ObjEffect_SetVertexXY(obj9, 5, 116,  -34);
		ObjEffect_SetVertexXY(obj9, 6, 116, 0);
		ObjEffect_SetVertexXY(obj9, 7,  116,  34);
		ObjEffect_SetVertexXY(obj9, 8, 116, 69);
		ObjEffect_SetVertexXY(obj9, 9, 58,  69);
		ObjEffect_SetVertexXY(obj9, 10, 0, 69);
		ObjEffect_SetVertexXY(obj9, 11,  -58,  69);
		ObjEffect_SetVertexXY(obj9, 12, -116, 69);
		ObjEffect_SetVertexXY(obj9, 13, -116,  34);
		ObjEffect_SetVertexXY(obj9, 14, -116, 0);
		ObjEffect_SetVertexXY(obj9, 15,  -116,  -34);
*/
		let VertexX=58*size;
		let VertexY=32*size;
		ObjEffect_SetVertexXY(obj9, 0, -VertexX*2, -VertexY*2);
		ObjEffect_SetVertexXY(obj9, 1, -VertexX,  -VertexY*2);
		ObjEffect_SetVertexXY(obj9, 2, 0, -VertexY*2);
		ObjEffect_SetVertexXY(obj9, 3,  VertexX,  -VertexY*2);
		ObjEffect_SetVertexXY(obj9, 4, VertexX*2, -VertexY*2);
		ObjEffect_SetVertexXY(obj9, 5, VertexX*2,  -VertexY);
		ObjEffect_SetVertexXY(obj9, 6, VertexX*2, 0);
		ObjEffect_SetVertexXY(obj9, 7,  VertexX*2,  VertexY);
		ObjEffect_SetVertexXY(obj9, 8, VertexX*2, VertexY*2);
		ObjEffect_SetVertexXY(obj9, 9, VertexX,  VertexY*2);
		ObjEffect_SetVertexXY(obj9, 10, 0, VertexY*2);
		ObjEffect_SetVertexXY(obj9, 11,  -VertexX,  VertexY*2);
		ObjEffect_SetVertexXY(obj9, 12, -VertexX*2, VertexY*2);
		ObjEffect_SetVertexXY(obj9, 13, -VertexX*2,  VertexY);
		ObjEffect_SetVertexXY(obj9, 14, -VertexX*2, 0);
		ObjEffect_SetVertexXY(obj9, 15,  -VertexX*2,  -VertexY);

		ObjEffect_SetVertexUV(obj9, 0,  0,  0);
		ObjEffect_SetVertexUV(obj9, 1,  100, 0);
		ObjEffect_SetVertexUV(obj9, 2, 200,  0);
		ObjEffect_SetVertexUV(obj9, 3, 300, 0);
		ObjEffect_SetVertexUV(obj9, 4, 401,  0);
		ObjEffect_SetVertexUV(obj9, 5, 401,  100);
		ObjEffect_SetVertexUV(obj9, 6, 401, 200);
		ObjEffect_SetVertexUV(obj9, 7,  401,  300);
		ObjEffect_SetVertexUV(obj9, 8,  401, 401);
		ObjEffect_SetVertexUV(obj9, 9, 300,  401);
		ObjEffect_SetVertexUV(obj9, 10, 200, 401);
		ObjEffect_SetVertexUV(obj9, 11,  100,  401);
		ObjEffect_SetVertexUV(obj9, 12,  0, 401);
		ObjEffect_SetVertexUV(obj9, 13, 0,  300);
		ObjEffect_SetVertexUV(obj9, 14, 0, 200);
		ObjEffect_SetVertexUV(obj9, 15, 0, 100);

		ObjEffect_SetScale(obj9, BGscax2,BGscay2);
		ObjEffect_SetAngle(obj9,0,0,CAngle+CameraDir);
		ObjEffect_SetLayer(obj9,8);
		Obj_SetPosition(obj9,Obj_GetX(Cobj),Obj_GetY(Cobj));
			ascent(let i in 0..16)
			{
				ObjEffect_SetVertexColor(obj9,i,150,255,255,255);
			}
	ascent(let j in 0..4)
	{
		ascent(let i in 0..5)
		{
			if((X[j]*(5-i)+X[(j+1)%4]*i)/5<GetClipMinX || (Y[j]*(5-i)+Y[(j+1)%4]*i)/5<GetClipMinY || (X[j]*(5-i)+X[(j+1)%4]*i)/5>GetClipMaxX || (Y[j]*(5-i)+Y[(j+1)%4]*i)/5>GetClipMaxY)
			{
				ObjEffect_SetVertexColor(obj9,j*4+i,0,50,50,50);
			}
		}
	}
//////////////////////////////////////////////////////////////////////////

		loop(loopnum)
		{
			Obj_SetPosition(obj,Obj_GetX(obj)+(DX-posX)/loopnum,Obj_GetY(obj)+(DY-posY)/loopnum);
			ObjEffect_SetScale(obj, scax,scay);
			scax-=(1-SnapSize)/loopnum;
			scay-=(1-SnapSize)/loopnum;
			SnapAngle+=360/loopnum;
			ObjEffect_SetAngle(obj,0,0,CAngle+CameraDir+SnapAngle);

			Obj_SetPosition(obj9,Obj_GetX(obj9)+(DX-posX)/loopnum,Obj_GetY(obj9)+(DY-posY)/loopnum);
			ObjEffect_SetScale(obj9, BGscax2,BGscay2);
			BGscax2-=(1-SnapSize)/loopnum;
			BGscay2-=(1-SnapSize)/loopnum;
			ObjEffect_SetAngle(obj9,0,0,CAngle+CameraDir+SnapAngle);

			yield;
		}
			scax+=(1-SnapSize)/loopnum;
			scay+=(1-SnapSize)/loopnum;
			BGscax2-=(1-SnapSize)/loopnum;
			BGscay2-=(1-SnapSize)/loopnum;
		PlaySE(SE[1]);

PhotoSelectAndEraze(obj,obj9,No,DX,DY, scax,scay);
//PhotoSelectAndEraze(obj9,No,DX,DY, scax,scay);
loop
{
	if(GetCommonDataDefault("DetailShooting",false)==true)
	{
		ascent(let i in 0..16)
		{
			ObjEffect_SetVertexColor(obj,i,0,255,255,255);
			ObjEffect_SetVertexColor(obj9,i,0,255,255,255);
		}
	}
	else
	{
ShootRange(obj,CAngle,CDAngle,X,Y,PX,PY,OriAngle1,OriDis1,OriAngle2,OriDis2,OriAngle3,OriDis3,OriAngle4,OriDis4);
		ascent(let i in 0..4)
		{
			ObjEffect_SetVertexColor(obj,i,255,255,255,255);
		}
		ascent(let i in 0..16)
		{
			ObjEffect_SetVertexColor(obj9,i,150,255,255,255);
		}
		ascent(let j in 0..4)
		{
			ascent(let i in 0..5)
			{
				if((X[j]*(5-i)+X[(j+1)%4]*i)/5<GetClipMinX || (Y[j]*(5-i)+Y[(j+1)%4]*i)/5<GetClipMinY || (X[j]*(5-i)+X[(j+1)%4]*i)/5>GetClipMaxX || (Y[j]*(5-i)+Y[(j+1)%4]*i)/5>GetClipMaxY)
				{
					ObjEffect_SetVertexColor(obj9,j*4+i,0,50,50,50);
				}
			}
		}
	}

yield;
}
}

task PhotoSelectAndEraze(obj,obj9,No,DX,DY, scax,scay)
{
		while(photoNo<No+11)
		{//１１枚以上になったら１枚目から順に破棄。専用スペルではまず使わないはず。
			if(GetCommonDataDefault("ShootingEnd",false)==true)
			{
				PhotoSelect(obj,obj9,No,DX,DY, scax,scay);
			}
			if(GetCommonDataDefault("PhotoEraze",false)==true)
			{
				Obj_Delete(obj);
				break;
			}
			yield;
		}
}

task FalsePhoto(Cobj,CAngle,finderangle,dis2,size)//失敗時の写真を取ってから捨てるまでの動作。
{
	let imgPhoto = "snapshot\"~snapFile[photoNo]~".bmp";
		LoadGraphic(imgPhoto);
		let scax=1;
		let scay=1;

		let X=[Obj_GetX(Cobj)+dxdy(0,0,dis2,finderangle,CAngle,size),Obj_GetX(Cobj)+dxdy(45,0,dis2,finderangle,CAngle,size),Obj_GetX(Cobj)+dxdy(45,34,dis2,finderangle,CAngle,size), Obj_GetX(Cobj)+dxdy(0,34,dis2,finderangle,CAngle,size), ];
		let Y=[Obj_GetY(Cobj)+dxdy2(0,0,dis2,finderangle,CAngle,size),Obj_GetY(Cobj)+dxdy2(45,0,dis2,finderangle,CAngle,size),  Obj_GetY(Cobj)+dxdy2(45,34,dis2,finderangle,CAngle,size), Obj_GetY(Cobj)+dxdy2(0,34,dis2,finderangle,CAngle,size)];
		let PX=5*size*45/2;
		let PY=5*size*25/2;
		let OriAngle1=atan2(GetClipMinX-Obj_GetX(Cobj),GetClipMinY-Obj_GetY(Cobj));
		let OriDis1=((GetClipMinX-Obj_GetX(Cobj))^2+((GetClipMinY-Obj_GetY(Cobj))^2))^0.5;
		let OriAngle2=atan2(GetClipMaxX-Obj_GetX(Cobj),GetClipMinY-Obj_GetY(Cobj));
		let OriDis2=((GetClipMaxX-Obj_GetX(Cobj))^2+((GetClipMinY-Obj_GetY(Cobj))^2))^0.5;
		let OriAngle3=atan2(GetClipMaxX-Obj_GetX(Cobj),GetClipMaxY-Obj_GetY(Cobj));
		let OriDis3=((GetClipMaxX-Obj_GetX(Cobj))^2+((GetClipMaxY-Obj_GetY(Cobj))^2))^0.5;
		let OriAngle4=atan2(GetClipMinX-Obj_GetX(Cobj),GetClipMaxY-Obj_GetY(Cobj));
		let OriDis4=((GetClipMinX-Obj_GetX(Cobj))^2+((GetClipMaxY-Obj_GetY(Cobj))^2))^0.5;

		let obj=Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgPhoto);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
	//	ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		let CDAngle=CameraDir;
		ShootRange(obj,CAngle,CDAngle,X,Y,PX,PY,OriAngle1,OriDis1,OriAngle2,OriDis2,OriAngle3,OriDis3,OriAngle4,OriDis4);

		ObjEffect_SetScale(obj, scax,scay);
		ObjEffect_SetAngle(obj,0,0,CAngle+CameraDir);
		ObjEffect_SetLayer(obj,8);
		Obj_SetPosition(obj,Obj_GetX(Cobj),Obj_GetY(Cobj));

		let DX=Obj_GetX(Cobj);
		let DY=Obj_GetY(Cobj)+60;
		let posX=Obj_GetX(obj);
		let posY=Obj_GetY(obj);
		let loopnum=10;
		if(GetCommonDataDefault("BunSpell",false)==true)
		{
			loopnum=30;
		}
		AddShootingScore("AYA",Cobj,CAngle,PX,PY,-5);//スコア計算文とはたてで違うのはセルフショット判定
		SetCommonData("PlayerPhotoTimeStop",true);
		let SnapAngle=0;
		loop(loopnum)
		{
			Obj_SetPosition(obj,Obj_GetX(obj)+(DX-posX)/loopnum,Obj_GetY(obj)+(DY-posY)/loopnum);
			ObjEffect_SetScale(obj, scax,scay);
			scax-=4/5/loopnum;
			scay-=4/5/loopnum;
			SnapAngle+=360/loopnum;
			ObjEffect_SetAngle(obj,0,0,CAngle+CameraDir+SnapAngle);
			yield;
		}
		Obj_Delete(obj);
		PlaySE(SE[0]);
		Failed;
		DeleteGraphic(imgPhoto);
		wait(10);
		DeleteSE(SE[0]);
		SetCommonData("BasePoint",0);
}


task CameraAngleChange//キー入力によってカメラ角が変わるタスクabsoluteとかはブレ防止用
{
let angle;
loop
{
if(FinderMode==false)
{
	if(GetCommonDataDefault("BunSpell",false)==true)
	{
	angle=atan2(GetEnemyInfo(1,ENEMY_Y)-GetPlayerY,GetEnemyInfo(1,ENEMY_X)-GetPlayerX);
	}
	else
	{
	angle=atan2(GetEnemyInfo(0,ENEMY_Y)-GetPlayerY,GetEnemyInfo(0,ENEMY_X)-GetPlayerX);
	}
	loop(10)
	{
			if((absolute(sin(CameraAngle-angle))>=0.01 || sin(CameraAngle%360-angle)<=0))
			{
				if(sin(CameraAngle-angle)>=0)
				{
					CameraAngle-=0.5;
				}
				else
				{
					CameraAngle+=0.5;
				}
			}	
	}
}
else
{
	while(FinderMode==true){yield;}
	wait(60);
}
if(CameraAngle>=360){CameraAngle=0.001;}
if(CameraAngle<=0){CameraAngle=360;}
yield;
}
}
#include_script".\..\txt\Pdraw.txt"//装填率や可能不可能表示
#include_script".\..\txt\Cdraw.txt"//.自機魔方陣や当たり判定
#include_script".\..\txt\data.txt"//wait関数のみ
#include_script".\..\txt\CommonData.txt"
#include_script".\..\txt\VariableCommonData.txt"
#include_script".\Config.txt"
}
