#ScriptVersion[2]

script_event Talk
{
	@Initialize
	{
	}

	@MainLoop
	{
		TextOutB(120, "\c[RED]八雲家主催の宴会へようこそ。\nでもその前に……");
		TextOutB(120, "\c[RED]残機とボムを幾らか置いて行きなさい。");

		End();
	}

	@Finalize
	{
	}
}

script_enemy_main
{
	#include_function ".\init.txt"
	#include_function ".\lib\lib_anime_Yukari.txt"

	@Initialize()
	{
		SetLife(9999);

		LoadGraphic(img_yukari);
		SetHitState(0);
		MagicCircle(false);

		SetX(GetClipMinX() - 64);
		SetY(GetClipMaxY() + 128);

		InitializeAction();
		DeleteEnemyShot(ALL);

		T_Main();
		T_DamageRate(0, 0, 240, -1);
		T_HitTest(32);
	}

	@Finalize()
	{
		DeleteGraphic(img_yukari);
	}

	@DrawLoop()
	{
		DrawBoss(img_yukari);
	}

	task T_Main()
	{
		yield;

		ForbidShot(true);
		ForbidBomb(true);

		T_StartMove();
		Wait(120);

		CreateEventFromScript("Talk");

		while( OnEvent() ){
			yield;
		}

		ForbidShot(false);
		ForbidBomb(false);
		SetCommonData("boss_x", GetX());
		SetCommonData("boss_y", GetY());
		VanishEnemy();
	}

	task T_StartMove()
	{
		SetAction(ACT_MOVE, 120);

		let vx = 2.2;
		let vy = -12.0;
		let ax = 0;
		let ay = -vy / 90;

		ascent( let i in 0..150 ){
			if( i == 90 ){
				ax = ((GetCenterX() - GetX()) / 15 - vx * 3) / 60;
				ay = (GetClipMinY() + 150 - GetY()) / 30 / 30;
			}
			else if( i == 120 ){
				ax = -vx / 30;
				ay = -vy / 30;
			}
			vx += ax;
			vy += ay;
			SetSpeed(hypot(vy, vx));
			SetAngle(atan2(vy, vx));
			yield;
		}
		SetSpeed(0.0);
	}

	#include_function ".\f_base.txt"
	#include_function ".\f_enemy.txt"
	#include_function ".\f_boss.txt"
}
