script_enemy_main {
	let imgEBlue	= GetCurrentScriptDirectory() ~ "\img\faily_blue.png";
	let imgERed	= GetCurrentScriptDirectory() ~ "\img\faily_red.png";
	#include_function ".\lib\setting_nue.txt"
	
	let BASE_ZANKI	= GetPlayerLife();
	let BASE_BOMB	= GetPlayerBomb();
	
	@Initialize {
		SetLife(9999);
		SetDamageRate(0, 0);

		LoadGraphic(imgEBlue);
		LoadGraphic(imgERed);
		LoadGraphic(imgNue);

		TMain;
	}

	@MainLoop {
		SetCollisionB(GetX+OF_X, GetY+OF_Y, 16);
		yield;
	}

	@DrawLoop {
		//敵画像はエフェクトで描画
	}

	@Finalize {
	}

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

		TShot;
		TMove;
	}

	//弾射出タスク
	task TShot()
	{
		wait(180);
		loop(5)
		{
			CreateEnemyFromScript("NueBig", GetX+OF_X, GetY+OF_Y, 0, 0, 0);
			wait(60);
		}
		wait(50);
		CreateEnemyFromScript("NueBig", GetX+OF_X, GetY+OF_Y, 0, 0, 0);
	}
	
	task TMove()
	{
		SetMovePositionHermite(GetCenterX-100, GetClipMinY+180, 150, 0, 400, 60, 200);
		wait(190);
		SetMovePositionHermite(GetCenterX+150, GetClipMinY+100, 150, 0, 400, 60, 120);
		wait(100);
		SetMovePositionHermite(GetCenterX, GetClipMinY+150, 150, 0, 400, 60, 200);
		wait(190);
		SetMovePositionHermite(GetClipMinX-60, GetClipMinY, 250, 0, 300, 0, 100);
		wait(100);
		
		VanishEnemy();
	}
	
	//妖精射出
	task shot_nueyousei(speed, angle, way, type)
	{
		let i = 0;
		let ip = 90;
		if (way < 0) { ip = -90; }
		loop(absolute(way))
		{
			let a = angle+i*360/way;
			CreateEnemyFromScript(type, GetX+cos(a)*64+OF_X, GetY+sin(a)*64+OF_Y, 2, a+ip, speed);
			i++;
			loop (3) { yield; }
		}
	}
}

// ぐるぐる妖精（星４面っぽい奴）
script_enemy NueBig {
	let imgEmeny	= GetCurrentScriptDirectory() ~ "\img\faily_blue.png";
	#include_function ".\lib\setting_emeny.txt"

	let shot_speed = GetArgument();
	let ANGLE = GetAngle();

	@Initialize {
		Initialize_Fairy(LARGE_FLOWER);	//使用する妖精を設定
		SetLife(333);
		SetScore(10000);
		SetDamageRate(100, 100);

		TMain;
	}

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

		yield;
	}

	@DrawLoop {
		DrawFairy(imgEmeny);	//妖精を描画
	}

	@Finalize()
	{
		if (!BeVanished())
		{
			loop(8)
			{
				let r = rand(0, 16^2)^0.5;
				let a = rand(0, 360);
				CreateItem(ITEM_SCORE, GetX+r*cos(a), GetY+r*sin(a));
			}
		}
	}

	task TMain {
		yield;
		TMove;
		TShot;
	}

	task TMove {
		SetMovePosition03(GetX, (GetY+GetCenterY-100)/2, 50, 1);
	}

	task TShot {
		yield;
		
		loop(60) { yield; }
		CreateShotFromScript("Guruguru", GetX, GetY, 1.5, 90, 0, US_RICE_S_PURPLE);
		loop(60) { yield; }
		CreateShotFromScript("Guruguru", GetX, GetY, 1.5, 90, 0, US_RICE_S_PURPLE);
		loop(120) { yield; }
		CreateShotFromScript("Guruguru", GetX, GetY, 1.5, 90, 0, US_RICE_S_PURPLE);
		loop(120) { yield; }
		CreateShotFromScript("Guruguru", GetX, GetY, 1.5, 90, 0, US_RICE_S_PURPLE);
	}
}

// ぐるぐるショット
script_shot Guruguru
{
	let SPEED	= GetSpeed();
	let GRAPHIC	= GetArgument();
	let userShot = GetCurrentScriptDirectory() ~ ".\lib\data_usershot.txt";
	
	let t = 0;
	let rest = -3;
	let NEXT_REST = 15;
	let tmp_angle = 0;

	#include_function ".\lib\lib_se.txt"
	#include_function ".\lib_usershot.txt"		//shot_all.png

	@Initialize
	{
		LoadUserShotData(userShot);
		SetAngle(90);
	}
	@MainLoop
	{
		if(GetY > GetClipMaxY-32){
			End();
		}
		else
		{
			if (rest <= 0)
			{
				CreateShotA(0, GetX+cos(t*12)*16, GetY+sin(t*12)*16, 5-rest*2);
				SetShotDataA(0,  0, 0, tmp_angle+(rest+1), 0, 0, 0, GRAPHIC);
				SetShotDataA(0, 60, 2, NULL, 0, 0, 0, GRAPHIC);
				FireShot(0);
			}
			else if (t%3 == 0)
			{
				//エフェクトだけ表示
				CreateShotA(0, GetX+cos(t*12)*16, GetY+sin(t*12)*16, 5);
				SetShotDataA(0, 0, 0, 0, 0, 0, 0, GRAPHIC);
				SetShotKillTime(0, 0);
				FireShot(0);
			}
			
			if (t%6 == 0)
			{
				StopSE(SE_SHOT2);
				PlaySE(SE_SHOT2);
			}
			
			if (rest >= NEXT_REST) {
				rest = -3;
				NEXT_REST = rand_int(8, 20);
				tmp_angle = t*12;
			}
			rest++;
			t++;
		}
	}
	@DrawLoop
	{
		//見えない弾
	}
	@Finalize
	{
	}
}
