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

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

	@Initialize
	{
		StartPlural();

		SetLife(2900);
		StartSetting(45, 0, "");
		SetInvincibility(240);

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

		LoadGraphic(img_range);

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

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

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

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

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

	task T_Main()
	{
		yield;

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

		T_Circle();
	}

	task T_Circle()
	{
		let k = 0;
		loop{
			SetAction(ACT_SHOT_B, 60);
			let angle = 90 + k * 180 / 14;
			PlaySE(se_shot2);
			ascent( let i in 0..14 ){
				CreateCircle(GetX(), GetY(), angle);
				angle += 360 / 14;
			}
			Wait(300);
			k = 1 - k;
		}
	}

	task CreateCircle(x, y, angle)
	{
		let obj_s = [];
		let obj_b = [];

		ascent( let i in 0..16 ){
			obj_s = obj_s ~ [Obj_Create(OBJ_SHOT)];
			ObjShot_SetGraphic(obj_s[i], 16);
			Obj_SetAutoDelete(obj_s[i], false);
		}
		ascent( let i in 0..8 ){
			obj_b = obj_b ~ [Obj_Create(OBJ_SHOT)];
			ObjShot_SetGraphic(obj_b[i], 41);
			Obj_SetAutoDelete(obj_b[i], false);
		}

		let v = 3.4;
		let vx = v * cos(angle);
		let vy = v * sin(angle);
		let ax = -vx / 60 * 2.7 / 3.5;
		let ay = -vy / 60 * 2.7 / 3.5;
		let r = 0;
		let dr = 3.0;
		let ddr = -3.0 / 60;
		let angle_s = rand(0, 360);
		let angle_b = angle;
		let count = 0;

		loop{
			x += vx;
			y += vy;
			r += dr;
			if( count < 60 ){
				vx += ax;
				vy += ay;
				dr += ddr;
			}

			if( IsOutOfClipRange(x, y, r + 32) ){
				ascent( let i in 0..16 ){
					Obj_Delete(obj_s[i]);
				}
				ascent( let i in 0..8 ){
					Obj_Delete(obj_b[i]);
				}
				break;
			}

			ascent( let i in 0..16 ){
				let angle_st = angle_s + i * 360 / 16;
				Obj_SetPosition(obj_s[i], x + r * cos(angle_st), y + r * sin(angle_st));
			}
			ascent( let i in 0..8 ){
				let angle_bt = angle_b + i * 360 / 8;
				Obj_SetPosition(obj_b[i], x + r * cos(angle_bt), y + r * sin(angle_bt));
			}
			angle_s += 0.8;
			angle_b -= 1.0;

			count ++;
			yield;
		}
	}

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