搶曽抏枊晽
#Title[抧晞乽嫄恖鑸曕乿]
#Text[]
#BackGround[DEFAULT]
#Player[FREE]
#ScriptVersion[2]

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

	let draw_rot = 0;

	@Initialize
	{
		SetLife(500);
		SetExMode();
		SetHitState(0);

		InitPosition(GetCenterX(), GetClipMinY() + 80);

		LoadGraphic(img_chen);

		LoadUserShotData(shot_00);
		SetShotAutoDeleteClip(24, 24, 24, 24);

		InitializeAction();
		InitializeBG();
		LoadSE(se_shot1);
		LoadSE(se_shot2);

		T_Main();
		T_HitTest(48);
	}

	@Finalize
	{
		if( GotSpellCardBonus() ){
			if( hypot(GetX() - GetPlayerX(), GetY() - GetPlayerY()) < 100 ){
				CreateItemCircle(GetX() - 40, GetY(), 20, 40);
				CreateItemCircle(GetX() + 40, GetY(), 20, 40);
			}
			else{
				CreateItemCircle(GetX(), GetY(), 20, 40);
			}
		}
		DeleteGraphic(img_chen);
		DeleteSE(se_shot1);
		DeleteSE(se_shot2);
		ClearBG();
	}

	@DrawLoop
	{
		if( action == ACT_MOVE && absolute(GetSpeed()) >= 0.1 ){
			if( cos( GetAngle() ) <= 0 ){
				draw_rot -= 30;
			}
			else{
				draw_rot += 30;
			}
		}
		else{
			draw_rot = 0;
		}
		SetGraphicAngle(0, 0, draw_rot);
		SetAlpha([255, 128][IsExMode() && OnBomb()]);
		DrawBoss(img_chen);
		SetGraphicAngle(0, 0, 0);
	}

	task T_Main()
	{
		yield;

		SetAction(ACT_MOVE, 60);
		Wait(60);
		StartSetting(60, 2000000, "抧晞乽嫄恖鑸曕乿");
		SetInvincibility(150);
		T_DamageRate(20, 0, 240, -1);

		SetAction(ACT_SPELL, 60);

		Wait(120);
		SetHitState(1);

		T_Move();
	}

	task T_Move()
	{
		let v;
		let a = (196 + 160) * 4 / (90 ^ 2);
		let angle = [115, 65];
		let warp_d = (80 + 160) / sin(angle[0]);
		let k = 0;

		PlaySE(se_concent);
		SetColor(255, 255, 255);
		Concentration01(90);
		SetColor(255, 255, 255);
		Wait(90);

		loop{
			SetAction(ACT_MOVE, 90 + 60);
			SetAngle(angle[k]);

			v = 0;
			ascent( let n in 0..90 ){
				v += a;
				SetSpeed(v);
				if( n % 3 == 1 ){
					PlaySE(se_shot1);
					CreateSideShot(rand(2.4, 2.8), 103);
					CreateSideShot(rand(1.8, 2.1), 101);
					CreateSideShot(rand(1.3, 1.6), 102);
				}
				CreateShot01(GetX(), GetY(), 1.7, GetAngleToPlayer(), 63, 0);
				yield;
			}
			SetX(GetCenterX() - warp_d * cos(angle[k]));
			SetY(GetClipMinY() + 80 - warp_d * sin(angle[k]));
			SetMovePositionDC(GetCenterX(), GetClipMinY() + 80, 60);
			ascent( let n in 0..60 ){
				if( n % 3 == 1 ){
					PlaySE(se_shot1);
					CreateSideShot(rand(2.4, 2.8), 103);
					CreateSideShot(rand(1.8, 2.1), 101);
					CreateSideShot(rand(1.3, 1.6), 102);
				}
				yield;
			}
			Wait(30);
			k = 1 - k;
		}
	}

	task CreateSideShot(v, type)
	{
		CreateShot01(GetX(), GetY(), v,   0 + rand(-2, 2), type, 0);
		CreateShot01(GetX(), GetY(), v, 180 + rand(-2, 2), type, 0);
	}

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