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

@MainLoop{

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

yield;


}
	
@DrawLoop{
drawenemy(2);
}
@Finalize{
		loop(7){
		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(100, GetCenterY-120, 10, 4);
	wait(120);
	SetMovePosition03(-50, GetCenterY-120, 10, 1);
	}
	case(1){
	SetMovePosition03(350, GetCenterY-120, 10, 4);
	wait(120);
	SetMovePosition03(500, GetCenterY-120, 10, 1);
	}
	case(2){
	SetMovePosition03(150, GetCenterY-120, 10, 4);
	wait(120);
	SetMovePosition03(-50, GetCenterY-120, 10, 1);
	}
	case(3){
	SetMovePosition03(300, GetCenterY-120, 10, 4);
	wait(120);
	SetMovePosition03(500, GetCenterY-100, 10, 1);
	}
	case(4){
	SetMovePosition03(GetCenterX, GetCenterY-100, 10, 4);
	wait(120);
	SetMovePosition03(-50, GetCenterY-100, 10, 1);
	}
	case(5){
	SetMovePosition03(GetCenterX+100, GetCenterY-100, 10, 6);
	wait(120);
	SetMovePosition03(-50, GetCenterY-100, 10, 2);
	}
	case(6){
	SetMovePosition03(GetCenterX-100, GetCenterY-100, 10, 6);
	wait(120);
	SetMovePosition03(500, GetCenterY-100, 10, 2);
	}
	case(7){
	SetMovePosition03(GetCenterX+180, GetCenterY-100, 10, 6);
	wait(120);
	SetMovePosition03(-50, GetCenterY-100, 10, 2);
	}
	case(8){
	SetMovePosition03(GetCenterX-180, GetCenterY-100, 10, 6);
	wait(120);
	SetMovePosition03(500, GetCenterY-100, 10, 2);
	}
	case(9){
	SetMovePosition03(80, GetCenterY-80, 10, 6);
	wait(120);
	SetMovePosition03(-50, GetCenterY-80, 10, 2);
	}
	case(10){
	SetMovePosition03(160, GetCenterY-80, 10, 6);
	wait(120);
	SetMovePosition03(-50, GetCenterY-80, 10, 2);
	}
	case(11){
	SetMovePosition03(240, GetCenterY-80, 10, 6);
	wait(120);
	SetMovePosition03(500, GetCenterY-80, 10, 2);
	}
	case(12){
	SetMovePosition03(320, GetCenterY-80, 10, 6);
	wait(120);
	SetMovePosition03(500, GetCenterY-80, 10, 2);
	}
	case(13){
	SetMovePosition03(400, GetCenterY-80, 10, 6);
	wait(120);
	SetMovePosition03(500, GetCenterY-80, 10, 2);
	}
	wait(210);
	VanishEnemy;
	}

task fire{
	if(famangle>=9){l=1;}
	loop(l){
	if(famangle!=4){
	PlaySE(CSD~"sound\bulletwave.wav");
	ascent(i in 0..15){
	ascent(a in 0..2){
	CreateShotA(0,GetX+30*cos(i*24),GetY+30*sin(i*24),10);
	SetShotDataA(0,0,1+a/2,i*24,0,0,0,75);
	FireShot(0);
	}
	}
	ascent(i in 0..3){
	ascent(a in 0..4){
	CreateShotA(0,GetX,GetY,10);
	SetShotDataA(0,0,1+a/2.5,GetAngleToPlayer-10+i*10,0,0,0,91);
	FireShot(0);
	}
	}
	}
	if(famangle==4){
	PlaySE(CSD~"sound\bulletwave.wav");
	ascent(i in 0..24){
	ascent(a in 0..3){
	CreateShotA(0,GetX+30*cos(i*15),GetY+30*sin(i*15),10);
	SetShotDataA(0,0,1+a/2,i*15,0,0,0,75);
	FireShot(0);
	}
	}
	ascent(i in 0..3){
	ascent(a in 0..4){
	CreateShotA(0,GetX,GetY,10);
	SetShotDataA(0,0,1+a/2,GetAngleToPlayer-10+i*10,0,0,0,91);
	FireShot(0);
	}
	}
	}
	wait(120);
	}
	}

task Bullet(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;}
			}

}