script_enemy_main{
	#include_function ".\drawenemy.txt";
	let ThisShot = GetCurrentScriptDirectory~"ZUN's shotdata.txt";
	let CSD = GetCurrentScriptDirectory;
	let imgFam = CSD ~ "pic\enemy.png";
	let s = 0;
	let switch = 1;
	let gp;
	let dif = 0;
	let r = 120;
	let famangle = GetArgument;
	let spin = 0;
@Initialize{
	LoadUserShotData(ThisShot);
	SetLife(30);
	LoadGraphic(imgFam);
	maintask;
}

@MainLoop{

SetCollisionA(GetX, GetY, 8);
SetCollisionB(GetX, GetY, 8);

yield;


}
	
@DrawLoop{
drawenemy(0);
}
@Finalize{

		loop(4){
		CreateItem(ITEM_SCORE,GetX()+rand(-20,20),GetY()+rand(-20,20));
		}

}

task maintask{
	movement;
	wait(60);
	fire;
	yield;
	}

task movement{
	alternative(famangle)
	case(0){
	SetMovePosition03(rand_int(60,180), rand_int(50,220), 10, 4);
	}
	case(1){
	SetMovePosition03(rand_int(160,280), rand_int(50,220), 10, 4);
	}
	case(2){
	SetMovePosition03(rand_int(250,380), rand_int(50,220), 10, 4);
	}
	case(3){
	SetMovePosition03(rand_int(60,180), rand_int(50,220), 10, 4);
	}
	case(4){
	SetMovePosition03(rand_int(160,280), rand_int(50,220), 10, 4);
	}
	case(5){
	SetMovePosition03(rand_int(250,380), rand_int(50,220), 10, 4);
	}
	}

task fire{
	loop(2){
	gp = GetAngleToPlayer;
	dif = GetX-GetPlayerX;
	ascent(i in 0..6){
	PlaySE(CSD~"sound\shot1.wav");
	CreateShotA(0,GetX,GetY,5);
	if(dif<0 && famangle<3){
	SetShotDataA(0,0,5-i/6,gp-i*7+20,0,-0.1,1.5,7);
	}
	else{
	SetShotDataA(0,0,5-i/6,gp+i*7-20,0,-0.1,1.5,7);
	}
	if(dif<0 && famangle>=3){
	SetShotDataA(0,0,5-i/6,gp+i*7+20,0,-0.1,1.5,7);
	}
	else{
	SetShotDataA(0,0,5-i/6,gp-i*7-20,0,-0.1,1.5,7);
	}
	FireShot(0);
	wait(4);
	}
	wait(60);
	}
	wait(240);
	SetLife(0);
	}

	function wait(w){
		loop(w){yield;}
			}

}