#東方弾幕風
#Title[ナズーリン通常]
#Text[test]
#ScriptVersion[2]

script_enemy_main {
	let name	= "";

	#include_function ".\lib_usershot.txt"
	#include_function ".\lib\setting_nazu.txt"

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

	let D_RATE = 100;
	let D_WAIT = 180;

	@Initialize {
		SetLife(1700);
		SetTimer(32);
		SetDamageRate(5, 5);

		Ini_Graphic;

		TMain;
	}

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

		yield;
	}

	@DrawLoop {
		Draw_Nazu;
	}

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

//		DeleteGraphic(imgBoss);
	}

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

		TRate;
		standBy;

		//弾
		TShot;
	}

	//弾射出タスク
	task TShot()
	{
		wait(30);
		loop
		{
			ATTACK_FLAG = 1;
			loop(5)
			{
				shot_nezumi(1.5, 4, 20, 60, US_SCALE_PURPLE);
				loop(10){yield;}
			}
			moveBoss(60, 120, 15, 40, 12, 4, 64, 40, 150);
			ATTACK_FLAG = 0;
			loop(45){yield;}
		}
	}
	
	//ネズーミンランド召喚
	task shot_nezumi(speed_min, speed_max, noudo, timer, graphic)
	{
		let n = 0;
		let speed_gain = (speed_min-speed_max)/timer;
		let noudo_gain = noudo/2;
		let angle = GetAngleToPlayer;
		//左側
		n = 0;
		while (n < 400)
		{
			let length = rand(-noudo/2,noudo/2) + n;
			let sx = GetX + cos(90+angle)*length;
			let sy = GetY + sin(90+angle)*length + rand(-(n+100)/4, (n+100)/4);
			CreateShot02(sx, sy, speed_max, angle, speed_gain, speed_min, graphic, 15);
			CreateShot02(sx, sy, speed_max, angle+180, speed_gain, speed_min, graphic, 15);

			length = rand(-noudo/2,noudo/2) - n;
			sx = GetX + cos(90+angle)*length;
			sy = GetY + sin(90+angle)*length + rand(-(n+100)/4, (n+100)/4);
			CreateShot02(sx, sy, speed_max, angle, speed_gain, speed_min, graphic, 15);
			CreateShot02(sx, sy, speed_max, angle+180, speed_gain, speed_min, graphic, 15);

			n += noudo;
			//外側は薄い
			noudo += noudo_gain;

			StopSE(SE_SHOT2);
			PlaySE(SE_SHOT2);
			loop(3) { yield; }
		}
	}
}
