#東方弾幕風
#Title[No.078　「幽幻魅了守護妖姫　-Normal-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "「幽幻魅了守護妖姫　-Normal-」";

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

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

	LoadGraphic(imgboss53);
	SetTexture(imgboss53);
	SetGraphicRect(0,0,127,127);
	Shot(1);
	}

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

	@Finalize{
	DeleteGraphic(imgboss53);
	MasicPointAddSpellCard;
	loop(60 + scorebonus * 2){
	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 JikiBatafry(level){
	let speed = 2;
	loop{
	loop(5){
	CreateShotA(1,GetX,GetY,10);
	SetShotDataA(1,0,2,0,0,0,0,RED22);
	SetShotDirectionType(PLAYER);
	SetShotDataA(1,30,speed,0,0,0,0,RED22);
	SetShotDirectionType(ABSOLUTE);
	FireShot(1);
	speed -= 1.5 / 5;}
	speed = 2;
	Wait(80 - level * 15);
	loop(5){
	CreateShotA(2,GetX,GetY,10);
	SetShotDataA(2,0,2,180,0,0,0,GREEN22);
	SetShotDirectionType(PLAYER);
	SetShotDataA(2,30,speed,0,0,0,0,GREEN22);
	SetShotDirectionType(ABSOLUTE);
	FireShot(2);
	speed -= 1.5 / 5;}
	speed = 2;
	Wait(80 - level * 15);
	}
	}

	function AllBatafry(angle,level){
	let way = [12,16,20,24];
	loop(way[level]){
	CreateShotA(1,GetX,GetY,0);
	SetShotDataA(1,0,1.5,angle,0,0,2,GREEN22);
	SetShotDataA(1,30,NULL,NULL,0.4,0.2,2,GREEN22);
	CreateShotA(2,GetX,GetY,0);
	SetShotDataA(2,0,1.5,angle,0,0,2,RED22);
	SetShotDataA(2,30,NULL,NULL,-0.4,0.2,2,RED22);
	FireShot(1);
	FireShot(2);
	angle += 360 / way[level];
	}
	}

	task DeathBatafry(angle,level){
	let way = [8,8,16,24];
	loop(way[level]){
	CreateShotA(9,GetX,GetY,0);
	SetShotDataA(9,0,2,angle,0,0,2,BLUE22);
	FireShot(9);
	if(level >= 1){
	CreateShotA(10,GetX,GetY,0);
	SetShotDataA(10,0,2,angle,0,0,2,BLUE22);
	SetShotDataA(10,150,0,90,0,0.02,2,BLUE22);
	FireShot(10);
	}
	if(level >= 2){
	CreateShotA(11,GetX,GetY,0);
	SetShotDataA(11,0,2,angle,0,0,2,BLUE22);
	SetShotDataA(11,50,0,90,0,0.02,2,BLUE22);
	FireShot(11);
	}
	angle += 360 / way[level]
	}
	}

	let angle = 0;
	let mx =GetClipMinX();
	let Mx =GetClipMaxX();
	let waitA = [30,30,35,40];

	JikiBatafry(level);
	loop{
	DeathBatafry(angle,level);
	Wait(waitA[level]);
	AllBatafry(angle,level);
	angle += 11.7;
	Wait(waitA[level]);
	AllBatafry(angle,level);
	angle -= 5.7;
	Wait(waitA[level]);
	DeathBatafry(angle,level);
	AllBatafry(angle,level);
	angle += 21.1;
	Wait(waitA[level]);
	AllBatafry(angle,level);
	angle -= 18.2;
	if(level >= 2){loop(3){Allshot(2,90,level * 4 + 12,PURPLE03,18);Wait(10);}}
	Wait(waitA[level]);
	}
	}
}