#e
#Title[zu̖Sv]
#Text[]
#ScriptVersion[2]
script_enemy_main
{
	let cx=GetCenterX();//STGV[̒SxW擾
	let cy=GetCenterY();//STGV[̒SyW擾
	let imgExRumia=GetCurrentScriptDirectory~"img\ExRumia.png";
	let imgExRumiaBack=GetCurrentScriptDirectory~"img\ExRumiaBack.png";
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(1500);
		SetDamageRate(10,0);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(120);
		LoadGraphic(imgExRumia);
		SetTexture(imgExRumia);	
		SetEffectForZeroLife(60,100,2);
		shottask;
		shottask2;
		bombtask;
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
		loop(8)
		{
			CreateItem(ITEM_SCORE,cx+rand(-100,100),rand(20,100));
		}
	}
	@DrawLoop
	{
		SetGraphicRect(1,1,64,64);
		DrawGraphic(GetX(),GetY());
	}
	task shottask
	{
		let s=0;
		let s2=1;
		SetShotAutoDeleteClip(64,512,64,64);
		SetMovePosition02(cx,-120,0);
		wait(60);
		SetMovePosition02(cx,cy-120,60);
		wait(120);
		SetScore(30000);
		SetTimer(99);
		CutIn(YOUMU,"zu̖Sv",0,0,0,0,0);
		wait(120);
		loop
		{
			if(GetEnemyLife>1125)
			{
				wait(20);
				shot(s,s2,rand(30,90),1);
				wait(20);
				shot(s,s2,rand(30,90),0);
			}
			if(GetEnemyLife<=1125&&GetEnemyLife>750)
			{
				wait(30);
				shot(s,s2,rand(30,90),1);
				wait(30);
				shot(s,s2,rand(30,90),0);
			}
			if(GetEnemyLife<=750&&GetEnemyLife>375)
			{
				loop(2)
				{
					wait(3);
					shot(s,s2,rand(30,90),1);
				}
				loop(2)
				{
					wait(3);
					shot(s,s2,rand(30,90),0);
				}
				wait(30);
			}
			if(GetEnemyLife<=375||GetTimer<30)
			{
				loop(5)
				{
					wait(3);
					shot(s,s2,rand(30,90),1);
				}
				loop(5)
				{
					wait(3);
					shot(s,s2,rand(30,90),0);
				}
				wait(50);
			}
		}
	}
	task shottask2
	{
		let s=0;
		let angle=0;
		wait(300);
		loop
		{
			angle=rand(0,360);
			loop(36)
			{
				CreateShotA(s,GetX,GetY,0);
				SetShotDataA(s,0,5,angle,0,-0.1,1.5,128);
				FireShot(s);
				angle-=10;
			}
			if(GetEnemyLife>1125)
			{
				wait(120);
			}
			if(GetEnemyLife<=1125&&GetEnemyLife>750)
			{
				wait(90);
			}
			if(GetEnemyLife<=750&&GetEnemyLife>375)
			{
				wait(60);
			}
			if(GetEnemyLife<=375||GetTimer<30)
			{
				wait(30);
			}
		}
	}
	task bombtask
	{
		loop
		{
			if(OnBomb)
			{
				SetAlpha(64);
				SetDamageRate(0,0);
			}
			else
			{
				SetAlpha(255);
				SetDamageRate(10,0);
				SetCollisionA(GetX(),GetY(),24);
				SetCollisionB(GetX(),GetY(),24);
			}
			yield;
		}
	}
	function shot(let shotid,let shotid2,let shottime,let right)
	{
		let long =48;
		let speed=0;
		let po =0;
		let point=0;
		let r=90;
		let angle=0;
		let carb=0;
		let time=shottime;
		if(right==1)
		{
			point=GetClipMaxX+32;
			angle=rand(220,260);
			carb=rand(-1,0);
		}
		else
		{
			point=GetClipMinX-32;
			angle=rand(320,280);
			carb=rand(1,0);
		}
		CreateLaserC(shotid,point,rand(GetClipMinY,GetClipMaxY),10,long,160,0);
		SetLaserDataC(shotid,0,6,angle,carb,0,2);
		loop(12)
		{
			CreateShotA(shotid2,0,0,0);
			SetShotDataA(shotid2,0,0,90,0,0,3,253);
			SetShotDataA(shotid2,shottime-time,0,rand(260,280),0,0,3,74);
			SetShotDataA(shotid2,shottime-time+10,0,rand(85,95),0,0.1,rand(1.5,2.5)+speed,74);
			AddShot(time,shotid,shotid2,48);	
			time-=4;
			speed-=0.03;
		}
		SetShotKillTime(shotid,shottime);
		FireShot(shotid);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}