#東方弾幕風
#Title[No.084　魔法「ウィッチクラフト　-Lunatic-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "魔法「ウィッチクラフト　-Lunatic-」";

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

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

	LoadGraphic(imgboss61);
	SetTexture(imgboss61);
	SetGraphicRect(0,0,127,127);
	Shot(3);
	}

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss61);
	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(a,level,loopangle,bullet){
	loop{
	let Angle = 0;
	while(Angle <= loopangle){
	let angle = Angle;
	loop(360 / loopangle){
	CreateShot01(GetX,GetY,1.3,angle,bullet,15);
	angle += loopangle;
	}
	Angle += (a - level * 1.5) * 5 / 7;
	Wait(14);
	}
	while(Angle >= 0){
	let angle = Angle;
	loop(360 / loopangle){
	CreateShot01(GetX,GetY,1.3,angle,bullet,15);
	angle += loopangle;
	}
	Angle -= (a - level * 1.5) * 5 / 7;
	Wait(14);
	}
	}
	}


	Wait(90);
	ShotA(16,level,60,PURPLE04);
	ShotA(10,level,120,PURPLE21);
	ShotA(16,level,45,BLUE04);
	ShotA(10,level,90,BLUE21);
	if(level >= 1){
	ShotA(18,level,36,AQUA04);
	ShotA(12,level,72,AQUA21);}
	if(level >= 2){
	ShotA(22,level,20,GREEN04);
	ShotA(14,level,40,GREEN21);}

	loop{
	Wait(140 - level * 20);
	let speed = 3;
	loop(3){
	CreateShot01(GetX,GetY,speed,GetAngleToPlayer,RED03,15);
	speed -= 0.3;
	}
	}
	}
}