
task SubShot//オプションからのショット。高速、低速で変化する。
{
loop
{
		if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && shotCount==-1 && HmspOn==0)
		{
			shotCount = 0;
		}
			if(shotCount%5 == 0)
			{
				if(Power>=1000)
				{
				CreateSubShot(opX[0], opY[0],270,4.5);
				}
				if(Power>=2000)
				{
				CreateSubShot(opX[1], opY[1],270,4.5);
				}
				if(Power>=3000)
				{
				CreateSubShot(opX[2], opY[2],270,4.5);
				}
				if(Power>=4000)
				{
				CreateSubShot(opX[3], opY[3],270,4.5);
				}
			}

		if(shotCount >= 0)
		{
			shotCount++;
		}
		if(shotCount == 10)
		{
			shotCount=-1;
		}
yield;
}
}

task CreateSubShot(let dx,let dy,let angle,let damage)
{
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetPosition(obj,dx,dy);
	Obj_SetSpeed(obj,15);
	Obj_SetAngle(obj,angle);
	ObjShot_SetDamage(obj,damage);
	ObjShot_SetPenetration(obj,1);
	ObjShot_SetGraphic(obj,124);
	Obj_SetAlpha(obj,155);
	if(OnBomb)
	{
		ObjShot_SetDamage(obj,damage/2);
	}
	else
	{
		ObjShot_SetDamage(obj,damage);
	}

	while(!Obj_BeDeleted(obj))
	{
		if(Obj_IsIntersected(obj))
		{
			HitSubShotEffect(Obj_GetX(obj),Obj_GetY(obj),angle);
		}
		yield;
	}
}

task HitSubShotEffect(let x,let y,let angle)
{
let dx=0;
let dy=0;
let speed=7.5;
let alpha=155;
		let scax=1.0;
		let scay=1.0;
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imgSpell);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_SetRenderState(obj, ADD); 
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexXY(obj, 0, -10, -10);
		ObjEffect_SetVertexXY(obj, 1, 10,  -10);
		ObjEffect_SetVertexXY(obj, 2, 10, 10);
		ObjEffect_SetVertexXY(obj, 3,  -10,  10);
		
		ObjEffect_SetVertexUV(obj, 0,  60,  271);
		ObjEffect_SetVertexUV(obj, 1,  79, 271);
		ObjEffect_SetVertexUV(obj, 2, 79,  291);
		ObjEffect_SetVertexUV(obj, 3, 60, 291);

		ObjEffect_SetVertexColor(obj,0,alpha,255,255,255);
		ObjEffect_SetVertexColor(obj,1,alpha,255,255,255);
		ObjEffect_SetVertexColor(obj,2,alpha,255,255,255);
		ObjEffect_SetVertexColor(obj,3,alpha,255,255,255);

		Obj_SetPosition(obj,x,y);
		ObjEffect_SetAngle(obj,0,0,angle+90);
		loop(10)
		{
		scax-=0.1;
		scay-=0.1;
		Obj_SetPosition(obj,x+dx*cos(angle),y+dy*sin(angle));
		ObjEffect_SetScale(obj, scax,scay);
		dx+=speed;
		dy+=speed;
		yield;
		}
		Obj_Delete(obj);
}