#東方弾幕風
#Title[星さん通常]
#Text[test]
#ScriptVersion[2]

script_enemy_main {
	let name	= "";

	// shot_all.png
	#include_function ".\lib_usershot.txt"
	// 星さん初期設定
	#include_function ".\lib\setting_tora.txt"

	// 初期位置
	let xIni	= GetCenterX;
	let yIni	= GetClipMinY + 64+32;

	let D_RATE = 100;
	let D_WAIT = 300;

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

		Ini_Graphic;
		LoadGraphic(imgHoutou);

		TMain;
	}

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

		yield;
	}

	@DrawLoop {
		Draw_Toramaru;
	}

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

//		DeleteGraphic(imgBoss);
	}

	// メインタスク
	task TMain {
		yield;

		TRate;

		SetX(GetCenterX); SetY(GetClipMinY-100);
		standBy;
		powerSave;
		effect_toramaru;

		//弾
		TShot;
	}

	//弾射出タスク
	task TShot()
	{
		wait(60);
		loop
		{
			ATTACK_FLAG = 1;
			shot_kurukuru_lazer2(rand(0,360), 16, US_LIGHT_YELLOW,-1);
			PlaySE(SE_LASER2);
			loop(30){yield;}
			shot_kurukuru_lazer2(rand(0,360), 16, US_LIGHT_YELLOW, 1);
			loop(30){yield;}
			shot_kurukuru_lazer1(rand(0,360), 18, US_LIGHT_RED);
			loop(60){yield;}
			TShot_sub;

			ATTACK_FLAG = 0;
			loop(135){yield;}
		}
	}

	task TShot_sub()
	{
		let angle = rand(0,360); let n = 0;
		ascent (let n in 0 .. 6)
		{
			shot_circle(2+n*0.45, angle+n*5, 24, US_BALL_M_A_WHITE);
		}
		StopSE(SE_SHOT);
		PlaySE(SE_SHOT);
		moveBoss(20, 40, 0, 30, 20, 2, 64, 40, 150);
	}
	
	//全方位弾
	function shot_circle(speed, angle, way, graphic)
	{
		ascent (let n in 0 .. way)
		{
			CreateShot01(GetX, GetY, speed, angle+n*360/way, graphic, 10);
		}
	}

	//くるんくるんレーザー
	task shot_kurukuru_lazer1(angle, way, graphic)
	{
		ascent (let n in 0 .. way)
		{
			CreateLaserC(0, GetX, GetY, 6, 90, graphic, 0);
			SetLaserDataC(0,   0, 3, angle+n*360/way, 4, 0, 6);
			SetLaserDataC(0,  48, 2.5, NULL, -3, 0, 6);
			SetLaserDataC(0,  60, 0.5, NULL, -2, 0, 6);
			SetLaserDataC(0,  76,   6, NULL,  0, 0, 6);
			FireShot(0);
		}
	}
	task shot_kurukuru_lazer2(angle, way, graphic, muki)
	{
		ascent (let n in 0 .. way)
		{
			CreateLaserC(0, GetX, GetY, 6, 60, graphic, 0);
			SetLaserDataC(0,   0, 4, angle+n*360/way, 12, 0, 6);
			SetLaserDataC(0,   2, 4, NULL, muki*-12, 0, 6);
			SetLaserDataC(0,   6, 4, NULL, muki* 12, 0, 6);
			SetLaserDataC(0,  10, 5, NULL, muki* -8, 0, 6);
			SetLaserDataC(0,  46,10, NULL, muki*  6, 0, 6);
			SetLaserDataC(0,  80,1.7, NULL, muki*0.4, 0, 6);
			SetLaserDataC(0,  92, 6, NULL,        0, 0, 6);
			FireShot(0);
		}
	}
}
