//󓃃r[(IDԂ)
// 1: XW
//	   2: YW
//	   4: px
//	   5: F(0`7ԁ`A8F)
//	   6: x
//	   7: ł܂ł̎(t[w)
	function Houtou(x, y, angle, color, delay, delTime) {
		let Obj    = Obj_Create(OBJ_EFFECT);

		Houtou_Beam(Obj, x, y, angle, color, delay, delTime);
		return Obj;
	}



//󓃃r[
	task Houtou_Beam(Obj, x, y, angle, Color, delay, delTime) {
		let Laser  = Obj_Create(OBJ_LASER);
		let Detail = Obj_Create(OBJ_EFFECT);
		let Fire   = Obj_Create(OBJ_EFFECT);

		let Length  = 0;
		let width   = 1;
		let grazeC  = 0;
		let color   = Color;
		let clrPlus = 0.25;
		let count   = 0;

		let Fire_count = 0;
		let Fire_scale = 1.5;
		let Fire_sclct = 0;

		if(Color == 8) {
			color = 0;
		}

		let u = 0;
		let uPlus = -12.5;

//----------------------------------------------------------------------------------------------------
//{ݒ

		Obj_SetPosition(Obj, x, y);
		ObjEffect_SetTexture(Obj, imgBeam);
		ObjEffect_SetRenderState(Obj, ADD);
		ObjEffect_SetPrimitiveType(Obj, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetScale(Obj, 1, width/40);
		ObjEffect_SetLayer(Obj, 2);

		Obj_SetPosition(Detail, x, y);
		ObjEffect_SetTexture(Detail, imgBeam);
		ObjEffect_SetRenderState(Detail, ALPHA);
		ObjEffect_SetPrimitiveType(Detail, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetScale(Detail, 1, width/40);
		ObjEffect_SetLayer(Detail, 2);

		Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
		ObjEffect_SetTexture(Fire, imgFire);
		ObjEffect_SetRenderState(Fire, ADD);
		ObjEffect_SetPrimitiveType(Fire, PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetScale(Fire, Fire_scale, Fire_scale);
		ObjEffect_SetLayer(Fire, 2);

		Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
		Obj_SetAngle(Laser, Obj_GetAngle(Obj));
		Obj_SetAlpha(Laser, 0);
		Obj_SetAutoDelete(Laser, false);
		ObjShot_SetGraphic(Laser, RED01);
		ObjShot_SetDelay(Laser, 0);
		ObjShot_SetBombResist(Laser, true);
		ObjShot_ToItem(Laser, false);
		ObjLaser_SetLength(Laser, 768);
		ObjLaser_SetWidth(Laser, width*(3/4));
		ObjLaser_SetSource(Laser, false);

//----------------------------------------------------------------------------------------------------
//GtFNg\̐ݒ

		Obj_SetAngle(Obj, angle);
		ObjEffect_CreateVertex(Obj, 4);
		ObjEffect_SetVertexXY(Obj, 0,   0, -20);
		ObjEffect_SetVertexXY(Obj, 1,   0,  20);
		ObjEffect_SetVertexXY(Obj, 2, 768, -20);
		ObjEffect_SetVertexXY(Obj, 3, 768,  20);
		ObjEffect_SetVertexUV(Obj, 0, 128+(trunc(color)*16)   , 368);
		ObjEffect_SetVertexUV(Obj, 1, 128+(trunc(color)*16)+16, 368);
		ObjEffect_SetVertexUV(Obj, 2, 128+(trunc(color)*16)   , 384);
		ObjEffect_SetVertexUV(Obj, 3, 128+(trunc(color)*16)+16, 384);
		ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));

		ObjEffect_CreateVertex(Detail, 4);
		ObjEffect_SetVertexXY(Detail, 0,   0, -15);
		ObjEffect_SetVertexXY(Detail, 1,   0,  15);
		ObjEffect_SetVertexXY(Detail, 2, 768, -15);
		ObjEffect_SetVertexXY(Detail, 3, 768,  15);
		ObjEffect_SetVertexUV(Detail, 0,   0, 330);
		ObjEffect_SetVertexUV(Detail, 1,   0, 360);
		ObjEffect_SetVertexUV(Detail, 2, 768, 330);
		ObjEffect_SetVertexUV(Detail, 3, 768, 360);
		ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));

		ObjEffect_CreateVertex(Fire, 4);
		ObjEffect_SetVertexXY(Fire, 0,  -1, -64);
		ObjEffect_SetVertexXY(Fire, 1,  -1,  64);
		ObjEffect_SetVertexXY(Fire, 2, 127, -64);
		ObjEffect_SetVertexXY(Fire, 3, 127,  64);
		ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

