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

				CreateSubShot(opX[1]+5,opY[1],270,2.5,3);
				CreateSubShot(opX[1]-5,opY[1],270,2.5,3);

				CreateSubShot(opX[2]+5,opY[2],270,2.5,3);
				CreateSubShot(opX[2]-5,opY[2],270,2.5,3);

				CreateSubShot(opX[3]+5,opY[3],270,2.5,3);
				CreateSubShot(opX[3]-5,opY[3],270,2.5,3);
			}
		}
		else
		{
			if(shotCount%5 == 0)
			{
		/*		if(Power>=1000)
				{
				CreateSubShot(opX[0]+5,opY[0],272.5,2.5,2);
				CreateSubShot(opX[0]-5,opY[0],267.5,2.5,2);
				}
				if(Power>=2000)
				{
				CreateSubShot(opX[1]+5,opY[1],272.5,2.5,2);
				CreateSubShot(opX[1]-5,opY[1],267.5,2.5,2);
				}
				if(Power>=3000)
				{
				CreateSubShot(opX[2]+5,opY[2],272.5,2.5,2);
				CreateSubShot(opX[2]-5,opY[2],267.5,2.5,2);
				}
				if(Power>=4000)
				{
				CreateSubShot(opX[3]+5,opY[3],272.5,2.5,2);
				CreateSubShot(opX[3]-5,opY[3],267.5,2.5,2);
				}
		*/
				CreateSubShot(opX[0]+5,opY[0],272.5,2.5,2);
				CreateSubShot(opX[0]-5,opY[0],267.5,2.5,2);

				CreateSubShot(opX[1]+5,opY[1],272.5,2.5,2);
				CreateSubShot(opX[1]-5,opY[1],267.5,2.5,2);

				CreateSubShot(opX[2]+5,opY[2],272.5,2.5,2);
				CreateSubShot(opX[2]-5,opY[2],267.5,2.5,2);

				CreateSubShot(opX[3]+5,opY[3],272.5,2.5,2);
				CreateSubShot(opX[3]-5,opY[3],267.5,2.5,2);

			}
		}

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

task CreateSubShot(let dx,let dy,let angle,let damage,let grf)
{
	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,grf);
	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,grf);
			AddScore(bonuspoint/200);
		}
		yield;
	}
}

task HitSubShotEffect(let x,let y,let angle,let grf)
{
let dx=0;
let dy=0;
let speed=10;
let alpha=155;
let adjust;
if(grf==2)
{
	adjust=0;
}
if(grf==3)
{
	adjust=15;
}
		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, -5, -24);
		ObjEffect_SetVertexXY(obj, 1, 5,  -24);
		ObjEffect_SetVertexXY(obj, 2, 5, 24);
		ObjEffect_SetVertexXY(obj, 3,  -5,  24);
		
		ObjEffect_SetVertexUV(obj, 0,  24+adjust,  3);
		ObjEffect_SetVertexUV(obj, 1,  35+adjust, 3);
		ObjEffect_SetVertexUV(obj, 2, 35+adjust,  51);
		ObjEffect_SetVertexUV(obj, 3, 24+adjust, 51);

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

task HitSubShotLowEffect(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);
}