#ScriptVersion[2]

script_enemy_main
{
	#include_function ".\init.txt"

	@Initialize
	{
		SetLife(240);

		SetTexture(img_fairy);

		LoadUserShotData(shot_00);

		InitializeAction();
		SetFairyType(3);

		T_Main();
		T_HitTest(32);
	}

	@Finalize
	{
		if( GetLife() <= 0 ){
			CreateItemCircle(GetX(), GetY(), 5, 10);
		}
	}

	@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 / 30;
		loop(30){
			v += a;
			SetSpeed(v);
			yield;
		}
		Wait(180);
		if( GetX() < GetCenterX() ){
			SetAngle(150);
		}
		else{
			SetAngle(0);
		}
		SetSpeed(3.0);
	}

	task T_Shot()
	{
		Wait(30);
		CreateShot02(GetX(), GetY(), 0.0, GetAngleToPlayer(), 0.02, 8.0, 197, 0);
		let angle = 90;
		ascent( let i in 0..10 ){
			PlaySE(se_shot1);
			ascent( let j in 0..12 ){
				CreateCircleShot(angle + j * 360 / 12, 26);
			}
			ascent( let j in 0..12 ){
				CreateCircleShot(180 - angle - j * 360 / 12, 26);
			}
			angle += 2.3 * GetArgument();
			Wait(9);
		}
	}

	function CreateCircleShot(angle, type)
	{
		CreateShotA(0, GetX(), GetY(), 0);
		SetShotDataA(0,   0, 5.0, angle, 0, -0.1, 0.0, type);
		SetShotDataA(0,  90, NULL, NULL, 0, 0.04, 8.0, type);
		FireShot(0);
	}

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