#e
#Title[@ʏR]
#Text[UfC]
#ScriptVersion[2]

script_enemy_main {
	let name	= "";

	// shot_all.png
	#include_function ".\lib_usershot.txt"
	// @񏉊ݒ
	#include_function ".\lib\setting_byakuren.txt"

	// ʒu
	let xIni	= GetCenterX;
	let yIni	= GetClipMinY + 120;

	let D_RATE = 100;
	let D_WAIT = 320;

	@Initialize {
		SetLife(2500);
		SetTimer(50);
		SetDamageRate(1, 1);

		Ini_Graphic;
		LoadGraphic(imgEffect);
		LoadGraphic(imgBlankCircle);

		TMain;
	}

	@MainLoop {
		SetCollisionA(GetX, GetY, 32);
		SetCollisionB(GetX, GetY, 16);

		yield;
	}

	@DrawLoop {
		Draw_Byakuren;
	}

	@Finalize {
		if (!IsTimeOut()) { makeTokutenItem(15); }
//		DeleteGraphic(imgBoss);
	}

	// C^XN
	task TMain {
		yield;

		TRate;
		standBy;

		//GtFNg
		sub_effects_start;
		wait(15);
		effect_blank_circle();

		//e
		TShot;
		TMove;
	}

	task TShot
	{
		wait(30);
		ATTACK_FLAG = 1;
		
		let base = 0;
		loop
		{
			ascent (let m in 0 .. 2)
			{
				shot_uneri_sub(0, 4,  base, m, [US_SCALE_RED, US_SCALE_BLUE][m]);
				shot_uneri_sub(1, 4, -base, m, [US_SCALE_RED, US_SCALE_BLUE][m]);
				shot_uneri_sub(2, 4,  base+90, m, [US_SCALE_RED, US_SCALE_BLUE][m]);
				shot_uneri_sub(3, 4, -base+90, m, [US_SCALE_RED, US_SCALE_BLUE][m]);
				wait(90);
			}
			base += 45;
			wait(210);
		}
	}
	
	function shot_uneri_sub(n, speed, base, st, graphic)
	{
		let byaku_optionX = [-90,90,-45,45];
		let byaku_optionY = [30,30,-60,-60];
		let A_STEP = 40;

		shot_uneri(byaku_optionX[n], byaku_optionY[n],
			speed,  base+90-A_STEP/2+A_STEP*st, 3,  1.25, graphic, 10);
		shot_uneri(byaku_optionX[n], byaku_optionY[n],
			speed, base+270+A_STEP/2-A_STEP*st, 3, -1.25, graphic, 10);
		shot_uneri(byaku_optionX[n], byaku_optionY[n],
			speed,  base+90+A_STEP/2-A_STEP*st, 3, -1.25, graphic, 10);
		shot_uneri(byaku_optionX[n], byaku_optionY[n],
			speed, base+270-A_STEP/2+A_STEP*st, 3,  1.25, graphic, 10);
	}

	// ˂˃Vbg
	task shot_uneri(x, y, speed, angle, a_step, a_change, graphic, wt)
	{
		let t = 0;
		let tmp = 80/speed;
		let tmp2 = 0;
		if (a_change > 0) { tmp2 = 1; }
		else { tmp2 = -1; }
		
		let max_c = 24;

		loop(max_c)
		{
			CreateShotA(0, GetX+x, GetY+y, 5);
			SetShotDataA(0,     0, 4, angle,       tmp2*80/tmp, 0, 0, graphic);
			SetShotDataA(0,   tmp, 4,  NULL,a_change*(t)/max_c, 0, 0, graphic);
			SetShotDataA(0, tmp*3, 4,  NULL,                 0, 0, 0, graphic);
			FireShot(0);//e(shot1)𔭎
			wait(wt);
			t++;
		}
	}

	// Lړ^XN1frameƂɔ
	task TMove {
		wait(120);
		SetMovePosition02(GetClipMinX+64, GetY, 300);
		setGraphicMove;
		wait(330);
		loop {
			SetMovePosition02(GetClipMaxX-64, GetY, 600);
			setGraphicMove;
			wait(630);
			SetMovePosition02(GetClipMinX+64, GetY, 600);
			setGraphicMove;
			wait(630);
		}
	}
}
