#ScriptVersion[2]

script_enemy_main
{
	#include_function ".\init.txt"

	@Initialize
	{
		SetLife(180);

		SetTexture(img_fairy);

		LoadUserShotData(shot_00);

		InitializeAction();
		SetFairyType(3);

		T_Main();
		T_HitTest(32);
	}

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

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

	task T_Main()
	{
		yield;

		T_Move();
		T_Chain();
		Wait(10);

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

	task T_Move()
	{
		let v = GetSpeed();
		let a = -v / 40;
		loop(40){
			v += a;
			SetSpeed(v);
			yield;
		}
		Wait(60);
		if( GetX() < GetCenterX() ){
			SetAngle(180);
		}
		else{
			SetAngle(0);
		}
		a = 0.04;
		loop(60){
			v += a;
			SetSpeed(v);
			yield;
		}
	}

	task T_Chain()
	{
		Wait(40);
		SetCommonData("x7_09_sub", 1);
		SetCommonData("x7_09_sub_x", GetX());
		SetCommonData("x7_09_sub_y", GetY());
	}

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