#搶曽抏枊晽
#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(200);
		SetDamageRate(10,10);
		SetMovePosition02(cx,cy,60);
		SetTimer(60);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(180);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		shottask;
		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 shottask
	{
		let angle=0;
		let s=0;
		let s2=1;
		wait(120);
		CreateObjShot(448-GetPlayerX, 480-GetPlayerY,0,0,32,30);
		loop
		{
			wait(3);
			SetShotDirectionType(ABSOLUTE);
			CreateShotA(s,GetX,GetY,0);	
			SetShotDataA(s,0,3,angle,0,-0.02,0,32);
			SetShotDirectionType(SEQUENCE);
			SetShotDataA(s,300,2,rand(0,180),0,0,3,16);
			FireShot(s);
			angle+=183;
		}
	}
	task CreateObjShot(let x, let y, let speed,let angle, let graphic, let delay)
	{
		let count=0;
		let obj = Obj_Create(OBJ_SHOT);
		Obj_SetPosition(obj, x, y);
		Obj_SetSpeed(obj, 0);
		ObjShot_SetGraphic(obj, graphic);
		ObjShot_SetDelay(obj, delay);
		ObjShot_SetBombResist(obj, true);
		Obj_SetAutoDelete(obj,false);
		while(!Obj_BeDeleted(obj))
		{
			if(count%6==0&&count>60)
			{
				CreateShot01(Obj_GetX(obj),Obj_GetY(obj),2,rand(0,360),16,0);
			}
			Obj_SetPosition(obj,448-GetPlayerX, 480-GetPlayerY);
			count++;
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}