
task SubShot//オプションからのショット。高速、低速で変化する。
{
loop
{
		if((GetKeyState(VK_SHOT)==KEY_PUSH || GetKeyState(VK_SHOT)==KEY_HOLD) && shotCount==-1 && HmspOn==0)
		{
			shotCount = 0;
		}
		if(GetKeyState(VK_SLOWMOVE)==KEY_PUSH || GetKeyState(VK_SLOWMOVE)==KEY_HOLD)
		{
			if(shotCount%5 == 0)
			{
				if(Power>=1000 && Power<2000)
				{
				CreateSubShot(opX[0], opY[0],280,3.0);
				CreateSubShot(opX[0], opY[0],260,3.0);
				}
				if(Power>=2000 && Power<3000)
				{
				CreateSubShot(opX[0], opY[0],267.5,3.0);
				CreateSubShot(opX[0], opY[0],260,3.0);
				CreateSubShot(opX[1], opY[1],272.5,3.0);
				CreateSubShot(opX[1], opY[1],280,3.0);
				}
				if(Power>=3000 && Power<4000)
				{
				CreateSubShot(opX[0], opY[0],265,3.0);
				CreateSubShot(opX[0], opY[0],260,3.0);
				CreateSubShot(opX[1], opY[1],275,3.0);
				CreateSubShot(opX[1], opY[1],280,3.0);
				CreateSubShot(opX[2], opY[2],272.5,3.0);
				CreateSubShot(opX[2], opY[2],267.5,3.0);
				}
				if(Power>=4000)
				{
				CreateSubShot(opX[0], opY[0],271.5,3.0);
				CreateSubShot(opX[0], opY[0],266.5,3.0);
				CreateSubShot(opX[1], opY[1],268.5,3.0);
				CreateSubShot(opX[1], opY[1],273.5,3.0);
				CreateSubShot(opX[2], opY[2],265,3.0);
				CreateSubShot(opX[2], opY[2],262.5,3.0);
				CreateSubShot(opX[3], opY[3],275,3.0);
				CreateSubShot(opX[3], opY[3],277.5,3.0);
				}
			}
		}
		else
		{
			if(shotCount%5 == 0)
			{
				if(Power>=1000 && Power<2000)
				{
				CreateSubShot(opX[0], opY[0],285,3.0);
				CreateSubShot(opX[0], opY[0],255,3.0);
				}
				if(Power>=2000 && Power<3000)
				{
				CreateSubShot(opX[0], opY[0],272.5,3.0);
				CreateSubShot(opX[0], opY[0],255,3.0);
				CreateSubShot(opX[1], opY[1],267.5,3.0);
				CreateSubShot(opX[1], opY[1],285,3.0);
				}
				if(Power>=3000 && Power<4000)
				{
				CreateSubShot(opX[0], opY[0],272.5,2.5);
				CreateSubShot(opX[0], opY[0],265,2.5);
				CreateSubShot(opX[0], opY[0],257.5,2.5);
				CreateSubShot(opX[0], opY[0],252.5,2.5);
				CreateSubShot(opX[1], opY[1],267.5,2.5);
				CreateSubShot(opX[1], opY[1],275,2.5);
				CreateSubShot(opX[1], opY[1],282.5,2.5);
				CreateSubShot(opX[1], opY[1],287.5,2.5);
				CreateSubShot(opX[2], opY[2],55,3.0);
				CreateSubShot(opX[2], opY[2],125,3.0);
				CreateSubShot(opX[2], opY[2],65,3.0);
				CreateSubShot(opX[2], opY[2],115,3.0);
				}
				if(Power>=4000)
				{
				CreateSubShot(opX[0], opY[0],272.5,2.5);
				CreateSubShot(opX[0], opY[0],265,2.5);
				CreateSubShot(opX[0], opY[0],257.5,2.5);
				CreateSubShot(opX[0], opY[0],252.5,2.5);
				CreateSubShot(opX[1], opY[1],267.5,2.5);
				CreateSubShot(opX[1], opY[1],275,2.5);
				CreateSubShot(opX[1], opY[1],282.5,2.5);
				CreateSubShot(opX[1], opY[1],287.5,2.5);
				CreateSubShot(opX[2], opY[2],125,3.0);
				CreateSubShot(opX[2], opY[2],90,3.0);
				CreateSubShot(opX[2], opY[2],115,3.0);
				CreateSubShot(opX[2], opY[2],85,3.0);
				CreateSubShot(opX[3], opY[3],55,3.0);
				CreateSubShot(opX[3], opY[3],90,3.0);
				CreateSubShot(opX[3], opY[3],65,3.0);
				CreateSubShot(opX[3], opY[3],95,3.0);
				}

			}
		}

		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,4);
	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, -12, -4);
		ObjEffect_SetVertexXY(obj, 1, 12,  -4);
		ObjEffect_SetVertexXY(obj, 2, 12, 4);
		ObjEffect_SetVertexXY(obj, 3,  -12,  4);
		
		ObjEffect_SetVertexUV(obj, 0,  4,  72);
		ObjEffect_SetVertexUV(obj, 1,  28, 72);
		ObjEffect_SetVertexUV(obj, 2, 28,  81);
		ObjEffect_SetVertexUV(obj, 3, 4, 81);

		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);
}