#東方弾幕風
#Title[犠牲「スーサイドパクト」]
#Text[試作]
#ScriptVersion[2]
script_enemy_main
{
	let count=0;
	let cx=GetCenterX();//STGシーンの中心x座標を取得
	let cy=GetCenterY();//STGシーンの中心y座標を取得
	let doll=0;
	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-120,60);
		SetTimer(40);
		SetGraphicRect(1,1,64,64);
		SetInvincibility(180);
		LoadGraphic(imgExRumia);
		LoadGraphic(GetCurrentScriptDirectory~".\img\enemy\faily_red.png");
		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 s=0;
		let angle=45; 
		let angle2=0; 
		let a=0;
		wait(120);
		loop
		{
			loop(12)
			{
				CreateEnemyFromScript("doll",rand(GetClipMinX-20,GetClipMaxX+20),rand(GetClipMinY-20,GetClipMaxY+20),0.5,angle,a);
			}
			loop(18)
			{
				CreateShot01(GetX,GetY,1,angle2,73,0);
				angle2+=20;
			}
			a++;
			if(angle==45)
			{
				angle=135;
			}
			else
			{
				angle=45;
			}
			if(a==4)
			{
				a=0;	
			}
			wait(120);
		}
	}
	task shottask2
	{
		let s=0;
		loop
		{	
			yield;
		}
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}
script_enemy doll
{
	let a=GetArgument;
	let alpha=0;
	LoadUserShotData(GetCurrentScriptDirectory~"shot.txt");
	@Initialize
	{
		SetLife(500);
		SetDamageRate(0,0);
		SetInvincibility(60);
		SetTexture(GetCurrentScriptDirectory~".\img\enemy\faily_red.png");	
		shottask;
	}
	@MainLoop
	{
		yield;
	}
	@Finalize
	{
	}
	@DrawLoop
	{
		SetShotDirectionType(ABSOLUTE);
		if(a==1||a==3)
		{
			SetGraphicRect(128,0,160,35);
			SetGraphicAngle(180,0,0);
		}
		else
		{
			SetGraphicRect(128,0,160,35);
			SetGraphicAngle(0,0,0);
		}
		SetAlpha(alpha);
		DrawGraphic(GetX(),GetY());
		if(alpha<255)
		{
			alpha+=5;
		}
	}
	task shottask
	{
		let s=0;
		let angle=rand(0,360);
		wait(150);
		Concentration01(30);
		wait(30);
		loop(64)
		{
			CreateShotA(s,GetX,GetY,0);
			SetShotDataA(s,0,rand(2,4),rand(0,360),0,0,0,0);
			SetShotKillTime(s,15);
			FireShot(s);
		}
		loop(6)
		{
			CreateShot01(GetX,GetY,1,angle,73,0);
			angle+=60;
		}
		SetLife(0);
	}
	function wait(w) 
	{
		loop(w)
		{
			yield;
		}
	}
}