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

@MainLoop{

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

yield;


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

	//DeleteGraphic(imgFam);

}

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

task fire{
	SetColor(0, 255, 255); 
	Concentration01(30);
	SetColor(255, 255, 255); 
	wait(30);
	fire2;
	loop(10){
	PlaySE(CSD~"sound\shot1.wav");
	ascent(i in 0..4){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,angle+i*90,0,0,0,73);
	FireShot(0);
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,-angle+i*90,0,0,0,73);
	FireShot(0);
	}
	if(famangle<3){
	angle+=2;
	}
	else{
	angle+=1;
	}
	wait(5);
	}
	loop(10){
	PlaySE(CSD~"sound\shot1.wav");
	ascent(i in 0..4){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,angle+i*90,0,0,0,73);
	FireShot(0);
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,-angle+i*90,0,0,0,73);
	FireShot(0);
	}
	wait(5);
	if(famangle<3){
	angle-=2;
	}
	else{
	angle-=1;
	}
	}
	///////////////////////////////////////////
	wait(30);
	fire2;
	loop(10){
	PlaySE(CSD~"sound\shot1.wav");
	ascent(i in 0..4){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,angle+i*90+45,0,0,0,73);
	FireShot(0);
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,-angle+i*90+45,0,0,0,73);
	FireShot(0);
	}
	if(famangle<3){
	angle+=2;
	}
	else{
	angle+=1;
	}
	wait(5);
	}
	loop(10){
	PlaySE(CSD~"sound\shot1.wav");
	ascent(i in 0..4){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,angle+i*90+45,0,0,0,73);
	FireShot(0);
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,2.5,-angle+i*90+45,0,0,0,73);
	FireShot(0);
	}
	wait(5);
	if(famangle<3){
	angle-=2;
	}
	else{
	angle-=1;
	}
	}
	}

task fire2{
	loop(6){
	ascent(i in 0..24){
	CreateShot01(GetX,GetY,1.8,i*15+360*sin(angle),9,0);
	}
	wait(20);
	angle2 += 37;
	}
	}

task movement{
	alternative(famangle)
	case(0){
	SetMovePosition03(GetCenterX, GetCenterY-100, 10, 4);
	wait(360);
	SetMovePosition03(-50, GetCenterY-100, 10, 2);
	wait(180);
	}
	case(1){
	SetMovePosition03(GetCenterX+100, GetCenterY-150, 10, 7);
	wait(360);
	SetMovePosition03(500, GetCenterY-100, 10, 2);
	wait(180);
	}
	case(2){
	SetMovePosition03(GetCenterX-100, GetCenterY-150, 10, 7);
	wait(360);
	SetMovePosition03(-50, GetCenterY-150, 10, 2);
	wait(180);
	}
	case(3){
	SetMovePosition03(GetCenterX+100, GetCenterY-150, 10, 7);
	wait(360);
	SetMovePosition03(-50, GetCenterY-150, 10, 2);
	wait(180);
	}
	case(4){
	SetMovePosition03(GetCenterX-100, GetCenterY-150, 10, 7);
	wait(360);
	SetMovePosition03(-50, GetCenterY-150, 10, 2);
	wait(180);
	}
	VanishEnemy;
	}

task tailbullet(x, y, v, dir, graphic, delay,check) 
	{
    	 let obj = Obj_Create(OBJ_SHOT);
	 let c = 0;
    	 Obj_SetPosition   (obj, x, y);
    	 Obj_SetSpeed      (obj, v);
    	 Obj_SetAngle      (obj, dir);
    	 ObjShot_SetGraphic(obj, graphic);
    	 ObjShot_SetDelay  (obj, delay);
	 ObjShot_SetBombResist(obj, true);
		 while(! Obj_BeDeleted(obj)) 
		{
		 yield;
		}
	}

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

}