script_enemy_main {
	let imgEBlue	= GetCurrentScriptDirectory() ~ "\img\faily_blue.png";
	let imgERed	= GetCurrentScriptDirectory() ~ "\img\faily_red.png";
	#include_function ".\lib\setting_nue.txt"
	#include_function ".\lib\lib_se.txt"

	// shot_all.png
	#include_function ".\lib_usershot.txt"
	let userShot = GetCurrentScriptDirectory() ~ ".\lib\data_usershot.txt";

	let BASE_ZANKI	= GetPlayerLife();
	let BASE_BOMB	= GetPlayerBomb();

	@Initialize {
		SetLife(9999);
		SetDamageRate(0, 0);

		LoadGraphic(imgEBlue);
		LoadGraphic(imgERed);
		LoadGraphic(imgNue);
		LoadUserShotData(userShot);

		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(4)
		{
			let angle = GetAngleToPlayer;
			loop(16)
			{
				StopSE(SE_LASER);
				PlaySE(SE_LASER);
				shot_kimera(GetX+cos(angle)*16, GetY+sin(angle)*16, 3, angle, 170, 35, US_BALL_S_BLUE, US_LIGHT_BLUE, 45);
				angle += 360/16;
				wait(3);
			}
			angle -= 360/32;
			wait(40);
			loop(16)
			{
				StopSE(SE_LASER);
				PlaySE(SE_LASER);
				shot_kimera(GetX+cos(angle)*16, GetY+sin(angle)*16, 3, angle, 170, 35, US_BALL_S_RED, US_LIGHT_RED, 160);
				angle -= 360/16;
				wait(3);
			}
			wait(75);
		}
	}

	//キメラ弾
	task shot_kimera(x, y, speed, angle, length, timer, graphic, graphic2, a_offset)
	{
		//オブジェクト弾の作成
		let obj = Obj_Create(OBJ_LASER);
		
		//パラメータの設定
		Obj_SetAngle(obj, angle);
		Obj_SetPosition(obj, x, y);
		ObjLaser_SetLength(obj, 0);
		ObjLaser_SetWidth(obj, 10);
		ObjShot_SetDelay(obj, 0);
		ObjShot_SetGraphic(obj, graphic);
		ObjLaser_SetSource(obj, false);
		
		let n = 0;
		while (n < length && !Obj_BeDeleted(obj)) {
			ObjLaser_SetLength(obj, n);
			n += speed;
			yield;
		}
		if (!Obj_BeDeleted(obj)) { ObjLaser_SetLength(obj, length); }
		
		let t = 0;
		while(!Obj_BeDeleted(obj))
		{
			if (t > timer)
			{
				let n = 0;
				let tx = Obj_GetX(obj);
				let ty = Obj_GetY(obj);
				while (n+56 <= length)
				{
					CreateShot02(tx+cos(angle)*n, ty+sin(angle)*n, 0, angle+a_offset, 0.03, 1.5, graphic2, 30);
					CreateShot02(tx+cos(angle)*(n+10), ty+sin(angle)*(n+14), 0, angle-a_offset, 0.03, 1.5, graphic2, 30);
					n += 28;
				}
				break;
			}
			x += cos(angle)*speed;
			y += sin(angle)*speed;
			Obj_SetPosition(obj,x,y);
			t++;
			yield;
			
			if (x < GetClipMinX || x > GetClipMaxX
				|| y < GetClipMinY || y > GetClipMaxY) { break; }
		}

		ObjShot_FadeDelete(obj);
	}

	task TMove()
	{
		SetMovePositionHermite(GetCenterX, GetClipMinY+150, 150, 0, 400, 60, 200);
		wait(980);
		SetMovePositionHermite(GetX-20, GetY-20, 250, 0, 250, 0, 120);
		wait(120);

		//ぬえプレゼント
		if (BASE_ZANKI == GetPlayerLife() && BASE_BOMB == GetPlayerBomb())
			{ CreateItem(ITEM_1UP, GetX, GetY); }
		else
			{ CreateItem(ITEM_BOMB, GetX, GetY); }

		SetMovePositionHermite(GetClipMinX-100, GetClipMinY, 250, 0, 300, 0, 100);
		wait(600);
		
		VanishEnemy();
	}

}
