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 count = 0;
	let r = 120;
	let famangle = GetArgument;
	let spin = 0;
@Initialize{
	LoadUserShotData(ThisShot);
	SetLife(300);
	LoadGraphic(imgFam);
	maintask;
}

@MainLoop{

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

yield;


}
	
@DrawLoop{
drawenemy(0);
}
@Finalize{
		loop(12){
		CreateItem(ITEM_SCORE,GetX()+rand(-20,20),GetY()+rand(-20,20));
		}

}

task maintask{
	movement;
	fire;
	yield;
	}

task fire{
	wait(60);
	SetColor(255, 255, 0); 
	Concentration01(30);
	SetColor(255, 255, 255); 
	wait(30);
	if(famangle%2!=0){switch= -1;}
	ascent(n in 0..35){
	PlaySE(CSD~"sound\shot1.wav");
	ascent(i in 0..4){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,4,i*90+n*6*switch,0,-0.05,1.7,77);
	FireShot(0);
	}
	ascent(i in 0..3){
	CreateShotA(0,GetX,GetY,0);
	SetShotDataA(0,0,-4,i*120-n*5*switch+60,0,0.1,1.7,95);
	FireShot(0);
	}
	wait(4);
	}
	ascent(n in 0..3){
	PlaySE(CSD~"sound\shot1.wav");
	ascent(i in 0..10){
	CreateShotA(0,GetX,GetY,20);
	SetShotDataA(0,0,2,i*36+n*18,0,0,0,23);
	FireShot(0);
	}
	wait(25);
	}
	}

task movement{
	alternative(famangle)
	case(0){
	SetMovePosition03(GetCenterX-100, GetCenterY-150, 10, 7);
	wait(240);
	SetMovePosition03(-50, GetCenterY-150, 10, 2);
	}
	case(1){
	SetMovePosition03(GetCenterX+100, GetCenterY-150, 10, 7);
	wait(240);
	SetMovePosition03(500, GetCenterY-150, 10, 2);
	}
	case(2){
	SetMovePosition03(GetCenterX-50, GetCenterY-100, 10, 7);
	wait(240);
	SetMovePosition03(-50, GetCenterY-150, 10, 2);
	}
	case(3){
	SetMovePosition03(GetCenterX+50, GetCenterY-100, 10, 7);
	wait(240);
	SetMovePosition03(500, GetCenterY-150, 10, 2);
	}
	wait(150);
	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;}
			}

}