#東方弾幕風
#Title[No.142 禁魅術「魅色の十色針　-Lunatic-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "禁魅術「魅色の十色針　-Lunatic-」";
	let count   = 0;

	//初期位置
	let xini    =GetCenterX;
	let yini    =GetCenterY + 160;

	@Initialize{
	CutIn(YOUMU,name,"",0,0,0,0);
	SetX(GetCenterX);
	SetY(GetClipMinY + 120);
	SetLife(1);
	SetTimer(50);
	SetScore(12000000 + spellbonus);
	SetDamageRate(0,0);
	SetDurableSpellCard();

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

	@MainLoop{
	ChackBonus;

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}


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

	task Move(level){
	loop{
	yield;
	}
	}


	task CharmNeedle(level){
	function NotHere(a,min,max,b){
	let c = rand_int(0,1);
	let d;
	let e = rand_int(0,5);
	if(e > 0&&a <= min + b){c = 1;}
	if(e > 0&&a >= max - b){c = 0;}
	if(c == 0){d = rand(min,a - b);}
	if(c == 1){d = rand(a + b,max);}
	return d;
	}

	let rank = 0;
	loop{
	loop(7){
	loop(level * (25 + rank * 3) + 80 - (GetTimer*4/5)){
	let x = NotHere(GetPlayerX,GetClipMinX,GetClipMaxX,90 - level * 10);
	let y = NotHere(GetPlayerY,GetClipMinY,GetClipMaxY,90 - level * 10);
	let speed = rand(0.2,0.9 + level * 0.7);
	let angle = rand(0,360);
	let bullet = rand_int(-65464,-65457);
	CreateShotA(1,x,y,20);
	SetShotDataA(1,0,0,angle,0,0,0,bullet);
	SetShotDataA(1,210,0,angle,0,0.065,speed,bullet);
	FireShot(1);
	if(level >= 2){
	CreateShotA(2,x,y,20);
	SetShotDataA(2,0,0,angle,0,0,0,bullet);
	SetShotDataA(2,210,0,angle,0,0.0325,speed/2,bullet);
	FireShot(2);
	}
	}
	loop(50){yield;}
	}
	rank++;
	}
	}

	task Shot(level){
	let rank = 0;
	loop(100){yield;}
	CharmNeedle(level);	
	loop{
	loop(8){
	loop(6 + rank){
	if(rank >= 2){
	CreateShot01(GetX,GetY,2.4,GetAngleToPlayer,RED01,10);
	}
	CreateShot01(GetX,GetY,2.4,GetAngleToPlayer+30,RED01,10);
	CreateShot01(GetX,GetY,2.4,GetAngleToPlayer-30,RED01,10);
	if(level >= 2){
	CreateShot01(GetX,GetY,2.4,GetAngleToPlayer+15,RED01,10);
	CreateShot01(GetX,GetY,2.4,GetAngleToPlayer-15,RED01,10);
	}
	if(level >= 3){
	if(rank >= 1){
	CreateShot01(GetX,GetY,1.2,GetAngleToPlayer,GREEN01,10);
	}
	CreateShot01(GetX,GetY,1.2,GetAngleToPlayer+30,GREEN01,10);
	CreateShot01(GetX,GetY,1.2,GetAngleToPlayer-30,GREEN01,10);
	CreateShot01(GetX,GetY,1.2,GetAngleToPlayer+15,GREEN01,10);
	CreateShot01(GetX,GetY,1.2,GetAngleToPlayer-15,GREEN01,10);
	}
	loop(4){yield;}
	}
	loop(70){yield;}
	}
	rank++;
	}
	}
}