script_enemy_main {
	let csd		=GetCurrentScriptDirectory;
	let shotData	=csd ~ "shot.txt";
	let imgEy	=csd ~ "img\yosei2.png";
	let imgmh	=csd ~ "img\mhj.png";
	let imgmhj	=csd ~ "img\mh.png";
	let imghks	=csd ~ "img\hks.png";
	let tama	=csd ~ "img\tama.wav";
	let po		=GetArgument[0];
	let free1	=GetArgument[1];
	let free2	=GetArgument[2];
	let free3	=GetArgument[3];
	let dr		=0;
	let drsign	=1;
	let opx1	=0;
	let opy1	=0;
	let opx2	=0;
	let opy2	=0;
	let opr		=0;
	let DD		=0;

    @Initialize {
        SetLife(800);
	SetDamageRate(0,0);
	SetScore(10000);
	LoadGraphic(imgEy);
	LoadGraphic(imgmh);
	LoadGraphic(imghks);
	LoadGraphic(imgmhj);
	LoadUserShotData(shotData);
	SetTexture(imgEy);
	LoadSE(tama);
	TMain;
	}

    @MainLoop {
	opr++;
	opx1=GetX+cos(opr)*160;
	opy1=GetY+sin(opr)*90;
	opx2=GetX+cos(opr+180)*160;
	opy2=GetY+sin(opr+180)*90;
	if(GetY<=-190 || GetY>=550){VanishEnemy;}    
	SetCollisionA(GetX,GetY,16);
	SetCollisionB(GetX,GetY,8);
	SetCollisionA(opx1,opy1,16);
	SetCollisionB(opx1,opy1,8);
	SetCollisionA(opx2,opy2,16);
	SetCollisionB(opx2,opy2,8);
	SetCollisionA(GetX+60,GetY-40,16);
	SetCollisionB(GetX-60,GetY-40,16);
	SetCollisionA(GetX+60,GetY-40,16);
	SetCollisionB(GetX+60,GetY-40,16);
	yield;
	}

	@DrawLoop
	{

	SetGraphicRect(0,0,96,96);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imgmh);
	DrawGraphic(GetX+60,GetY-40);
	DrawGraphic(GetX-60,GetY-40);

	SetGraphicRect(0,0,64,64);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imgmhj);
	DrawGraphic(GetX,GetY);
	DrawGraphic(GetX+40,GetY+30);
	DrawGraphic(GetX-40,GetY+30);

	dr+=drsign;
	if(dr>=0 && dr<=3){SetGraphicRect(0,0,31,31);}
	else if(dr>=4 && dr<=10){SetGraphicRect(32,0,63,31);}
	else {SetGraphicRect(64,0,95,31);}
	if(dr>=10){drsign=-drsign;}
	if(dr<=0){drsign=-drsign;}
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imgEy);
	DrawGraphic(GetX,GetY);

	SetGraphicRect(0,0,120,120);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imghks);
	DrawGraphic(opx1,opy1);
	DrawGraphic(opx2,opy2);

	}
	@Finalize{
	attributeB();
	//if(BeVanished==false){
	//DeleteEnemyShotToItem(ALL);
	//}
	}

    task TMain {
        yield;
standBy;
wait(free3);
SetDamageRate(4,0);
shotop;
IDOU;
wait(120);
loop(2){
shotA;
wait(120);
shotB;
wait(60);
shotC_1;
wait(30);
shotC_2;
wait(60);
shotC_2;
wait(120);
}
SetDamageRate(100,100);
shoto;
shotD;
wait(40);
IDOUA;
}

task shotop{
let A=2;
loop(40){
wait(2);
let angleB=-40;
while(angleB<41){
CreateShot01(opx1-4,opy1,A,angleB+90,46,0);
CreateShot01(opx2-4,opy2,A,angleB+90,46,0);
CreateShot01(opx1+4,opy1,A,angleB+90,46,0);
CreateShot01(opx2+4,opy2,A,angleB+90,46,0);
angleB+=20;
}
A+=0.2;
}
}

