#ScriptVersion[2]

script_enemy_main
{
	#include_function ".\init.txt"

	@Initialize
	{
		SetLife(700);

		SetTexture(img_fairy);

		LoadUserShotData(shot_00);

		InitializeAction();
		SetFairyType(3);

		T_Main();
		T_HitTest(32);
	}

	@Finalize
	{
		if( GetLife() <= 0 ){
			CreateItemCircle(GetX(), GetY(), 8, 16);
			CreateItem(ITEM_BOMB, GetX(), GetY());
		}
	}

	@DrawLoop
	{
		DrawGraphic(GetX(), GetY());
	}

	task T_Main()
	{
		yield;

		T_Move();
		T_Shot();
		Wait(10);

		loop{
			if( IsOutOfClipRange(GetX(), GetY(), 16) ){
				VanishEnemy();
			}
			yield;
		}
	}

	task T_Move()
	{
		let v = GetSpeed();
		let a = -v / 60;
		loop(60){
			v += a;
			SetSpeed(v);
			yield;
		}
		Wait(280);
		a = 0.05;
		loop(60){
			v += a;
			SetSpeed(v);
			yield;
		}
	}

	task T_Shot()
	{
		Wait(60);
		let angle = 90 - 4.0 * 60 / 10;
		loop(7){
			PlaySE(se_shot1);
			ascent( let j in 0..10 ){
				let s_angle = angle + j * 360 / 10;
				ascent( let i in 0..3 ){
					CreateShot01(GetX(), GetY(), 3.0, s_angle + i * 60 / 10, 11, 0);
				}
				let c_angle = s_angle + 4.0 * 60 / 10;
				let cx = 3.0 * cos(c_angle);
				let cy = 3.0 * sin(c_angle);
				let r = 3.0 * sin(3.0 * 30 / 10);
				ascent( let i in 0..13 ){
					let p_angle = c_angle + i * 360 / 13;
					let tx = cx + r * cos(p_angle);
					let ty = cy + r * sin(p_angle);
					CreateShot01(GetX(), GetY(), hypot(ty, tx), atan2(ty, tx), 11, 0);
				}
			}
			angle += 180 / 10;
			Wait(40);
		}
	}

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