#e
#Title[pdcuSXTN̔gv]
#ScriptVersion[2]
#Player[FREE]
#Text[]
#BackGround[User(.\back.png,0,0)]

script_enemy_main
{
let GC=GetCurrentScriptDirectory;
@Initialize
{
LoadGraphic(GC~".\main.png");
SetTexture(GC~".\main.png");
SetGraphicRect(0,0,32,40);
PlayMusic("bgm\fran");
LoadUserShotData(GC~".\burret01.txt");
SetDamageRate(400,0);
	SetScore(100000);
	CutIn(YOUMU,"pdcuSXTN̔gv",GC~".\cut_in.png",100,0,480,480);
SetLife(6000);
Tmain;
Twing;
Tbat;
}
@MainLoop
{
if(OnBomb==false)
	{
	SetCollisionA(GetX,GetY,24);
	SetCollisionB(GetX,GetY,12);
	}

yield;
}
@DrawLoop
{
if(OnBomb==false){DrawGraphic(GetX,GetY);}
}
@Finalize
{
AddScore(10000);
loop(30){CreateItem(ITEM_SCORE,GetX+rand(-50,50),GetY+rand(-30,30))};
DeleteGraphic(GC~".\main.png");
}

#include_function ".\function.txt"

task Tmain
{
loop(60){yield};
SetAlpha(255);
SetDamageRate(10,0);
if(GetX!=GetCenterX||GetY!=GetClipMinY+80)
	{
	if(GetX>GetCenterX){pattern(2);}
	else{pattern(1);}
	SetMovePosition02(GetCenterX,GetClipMinY+80,60);
	}
loop(60){yield};
pattern(0);
SetDamageRate(100,0);
Tattack;
loop
	{
	yield;
	}
}

task Tattack
{
let wait=240;
let way=90;
loop

	{	
	DeleteSE("se\seShot");
	PlaySE("se\seShot");
	let angle=0;
	let X=GetCenterX+rand(-170,170);
	let Y=GetY+rand(0,40);
	loop(way)
		{
		Tstand(X,Y,angle);
		angle=angle+360/way;
		}
	wait=40+GetLife/6000*110;
	loop(wait){yield;}
	}
}

task Tstand(X,Y,angle)
{
let shot=CreateShot01(X,Y,1.5,angle,33,20);
loop
	{
	if(Obj_GetX(shot)<=GetClipMinX||Obj_GetX(shot)>=GetClipMaxX){Obj_SetAngle(shot,180-Obj_GetAngle(shot));break;}
	else if(Obj_GetY(shot)<=GetClipMinY){Obj_SetAngle(shot,-Obj_GetAngle(shot));break;}
	loop(1){yield;}
	}
}

}