#e
#Title[jujdv]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\th[.txt"


	let name    = "jujdv";

	//ʒu
	let xini    =GetCenterX;
	let yini    =GetCenterY;

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(750);
	SetTimer(69);
	SetScore(500000);
	SetDamageRate(17,2);
	SetInvincibility(300);

	LoadGraphic(imgboss);
	SetTexture(imgboss);
	SetGraphicRect(0,0,127,127);
	BreakBatafryShotA(300,0,45,8,18);
	Shot();
	}

	@MainLoop{
	if(OnBomb() == false){
	SetCollisionA(GetX,GetY,24);
	SetCollisionB(GetX,GetY,24);}

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss);

	loop(30){
	let x = rand(GetX-32,GetX+32);
	let y = rand(GetY-32,GetY+32);
	CreateItem(ITEM_SCORE,x,y);}
	}

	task BreakBatafryShotA(wait,minangle,addangle,way,atk){
	let i=minangle;
	let rate = [7,26,192,63,169,51,103,134,13,38,116,147,10,44,184,162,100,72,155,85,141,89,15,129,57,121,118,160,0,32,77,187,128,91,30,96,69,53,176,94,125,49,172,173,197,153,23,41,8,94,114,97,191,105,91,110,80,140,112,73,189,144,64,67,36,165,137,142,163,87,19,193,106,47,21,66,151,180,2,198,132,108,88,136,29,43,55,54,82,93,123,140,39,18,76,131,126,43,92,145,62,1,27,115,153,181,24,74,101,31,195,167,117,5,157,177,48,178,17,133,186,135,45,99,111,199,9,59,71,156,120,20,42,166,65,56,182,138,159,61,178,174,22,68,104,148,130,60,175,4,11,171,81,161,28,83,143,168,37,58,170,152,124,75,14,194,132,139,90,46,164,109,84,6,79,200,158,78,12,146,86,33,102,198,149,185,52,183,127,95,196,70,3,113,122,35,117,190,98,16,188,30,107,154,179,25,188,50,119];
	let a = 0;
	loop(60){yield;}
	loop{
	loop(way){let shot1=1;
	CreateShotA(shot1,GetX(),GetY(),30);
	SetShotDataA(shot1,0,1.5,i,0,0,0,RED22);
	let j = 0;
		while(j<= atk){
		if(a >= length(rate)){a -= length(rate);}
		let shot2=2;
		CreateShotA(shot2,0,0,10);
		SetShotDataA(shot2,0,rand(0.1,0.3),360*rate[a]/200,0,rand(0,0.05),3,RED04);
		j++;
		a++;
		AddShot(45,shot1,shot2,0);}
	SetShotKillTime(shot1,46);
	FireShot(shot1);
	i+=addangle;}
	loop(wait){yield;}
	}
	}

	function BreakBatafryShotB(){
	SetShotDirectionType(PLAYER);
	let i= 0;
	loop(8){let shot1=1;
	CreateShotA(shot1,GetX(),GetY(),30);
	SetShotDataA(shot1,0,2.5,i,0,0,0,BLUE22);
	let k = 0;
	let n = 0;
		while(n<= 16){
		while(k<= 5){
		let shot2=2;
		CreateShotA(shot2,0,0,10);
		SetShotDataA(shot2,0,0.4+k*0.6,n*22.5,0,0,3,BLUE04);
		k++;
		AddShot(45,shot1,shot2,0);}
		k = 0;
		n++;
		}
	SetShotKillTime(shot1,46);
	FireShot(shot1);
	i+=45;}
	SetShotDirectionType(ABSOLUTE);
	}


	task Shot(){
	loop(150){yield;}
	loop{
	BreakBatafryShotB();
	loop(300){yield;}
	}
	}

}