#東方弾幕風
#Title[No.096　魔法「金閣寺の紫雲　-Lunatic-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

script_enemy_main
{
#include_function ".\弾幕集.txt"

	let name    = "魔法「金閣寺の紫雲　-Lunatic-」";

	//初期位置
	let xini    =GetCenterX;
	let yini    =GetCenterY - 100;

	@Initialize{
	SetCommonData("ON_SPELL",1);
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(xini);
	SetY(yini);
	SetLife(2500);
	SetTimer(79);
	SetScore(8500000 + spellbonus * 3);
	SetDamageRate(50,1);
	SetInvincibility(120);

	LoadGraphic(imgboss61);
	SetTexture(imgboss61);
	SetGraphicRect(0,0,127,127);
	Shot(3);
	Move(3);
	LoadUserShotData(GetCurrentScriptDirectory~"11-221Shot_データ.txt");
	}

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss61);
	SetColor(0,0,0);
	MasicPointAddSpellCard;
	loop(90 + scorebonus * 3){
	let x = rand(GetX-32,GetX+32);
	let y = rand(GetY-32,GetY+32);
	CreateItem(ITEM_SCORE,x,y);}
	SetCommonData("ON_SPELL",0);
	}

	task Shot(level){
	function Wait(time){loop(time){yield;}}

	task ShotA(level){
	loop{
	Wait(40);
	let angle = GetAngleToPlayer - 90;
	loop(30 + level * 15){
	CreateShot01(GetX,GetY,2,angle,47,20);
	CreateShot01(GetX,GetY,1.7,angle + 1.7,47,20);
	if(level >= 1){CreateShot01(GetX,GetY,1.4,angle + 3.4,47,20);}
	angle += 9.1;
	Wait(2);
	}
	loop(30 + level * 15){
	CreateShot01(GetX,GetY,2,angle,47,20);
	CreateShot01(GetX,GetY,1.7,angle + 1.7,47,20);
	if(level >= 1){CreateShot01(GetX,GetY,1.4,angle + 3.4,47,20);}
	angle -= 13;
	Wait(2);
	}
	Wait(60);
	}
	}

	task ShotB(level){
	loop{
	Wait(40);
	let angle = GetAngleToPlayer + 90;
	loop(30 + level * 15){
	CreateShot01(GetX,GetY,2,angle,47,20);
	CreateShot01(GetX,GetY,1.7,angle + 1.7,47,20);
	if(level >= 3){CreateShot01(GetX,GetY,1.4,angle + 3.4,47,20);}
	angle -= 9.1;
	Wait(2);
	}
	loop(30 + level * 15){
	CreateShot01(GetX,GetY,2,angle,47,20);
	CreateShot01(GetX,GetY,1.7,angle + 1.7,47,20);
	if(level >= 3){CreateShot01(GetX,GetY,1.4,angle + 3.4,47,20);}
	angle += 13;
	Wait(2);
	}
	Wait(60);
	}
	}

	task ShotC(level){
	loop{
	Wait(40);
	let angle = GetAngleToPlayer - 90;
	loop(90 + level * 30){
	CreateShot01(GetX,GetY,1.6,angle,27,20);
	CreateShot01(GetX,GetY,1.3,angle + 1.2,27,20);
	if(level >= 1){CreateShot01(GetX,GetY,1.4,angle + 2.4,27,20);}
	angle += 8.71;
	Wait(2);
	}
	}	
	}

	task ShotKinkakuji{
	loop{
	let shots = rand_int(6,14);
	let between = 20;
	let x1 = GetClipMinX;
	let x2 = GetClipMaxX;
	Wait(50);
	loop(shots){
	CreateShot01(x1,GetY,2,90,YELLOW01,20);
	x1 += between;}
	let shots = rand_int(7,13);
	Wait(50);
	loop(shots){
	CreateShot01(x2,GetY,2,90,YELLOW01,20);
	x2 -= between;}
	}
	}

	Concentration01(40);
	ShotA(level);
	if(level == 2){ShotB(level);}
	ShotC(level);
	if(level == 3){ShotKinkakuji();}
	Wait(40);
	loop{
	Wait((90 + level * 30) * 2);
	Concentration01(40);
	Wait(40);
	}
	}

	task Move(level){
	loop(40){yield;}
	loop{
	loop((90 + level * 30) * 2){yield;}
	if(GetPlayerX <= GetX - 40||GetPlayerX >= GetX + 40){
	let x = GetPlayerX;
	if(x >= GetClipMaxX - 84){x = GetClipMaxX - 84;}
	if(x <= GetClipMinX + 84){x = GetClipMinX + 84;}
	SetMovePosition02(x + rand(-20,20),GetClipMinY + rand(100,140),30);
	}
	loop(40){yield;}
	}
	}

}