script_enemy_main
{
	let ITEM_POINT=0;
	let ITEM_BOMB=1;
	let ITEM_1UP=2;
	let ITEM_MULTI=3;
	
	let type=GetArgument;
	
	@Initialize
	{
		SetX(GetCenterX);
		SetY(GetCenterY);
		SetLife(1);
		TMain;
	}
	@MainLoop{yield;}
	task TMain
	{
		yield;
		alternative(type)
		case(1,2)
		{
			Concentration01(30);
			SetItem(GetX,GetY,(type%4));
			let leng=50;
			loop(150)
			{
				DeleteEnemyShotToItemInCircle(SHOT,GetX,GetY,leng);
				leng+=3;
				yield;
			}
		}
		case(0)
		{
			let leng=30;
			let vx=rand(0,360);
			let vy=rand(0,360);
			let lp=0;
			loop(100)
			{
				let py=GetPlayerY-lp*2;
				let L=2;
				let itemtype=type;
				if(GetCommonDataDefault("Rate",1)>=800){L=4;}
				if(IsBossExisting){itemtype=3;}
				loop(L)
				{
					let sx=GetPlayerX+leng*cos(vx)+rand(-20,20);
					let sy=py+leng*sin(vy)+rand(-20,20);
					SetItem(sx,sy,itemtype);
				}
				DeleteEnemyShotToItemInCircle(SHOT,GetPlayerX,GetPlayerY,leng*2);
				lp++;
				leng+=1;
				vx+=6;
				vy+=3;
				yield;
			}
			loop(80)
			{
				DeleteEnemyShotToItemInCircle(SHOT,GetPlayerX,GetPlayerY,leng*2);
				yield;
			}
		}
		others{}
		VanishEnemy;
	}

	function SetItem(let x,let y,let type)
	{
		let data=[x,y,type];
		let itemstate=GetCommonDataDefault("ItemState",[]);
		itemstate=itemstate~[data];
		SetCommonData("ItemState",itemstate);
	}
}
