script_enemy_main {
	let csd		=GetCurrentScriptDirectory;
	let shotData	=csd ~ "shot.txt";
	let imgEy	=csd ~ "img\yosei3.png";
	let imgmh	=csd ~ "img\mh.png";
	let imgmhs	=csd ~ "img\mhs.png";
	let imgmhjn	=csd ~ "img\mhjn.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;

    @Initialize {
        SetLife(50);
	SetDamageRate(100,100);
	SetScore(10000);
	LoadGraphic(imgEy);
	LoadGraphic(imgmh);
	LoadGraphic(imgmhs);
	LoadGraphic(imgmhjn);
	LoadUserShotData(shotData);
	SetTexture(imgEy);
	LoadSE(tama);
	TMain;
	}

	@MainLoop {
    	if(GetX<=0 || GetX>=500){VanishEnemy;}
	if(GetY<=-46 || GetY>=550){VanishEnemy;}    
	SetCollisionA(GetX,GetY,16);
	SetCollisionB(GetX,GetY,8);
	yield;
	}

	@DrawLoop
	{
	SetGraphicRect(0,0,64,64);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imgmh);
	DrawGraphic(GetX+30,GetY);
	DrawGraphic(GetX-30,GetY);
	SetGraphicRect(0,0,64,64);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imgmhs);
	DrawGraphic(GetX,GetY);

	SetGraphicRect(0,0,64,64);
	SetGraphicAngle(0,0,GetGapAngle(GetX+30,GetY,GetPlayerX,GetPlayerY)-90);
	SetColor(255,255,255);
	SetTexture(imgmhjn);
	DrawGraphic(GetX+30,GetY);

	SetGraphicRect(0,0,64,64);
	SetGraphicAngle(0,0,GetGapAngle(GetX-30,GetY,GetPlayerX,GetPlayerY)-90);
	SetColor(255,255,255);
	SetTexture(imgmhjn);
	DrawGraphic(GetX-30,GetY);

	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);
	}
	@Finalize{
	attributeB();
	}

    task TMain {
        yield;
standBy;
wait(free3);
loop(2){
shotA;
shotB;
wait(90);
}
IDOUA;
}

sub shotA{
let A=3;
let GATP1=GetGapAngle(GetX+30,GetY,GetPlayerX,GetPlayerY);
let GATP2=GetGapAngle(GetX-30,GetY,GetPlayerX,GetPlayerY);
loop(12){
wait(3);
let angleB=-60;
while(angleB<61){
CreateShot01(GetX+30,GetY,A+2,angleB+GATP1,70,0);
CreateShot01(GetX-30,GetY,A+2,angleB+GATP2,70,0);
angleB+=20;
}
let angleA=-50;
while(angleA<51){
CreateShot01(GetX+30,GetY,A,angleA+GATP1-1,46,0);
CreateShot01(GetX-30,GetY,A,angleA+GATP2-1,46,0);
CreateShot01(GetX+30,GetY,A,angleA+GATP1+1,46,0);
CreateShot01(GetX-30,GetY,A,angleA+GATP2+1,46,0);
angleA+=20;
}
A+=0.2;
}
}

sub shotB{
let angleB=-35;
while(angleB<36){
CreateShot01(GetX,GetY,3,angleB+GetAngleToPlayer+1,70,0);
CreateShot01(GetX,GetY,3,angleB+GetAngleToPlayer-1,70,0);
CreateShot01(GetX,GetY,3,angleB+GetAngleToPlayer,70,0);
angleB+=10;
}
let angleB=-30;
while(angleB<31){
CreateShot01(GetX,GetY,1.9,angleB+GetAngleToPlayer,70,0);
CreateShot01(GetX,GetY,1.8,angleB+GetAngleToPlayer,70,0);
CreateShot01(GetX,GetY,1.7,angleB+GetAngleToPlayer,70,0);
angleB+=10;
}
}

task IDOUA{
loop{
yield;
SetAngle(90);
SetSpeed(3);
}
}


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"
}