#ScriptVersion[2]

script_enemy_main
{
	#include_function ".\init.txt"

	@Initialize
	{
		SetLife(75);

		SetTexture(img_fairy);

		LoadUserShotData(shot_00);

		InitializeAction();
		SetFairyType(1);

		T_Main();
		T_HitTest(16);
	}

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

	@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(150);
		a = 0.05;
		loop(60){
			v += a;
			SetSpeed(v);
			yield;
		}
	}

	task T_Shot()
	{
		Wait(20);
		loop(3){
			PlaySE(se_shot1);
			let angle = GetAngleToPlayer() - 360 / 36;
			ascent( let i in 0..12 ){
				ascent( let j in 0..3 ){
					CreateShotA(0, GetX(), GetY(), 0);
					SetShotDataA(0,  0, 1.0, angle, 0.0, 0.06, 8.0, 45);
					SetShotDataA(0, 40, NULL, NULL, (1 - j) * 0.6, 0.06, 8.0, 45);
					SetShotDataA(0, 80, NULL, NULL, 0.0, 0.06, 8.0, 45);
					FireShot(0);
					angle += 360 / 36;
				}
			}
			Wait(45);
		}
	}

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