#搶曽抏枊晽
#Title[No.135 嬛壩弍乽捛旜憮墜丂-Hard-乿]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\抏枊廤.txt"

	let name    = "嬛壩弍乽捛旜憮墜丂-Hard-乿";
	let count   = 0;

	//弶婜埵抲
	let xini    =GetCenterX;
	let yini    =GetCenterY + 20;

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1000);
	SetTimer(100);
	SetScore(12000000 + spellbonus * 0.5);
	SetDamageRate(15,0);

	LoadGraphic(imgboss73);
	SetTexture(imgboss73);
	SetGraphicRect(0,0,127,127);
	SetInvincibility(150);
	Shot(2);
	Move(2);
	LoadUserShotData(GetCurrentScriptDirectory~"11-221Shot_僨乕僞.txt");
	}

	@MainLoop{
	ChackBonus;
	SetCollisionA(GetX,GetY,48);
	SetCollisionB(GetX,GetY,24);

	//EX晽儃儉僶儕傾
	if(OnBomb() == true){SetInvincibility(2);}
	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}


	@Finalize{
	DeleteGraphic(imgboss73);
	MasicPointAddSpellCard;
	loop(200 + scorebonus * 10){
	let x = rand(GetX-96,GetX+96);
	let y = rand(GetY-96,GetY+96);
	CreateItem(ITEM_SCORE,x,y);}
	SetCommonData("ON_SPELL",0);
	}

	task Move(level){
	loop{
	loop(level * -40 + 450){yield;}
	if(GetX >= GetPlayerX){
	SetMovePositionRandom01(rand_int(-8,0)*8,rand(-16,16),1,GetClipMinX + 128,GetCenterY - 180,GetClipMaxX - 128,GetCenterY - 120);
	}
	if(GetX < GetPlayerX){
	SetMovePositionRandom01(rand_int(0,8)*8,rand(-16,16),1,GetClipMinX + 128,GetCenterY - 180,GetClipMaxX - 128,GetCenterY - 120);
	}
	loop(510){yield;}
	}
	}

	task LightShot(angle,level){
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetX(obj, GetX);
	Obj_SetY(obj, GetY);
	Obj_SetSpeed(obj, 1.5 + level * 0.4);
	Obj_SetAngle(obj, angle);
	ObjShot_SetGraphic(obj, 51);
	ObjShot_SetDelay(obj, 20);
	
	while( !Obj_BeDeleted(obj) ){yield;}
	}

	task CreateFireLaser(a,b,level){
	function GetGapAngle(xA,yA,xB,yB)
	{return atan2( yB - yA, xB - xA );}
	//儗乕僓乕僞僗僋弶婜壔
	let obj = Obj_Create(OBJ_SHOT);
	Obj_SetX(obj, GetX);
	Obj_SetY(obj, GetY);
	Obj_SetAngle(obj, GetAngleToPlayer + a);
	Obj_SetSpeed(obj, b);
	ObjShot_SetGraphic(obj, 41);
	ObjShot_SetDelay(obj, 60);//抶墑帪娫丗60僼儗乕儉
			loop(level * 20 + 90){
			Obj_SetAngle(obj, GetGapAngle(Obj_GetX(obj),Obj_GetY(obj),GetPlayerX,GetPlayerY));
			yield;
			}
	while(!Obj_BeDeleted(obj)){yield;}
	}

	task LightShotCom(level){


	let way = 24 + 8 * level;
	let angle;
	loop{
	angle = rand(0,360);
	loop(50){yield;}
	loop(way){
	LightShot(angle,level);
	angle += 360 / way;
	}
	}
	}

	task Shot(level){
	LightShotCom(level);
	loop{
	Concentration01(level * -10 + 150);
	loop(level * -10 + 150){yield;}
	CreateFireLaser(0,2.7,level);
	if(level >= 2){
	CreateFireLaser(-120,2,level);
	CreateFireLaser(120,2,level);
	}
	if(level >= 3){
	CreateFireLaser(180,2.3,level);
	CreateFireLaser(60,2.3,level);
	CreateFireLaser(60,2.3,level);
	}
	loop(360 - level * 30){yield;}
	}
	}
}