#東方弾幕風
#Title[日暮し「不和非ずの勾玉」]
#Text[試作]
#ScriptVersion[2]

script_enemy_main
{
	let cx=GetCenterX();
	let cy=GetCenterY();
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetScore(30000);
		SetLife(500);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy-120,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(60);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		movetask;
		CutIn(YOUMU,"日暮し「不和非ずの勾玉」",0,0,0,0,0);
	}
	@MainLoop
	{
		yield;
		SetCollisionA(GetX(),GetY(),24);
		SetCollisionB(GetX(),GetY(),24);
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		SetAlpha(255);
		DrawGraphic(GetX(),GetY());
	}
	task movetask
	{
		wait(120);
		loop
		{
			loop(180)
			{
				SetAngle(GetAngleToPlayer);
				SetSpeed(1);
				yield;
			}
			SetMovePosition02(GetPlayerX,GetPlayerY,60);
			wait(60);
		}
	}
	task shottask
	{
		SetShotAutoDeleteClip(512,512,512,512);
		let angle=0;
		let s=0;
		wait(120);
		loop
		{
			loop(240)
			{
				wait(1);
				SetShotDirectionType(ABSOLUTE);
				CreateShotA(s,GetX,GetY,0);	
				SetShotDataA(s,0,3,angle,0,-0.05,0,17);
				SetShotDirectionType(PLAYER);
				SetShotDataA(s,180,0,0,0,0.05,3,17);
				FireShot(s);
				CreateShotA(s,GetPlayerX,GetPlayerY,20);
				SetShotDataA(s,0,0,0,0,0,0,8);	
				SetShotKillTime(s,0);
				FireShot(s);
				CreateShotA(s,GetX,GetY,20);
				SetShotDataA(s,0,0,0,0,0,0,17);	
				SetShotKillTime(s,0);
				FireShot(s);
				angle+=6;
			}
			loop(30)
			{
				CreateShotA(s,GetX,GetY,10);
				SetShotDataA(s,0,5,angle,0,-0.1,0.1,254);
				FireShot(s);
				angle+=12;
			}
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}