#e
#Title[֒ʏP]
#Text[test]
#ScriptVersion[2]

script_enemy_main {
	let name	= "";

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

	//shotall.png
	#include_function ".\lib_usershot.txt"
	//ւ̊{ݒ
	#include_function ".\lib\setting_itirin.txt"

	let D_RATE = 100;
	let D_WAIT = 260;

	@Initialize {
		SetLife(2500);
		SetTimer(35);
		SetDamageRate(5, 5);

		Ini_Graphic;

		TMain;
	}

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

		yield;
	}

	@DrawLoop {
		Draw_Itirin;
	}

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

	// C^XN
	task TMain {
		yield;

		TRate;
		standBy;
		powerSave;

		//e
		TShot;
	}

	//eˏo^XN
	task TShot()
	{
		loop
		{
			ATTACK_FLAG = 1;
			shot_guruguru2(270, 13, 1.8, US_RICE_S_BLUE, 10, 8, 30, 1, 0.9);
			shot_guruguru2(270, 13, 1.8, US_RICE_S_AQUA, 10, 8, 30,-1, 0.9);
			wait(60);
			ATTACK_FLAG = 0;
			wait(115);
			ATTACK_FLAG = 1;
			lazer_guruguru(32, 90, 10, 4, 150, 7, WHITE11, 10, 36);
			wait(30);
			lazer_guruguru(32, 95, 10, 4, 150, 7, WHITE11, 10, 36);
			wait(36);
			ATTACK_FLAG = 0;
			
			moveBoss(30, 45, 15, 40, 10, 2, 64, 40, 150);
			
			wait(30);
		}
	}

	//{X[U[
	task lazer_guruguru(r, angle, a_move, speed, length, width, graphic, delay, count)
	{
		PlaySE(SE_LASER);

		ascent(let t in 0..count)
		{
			let a = angle + t*a_move;
			CreateLaser01(GetX+cos(a)*r, GetY+sin(a)*r, speed, a+180, length, width, graphic, delay);
			CreateLaser01(GetX+cos(a)*r, GetY+sin(a)*r, speed, a+105, length, width, graphic, delay);
			CreateLaser01(GetX+cos(a)*r, GetY+sin(a)*r, speed, a-105, length, width, graphic, delay);
			yield;
		}
	}
	
	//ւʏBe̋O킯킩
	//kankaku=1lAeƒe̊Ԃ̋
	task shot_guruguru2(angle, a_move, min_speed, graphic, delay, s_count, count, muki, kankaku)
	{
		muki *= (min_speed/2);	//speed=2Œ
		ascent(let t in 0..count)
		{
			let a = angle + t*a_move;
			ascent (let n in 0..(s_count+1)) {
				let sd = (4-min_speed+0.05*n*kankaku)/30;
				CreateShotA(0, GetX, GetY, delay);
				SetShotDataA(0,   0, 4+0.2*n*kankaku, 180+a,muki*3,     0, 0, graphic);
				SetShotDataA(0,  10, 4+0.1*n*kankaku, NULL, muki*2.5, -sd, 0, graphic);
				SetShotDataA(0,  20, NULL, NULL,    muki*2,   -sd, 0, graphic);
				SetShotDataA(0,  40, NULL, NULL,    muki,       0, 0, graphic);
				SetShotDataA(0, 100, NULL, NULL,    muki*0.2,   0, 0, graphic);
				FireShot(0);
			}
			
			StopSE(SE_SHOT);
			PlaySE(SE_SHOT);

			yield;
		}
	}
}
