e
#Title[WʏS]
#Text[]
#BackGround[DEFAULT]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
	#include_function ".\init.txt"
	#include_function ".\lib\lib_anime_Range.txt"

	@Initialize
	{
		SetLife(2200);
		StartSetting(35, 0, "");
		SetInvincibility(360);

		InitPosition(GetCenterX(), GetClipMinY() + 120);

		LoadGraphic(img_range);

		LoadUserShotData(shot_00);
		SetShotAutoDeleteClip(64, 16, 64, 16);

		InitializeAction();
		DeleteEnemyShot(ALL);
		LoadSE(se_shot1);
		LoadSE(se_shot2);

		T_Main();
		T_DamageRate(100, 100, 0, -1);
		T_HitTest(48);
	}

	@Finalize
	{
		DeleteGraphic(img_range);
		DeleteSE(se_shot1);
		DeleteSE(se_shot2);
		ClearBG();
	}

	@DrawLoop
	{
		SetAlpha([255, 128][IsExMode() && OnBomb()]);
		DrawBoss(img_range);
	}

	task T_Main()
	{
		yield;

		Wait(180);
		SetColor(255, 255, 255);
		Concentration01(30);
		SetColor(255, 255, 255);
		Wait(30);

		T_Move();
		T_Circle();
	}

	task T_Move()
	{
		Wait(120);
		loop{
			SetAction(ACT_MOVE, 30);
			MoveActA(GetY(), GetY());
			Wait(120);
		}
	}

	task T_Circle()
	{
		SetAction(ACT_SHOT_B, 60);
		PlaySE(se_shot2);
		ascent( let i in 0..18 ){
			let f_shot = (i % 6 == 0);
			CreateBaseShot(GetX(), GetY(), i * 360 / 18, [18, 11][f_shot], f_shot);
		}
		Wait(120);
		loop{
			PlaySE(se_shot1);
			Wait(6);
		}
	}

	task CreateBaseShot(cx, cy, angle, type, f_shot)
	{
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, cx, cy);
		Obj_SetAngle(obj, -90);
		Obj_SetAutoDelete(obj, false);
		ObjShot_SetBombResist(obj, true);
		ObjShot_SetGraphic(obj, type);

		let r = 0;
		let v = 4.0;
		let a = -v / 60;
		let d_angle = 0;
		let dd_angle = -1.6 / 60;
		let s_angle = 0;
		let count = 0;
		loop{
			cx = GetX();
			if( count < 60 ){
				v += a;
				r += v;
			}
			if( count >= 60 && count < 120 ){
				d_angle += dd_angle;
			}
			angle += d_angle;
			let x = cx + r * cos(angle);
			let y = cy + r * sin(angle);
			Obj_SetPosition(obj, x, y);
			if( f_shot && count >= 120 && count % 6 == 0 ){
				ascent( let i in 0..3 ){
					CreateShot01(x, y, 3.4, s_angle + i * 360 / 3, 118, 0);
					CreateShot01(x, y, 3.1, s_angle + i * 360 / 3, 112, 0);
				}
				s_angle -= 8;
			}
			count ++;
			yield;
		}
	}

	#include_function ".\f_base.txt"
	#include_function ".\f_enemy.txt"
	#include_function ".\f_boss.txt"
	#include_function ".\f_bg_mystia.txt"
}
