#ScriptVersion[2]

script_enemy_main
{
	#include_function ".\init.txt"

	@Initialize
	{
		SetLife(50);

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

	task T_Shot()
	{
		Wait(20);
		loop(2){
			PlaySE(se_shot1);
			let angle = GetAngleToPlayer();
			ascent( let i in 0..30 ){
				CreateShot02(GetX(), GetY(), 8.5, angle + i * 360 / 30, -0.1, 1.0, 116, 5);
			}
			ascent( let j in 0..4 ){
				ascent( let i in 0..30 ){
					let s_angle = angle + (i + 0.5) * 360 / 30;
					CreateShot02(GetX(), GetY(), 1.0, s_angle, 0.08, 8.0, 116, 5);
				}
				Wait(5);
			}
			Wait(60);
		}
	}

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