#東方弾幕風
#Title[No.098　「妖洞窟の吸魔蝶　-Normal-」]
#Text[]
#Image[]
#BackGround[]
#PlayLevel[]
#Player[FREE]
#ScriptVersion[2]

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

	let name    = "「妖洞窟の吸魔蝶　-Normal-」";

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

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

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

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

	yield;
	}

	@DrawLoop{
	DrawGraphic(GetX,GetY);
	}

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

task Shot1(angle,level){
let obj = Obj_Create(OBJ_SHOT);
Obj_SetX(obj, GetX);
Obj_SetY(obj, GetY);
Obj_SetSpeed(obj, 2 - level * 0.4);
Obj_SetAngle(obj, angle);
ObjShot_SetGraphic(obj, 41);
ObjShot_SetDelay(obj, 20);
			
while( !Obj_BeDeleted(obj) ){loop(15 - (level * 2) + GetLife / 800){yield;}
let x = Obj_GetX(obj);
let y = Obj_GetY(obj);
CreateShot01(x,y,rand(0.5,1.5 + level * 0.4),rand(0,360),21,20);
if(Obj_GetX(obj) <= GetClipMinX||Obj_GetX(obj) >= GetClipMaxX||Obj_GetY(obj) <= GetClipMinY||Obj_GetY(obj) >= GetClipMaxY){
Obj_Delete(obj);}
}
}

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

	yield;
	SetLotus(level);
	loop{
	Wait(150);
	if(level == 0||level == 3){Shot1(GetAngleToPlayer,level);}
	if(level >= 1){Shot1(GetAngleToPlayer+60,level);Shot1(GetAngleToPlayer-60,level);}
	if(level >= 2){Shot1(GetAngleToPlayer+120,level);Shot1(GetAngleToPlayer-120,level);}
	if(level == 3){Shot1(GetAngleToPlayer+180,level);;}
	}
	}

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

	function wait(w) {
		loop(w) { yield; }
	}

	#include_function ".\lib_Lotus.txt"

}