task Orrery(x,y, speed, angle, damage, pene, type)
{
	if(IsPermitPlayerShot==false){return;}
	if(OrreryNum>=OrreryNumMax){return;}
	let ExRange=1;
	let ShotNum=100;
	let RadiusPlus=50;
	if(SpiritPoint>=10*SpiritReduce)
	{
		SpiritPoint-=10*SpiritReduce;
	}
	else
	{
		SpiritPointLack;
		return;
	}
	Obj_PlaySE(GetCurrentScriptDirectory~"../se/se_maoudamashii_element_fire09.wav");
	OrreryBit(0);
	OrreryBit(120);
	OrreryBit(240);
	ShotForbitTime(30);

	task OrreryBit(angle)
	{

	OrreryNum+=0.5;

	let Radius=0;
	let damage=Status_MagicPower*0.35;
	let Bdamage=Status_MagicPower*0.35;
	let obj = ObjShot_Create(OBJ_SHOT);
	ObjMove_SetX(obj, x);//x座標設定
	ObjMove_SetY(obj, y);//y座標設定;
	ObjMove_SetSpeed(obj, speed);//x座標設定
	ObjMove_SetAngle(obj, angle);//y座標設定;
	ObjShot_SetGraphic(obj, ShotNum);//画像設定
	ObjShot_SetDamage(obj, damage);//ダメージを設定
	ObjShot_SetPenetration(obj, 1000);//貫通力は適当に大きく
	ObjShot_Regist(obj);
	ObjRender_SetColor(obj,255,128,128);
	ObjRender_SetAlpha(obj,255);
	ObjRender_SetScaleXYZ(obj,1.5,1.5,1.5);

	let S_count=0;
	loop(30)
	{
		if(S_count%5==0){damage=Bdamage;}
		else{damage=0;}
		ObjShot_SetDamage(obj, damage);
		ShotEffect(ObjMove_GetX(obj),ObjMove_GetY(obj));
		ObjMove_SetX(obj, GetPlayerX+Radius*cos(angle));//x座標設定
		ObjMove_SetY(obj, GetPlayerY+Radius*sin(angle));//y座標設定;
		Radius+=RadiusPlus/30;
		angle+=6;
		S_count+=1;
		yield;
	}
	loop(300)
	{
		if(S_count%5==0){damage=Bdamage;}
		else{damage=0;}
		ObjShot_SetDamage(obj, damage);
		ShotEffect(ObjMove_GetX(obj),ObjMove_GetY(obj));
		ObjMove_SetX(obj, GetPlayerX+Radius*cos(angle));//x座標設定
		ObjMove_SetY(obj, GetPlayerY+Radius*sin(angle));//y座標設定;
		angle+=6;
		S_count+=1;
		yield;
	}
	loop(30)
	{
		if(S_count%5==0){damage=Bdamage;}
		else{damage=0;}
		ObjShot_SetDamage(obj, damage);
		ShotEffect(ObjMove_GetX(obj),ObjMove_GetY(obj));
		ObjMove_SetX(obj, GetPlayerX+Radius*cos(angle));//x座標設定
		ObjMove_SetY(obj, GetPlayerY+Radius*sin(angle));//y座標設定;
		Radius-=RadiusPlus/30;
		angle+=6;
		S_count+=1;
		yield;
	}
	Obj_Delete(obj);
	OrreryNum-=0.5;

	task ShotEffect(x,y)
	{
		let imgWhite = GetCurrentScriptDirectory() ~ "../img/effects.png";
		let obje = ObjPrim_Create(OBJ_PRIMITIVE_2D);
		ObjPrim_SetTexture(obje, imgWhite);
		ObjPrim_SetPrimitiveType(obje, PRIMITIVE_TRIANGLEFAN);
		ObjPrim_SetVertexCount(obje, 4);
		ObjRender_SetBlendType(obje, BLEND_ADD_RGB);
		Obj_SetRenderPriorityI(obje,20);
		ObjRender_SetAngleZ(obje,0);

		ObjPrim_SetVertexPosition(obje, 0, -64, -64, 0);
		ObjPrim_SetVertexPosition(obje, 1, 64, -64, 0);
		ObjPrim_SetVertexPosition(obje, 2, 64, 64, 0);
		ObjPrim_SetVertexPosition(obje, 3,-64, 64, 0);

		ObjPrim_SetVertexUVT(obje, 0, 0, 0);
		ObjPrim_SetVertexUVT(obje, 1, 128, 0);
		ObjPrim_SetVertexUVT(obje, 2, 128, 128);
		ObjPrim_SetVertexUVT(obje, 3, 0, 128);

		let ox=GetPlayerX;
		let oy=GetPlayerY;
		let Speed=rand(2,10);
		let Angle=rand(0,360);

		let Scale=0.2*ExRange;

		let Xangle=rand(0,360)*0;
		let Yangle=rand(0,360)*0;
		let Zangle=rand(0,360)*0;

		let XanglePlus=rand(-10,10);
		let YanglePlus=rand(-10,10);
		let ZanglePlus=rand(-10,10);

		ObjRender_SetPosition(obje,ox,oy,0);

		let Alpha=1;
		ObjRender_SetColor(obje,128,64,64*Alpha);

		ObjRender_SetPosition(obje,x,y,0);

		loop(30)
		{
			let sr=Obj_GetValue(GetPlayerObjectID,"Move_Right");
			let sl=Obj_GetValue(GetPlayerObjectID,"Move_Left");
			let su=Obj_GetValue(GetPlayerObjectID,"Move_Up");
			let sd=Obj_GetValue(GetPlayerObjectID,"Move_Down");
			if(sr!=0)
			{
				ObjRender_SetX(obje, ObjRender_GetX(obje)-sr);
			}
			if(sl!=0)
			{
				ObjRender_SetX(obje, ObjRender_GetX(obje)-sl);
			}
			if(su!=0)
			{
				ObjRender_SetY(obje, ObjRender_GetY(obje)-su);
			}
			if(sd!=0)
			{
				ObjRender_SetY(obje, ObjRender_GetY(obje)-sd);
			}
			ObjRender_SetAngleXYZ(obje,Xangle,Yangle,Zangle);
			ObjRender_SetScaleXYZ(obje,Scale,Scale,Scale);
			ObjRender_SetColor(obje,255*Alpha,64*Alpha,64*Alpha);
			Alpha-=1/30;
		//	Scale-=1/30;
			Xangle+=XanglePlus;
			Yangle+=YanglePlus;
			Zangle+=ZanglePlus;
			yield;
		}

		Obj_Delete(obje);
	
	}

	}


}