script_enemy_main{
	#include_function ".\drawenemy3.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(800);
	SetInvincibility(180);
	LoadGraphic(imgFam);
	maintask;
}

@MainLoop{

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

yield;


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

		loop(20){
		CreateItem(ITEM_SCORE,GetX()+rand(-30,30),GetY()+rand(-20,20));
		}
		//CreateItem(ITEM_BOMB,GetX,GetY);

}

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

task fire{
	let angle=0;
	Concentration01(60);
	SetColor(255, 255, 255); 
	wait(60);
	PlaySE(CSD~"sound\Weird2.wav");
	ascent(i in 0..36){
	ascent(a in 0..8+count){
	CreateShotA(0,GetX+30*cos(GetAngleToPlayer+i*10),GetY+30*sin(GetAngleToPlayer+i*10),15);
	SetShotDataA(0,0,1+a/2,GetAngleToPlayer+i*10-45*switch,0,0,0,144);
	FireShot(0);
	CreateShotA(0,GetX+90*cos(GetAngleToPlayer+i*10),GetY+90*sin(GetAngleToPlayer+i*10),15);
	SetShotDataA(0,0,+1+a/2,GetAngleToPlayer+i*10+25*switch,0,0,0,144);
	FireShot(0);
	}
	}
	wait(180);
	let gx;
	let gy;
	loop(10+count*2){
	gx = GetX+rand_int(-120,120);
	gy = GetX+rand_int(-100,-20);
	PlaySE(CSD~"sound\shot5.wav");
	ascent(i in 0..36){
	CreateShotA(0,gx+30*cos(i*10),gy+30*sin(i*10),30);
	SetShotDataA(0,0,2,i*10,0,0,0,14);
	FireShot(0);
	}
	ascent(i in 0..6){
	CreateShotA(0,gx,gy,30);
	SetShotDataA(0,0,1+i/3,atan2(GetPlayerY-gy,GetPlayerX-gx),0,0,0,144);
	FireShot(0);
	}
	wait(10-count);
	}
	switch = -switch;
	count++;
	wait(60);
	fire;
	}

task movement{
	SetMovePosition03(GetCenterX, GetCenterY-80, 10, 3);
	}

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

}