task shoto{
let A=4;
loop(270){
if(9>=A){A+=0.25;}
wait(2);
let angleB=-40;
while(angleB<41){
CreateShot01(opx1-4,opy1,A,angleB+90,46,0);
CreateShot01(opx2-4,opy2,A,angleB+90,46,0);
CreateShot01(opx1+4,opy1,A,angleB+90,46,0);
CreateShot01(opx2+4,opy2,A,angleB+90,46,0);
angleB+=80;
}
}
}

task shotA{
let A=2;
let GATP1=GetGapAngle(GetX+60,GetY-40,GetPlayerX,GetPlayerY);
let GATP2=GetGapAngle(GetX-60,GetY-40,GetPlayerX,GetPlayerY);
loop(3){
let angleA=-30;
while(angleA<31){
let angleB=-10;
while(angleB<11){
CreateShot01(GetX+60,GetY-40,A,angleA+angleB+GATP1,14,0);
CreateShot01(GetX-60,GetY-40,A,angleA+angleB+GATP2,14,0);
angleB+=1.5;
}
angleA+=30;
}
A+=0.2;
}
wait(60);
let A=2;
loop(3){
let angleA=-45;
while(angleA<46){
let angleB=-10;
while(angleB<11){
CreateShot01(GetX+60,GetY-40,A,angleA+angleB+GATP1,14,0);
CreateShot01(GetX-60,GetY-40,A,angleA+angleB+GATP2,14,0);
angleB+=1.5;
}
angleA+=30;
}
A+=0.2;
}
}

task shotC_1{
let B=2;
loop(30){
wait(6);
let GATP1=GetGapAngle(GetX+40,GetY+30,GetPlayerX,GetPlayerY);
let GATP2=GetGapAngle(GetX-40,GetY+30,GetPlayerX,GetPlayerY);
let A=B;
loop(4){
let angleB=-105;
while(angleB<106){
CreateShot01(GetX+40,GetY+30,A,angleB+GATP1,14,0);
CreateShot01(GetX-40,GetY+30,A,angleB+GATP2,14,0);
angleB+=30;
}
A+=0.3;
}
B+=0.2;
}
}

task shotC_2{
let B=4;
loop(12){
wait(3);
let GATP1=GetGapAngle(GetX+60,GetY-40,GetPlayerX,GetPlayerY);
let GATP2=GetGapAngle(GetX-60,GetY-40,GetPlayerX,GetPlayerY);
let A=B;
loop(4){
CreateShot01(GetX+60,GetY-40,A+1,GATP1,70,0);
CreateShot01(GetX-60,GetY-40,A+1,GATP2,70,0);
A+=0.2;
}
B+=0.4;
}
}

sub shotB{
let A=0;
loop(45){
wait(1);
CreateShot01(GetX+40,GetY+30,2,A,46,0);
CreateShot01(GetX-40,GetY+30,2,180-A,46,0);
CreateShot01(GetX+40,GetY+30,2.2,A,46,0);
CreateShot01(GetX-40,GetY+30,2.2,180-A,46,0);
A+=6;
}
}

sub shotD{
let A=3;
let B=0;
loop(90){
wait(6);
let angleB=-0;
while(angleB<360){
CreateShot01(GetX+40,GetY+30,A,angleB-B,14,0);
CreateShot01(GetX-40,GetY+30,A,angleB+B,14,0);
CreateShot01(GetX+40,GetY+30,A+0.1,angleB-B+1,14,0);
CreateShot01(GetX-40,GetY+30,A+0.1,angleB+B-1,14,0);
angleB+=60;
}
B+=13;
}
DD=1;
}

sub IDOUA{
loop{
yield;
SetAngle(270);
SetSpeed(1.5);
}
}

task IDOU {
let angle=90;
loop{
if(DD==0){
SetY(free2+10*sin(angle));
SetX(free1+32*cos(angle));
}
yield;
angle+=1;
}
}

function GetGapAngle(
	let x1,
	let y1,
	let x2,
	let y2
){
	return atan2(y2-y1,x2-x1);
}

    task standBy {
	SetMovePosition02(free1,free2,free3);
        SetInvincibility(free3);
}


function wait(w) {
    loop(w) { yield; }
}
#include_function ".\zako.txt"
}