script_enemy_main {
	let csd		=GetCurrentScriptDirectory;
	let shotData	=csd ~ "shot.txt";
	let imgEy	=csd ~ "img\yosei5.png";
	let imgmh	=csd ~ "img\mhj.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(190);
	SetDamageRate(100,100);
	SetScore(1000);
	LoadGraphic(imgEy);
	LoadGraphic(imgmh);
	LoadUserShotData(shotData);
	SetTexture(imgEy);
	LoadSE(tama);
	TMain;
	}

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

	@DrawLoop
	{
	SetGraphicRect(0,0,96,96);
	SetGraphicAngle(0,0,0);
	SetColor(255,255,255);
	SetTexture(imgmh);
	DrawGraphic(GetX,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(1);
shotA(-1);
wait(60);
shotB;
wait(120);
}
IDOU;
}

	task shotA(Ang){
		let A=GetAngleToPlayer+120*Ang;
		let S=1;
		loop(13){
			S=1;
			loop(28){
				wayShot(GetX, GetY, S, A, 2, 2, 30, 46, 0);
			S+=0.2;
			}
		A-=10*Ang;
		wait(4);
		}
	}

	sub shotB{
		let S=3;
		loop(4){
			wayShot(GetX, GetY, S, 90, 2, 180, 30, 14, 0);
		wait(10);
		S-=0.8;
		}
	}

task IDOU{
loop{
yield;
SetAngle(90);
SetSpeed(2);
}
}

function wayShot(
	let x,
	let y,
	let speed,
	let angle,
	let interval,
	let way,
	let distance,
	let graphic,
	let delay

){
	let ANGLE = - (way - 1)*interval/2 + angle;
	while(ANGLE<(way - 1)*interval/2 + angle + 0.1){

	CreateShot01(x + cos(ANGLE)*distance, y + sin(ANGLE)*distance, speed, ANGLE, graphic, delay);

	ANGLE += interval;
	}
}

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