//----------------------------------------------------------------------------------------------------
//ҋ@Ԃ̏

//		PlaySE(SEAppear);

		loop(delay) {
			if(Obj_BeDeleted(Obj) == true) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }

			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetScale(Fire, Fire_scale+1.5*(1-Fire_sclct), Fire_scale*Fire_sclct);
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			Fire_count += 0.5;
			if(Fire_sclct < 1) { Fire_sclct += 0.2; }
			if(Color == 8) { color += clrPlus; }
			if(Color == 8 && color >= 7)  { color = 0; }
			yield;
		};

//----------------------------------------------------------------------------------------------------
//˂鏈

		ObjEffect_SetScale(Obj, (Length/768), 1);
		ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
		ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
		ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);
		ObjEffect_SetScale(Fire, Fire_scale, Fire_scale);
//		PlaySE(SELaser);

		loop(30) {
			if(Obj_BeDeleted(Obj) == true) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }

			Length += 20;
			if(width < 40) { width  += (39/15); } else { width = 40; }
			u += uPlus;

			ObjEffect_SetScale(Obj, (Length/768), width/40);
			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
			ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetScale(Detail, 1, width/40);
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
			ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
			ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
			ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			Fire_count += 0.5;
			if(Color == 8) { color += clrPlus; }
			if(Color == 8 && color >= 7)  { color = 0; }
			yield;
		}

//----------------------------------------------------------------------------------------------------
//˂鏈

		Length = 768;
		ObjEffect_SetScale(Obj, (Length/768), 1);

		while(!Obj_BeDeleted(Obj)) {
			if(count >= delTime && delTime >= 0) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }
			u += uPlus;

			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
			ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
			ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
			ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
			ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			Fire_count += 0.5;
			if(Color == 8) { color += clrPlus; }
			if(Color == 8 && color >= 7)  { color = 0; }
			if(delTime >= 0) { count++; }
			yield;
		}

//----------------------------------------------------------------------------------------------------
//ŏ

		loop(30) {
			if(Obj_BeDeleted(Obj) == true) { break; }
			if(Obj_BeDeleted(Laser)) { Laser = Obj_Create(OBJ_LASER); }

			width -= (4/3);
			u += uPlus;

			ObjEffect_SetScale(Obj, 1, width/40);
			ObjEffect_SetAngle(Obj, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Obj, 0,   0, (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 1,   0, (trunc(color)*40)+45);
			ObjEffect_SetVertexUV(Obj, 2, 256, (trunc(color)*40)+5);
			ObjEffect_SetVertexUV(Obj, 3, 256, (trunc(color)*40)+45);

			Obj_SetPosition(Detail, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetScale(Detail, 1, width/40);
			ObjEffect_SetAngle(Detail, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetVertexUV(Detail, 0,   0+u, 330);
			ObjEffect_SetVertexUV(Detail, 1,   0+u, 360);
			ObjEffect_SetVertexUV(Detail, 2, 768+u, 330);
			ObjEffect_SetVertexUV(Detail, 3, 768+u, 360);

			Obj_SetPosition(Fire, Obj_GetX(Obj), Obj_GetY(Obj));
			ObjEffect_SetAngle(Fire, 0, 0, Obj_GetAngle(Obj));
			ObjEffect_SetScale(Fire, Fire_scale, Fire_scale*(width/40));

			if(trunc(Fire_count)%2 == 0) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256    ,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256    , ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
			} else if(trunc(Fire_count)%2 == 1) {
				ObjEffect_SetVertexUV(Fire, 0,  trunc(color/4)*256+128,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 1,  trunc(color/4)*256+128, ((trunc(color)%4)*128)+128);
				ObjEffect_SetVertexUV(Fire, 2,  trunc(color/4)*256+256,  (trunc(color)%4)*128);
				ObjEffect_SetVertexUV(Fire, 3,  trunc(color/4)*256+256, ((trunc(color)%4)*128)+128);
			}

			Obj_SetPosition(Laser, Obj_GetX(Obj), Obj_GetY(Obj));
			Obj_SetAngle(Laser, Obj_GetAngle(Obj));
			ObjLaser_SetWidth(Laser, width*(5/4));

			if(Color == 8) { color += clrPlus; }
			if(Color == 8 && color >= 7)  { color = 0; }
			yield;
		}

		Obj_Delete(Obj);
		Obj_Delete(Fire);
		Obj_Delete(Detail);
		Obj_Delete(Laser);
	}
