let Cut = GetCurrentScriptDirectory~"sprites\Cut.png";
let imageFile = GetCurrentScriptDirectory~"sprites\eirin.png";
let f = true;
let variation = 1;
let variable = 1;
let futo = GetCurrentScriptDirectory~"sprites\futo.png";
let frame = -60;
let shooting = false;
let explode = GetCurrentScriptDirectory~"sfx\se_enep01.wav";
let frame2 = -60;
let frame3 = -60;
let border = GetCurrentScriptDirectory~"sfx\border.wav";
let orb = GetCurrentScriptDirectory~"sfx\orb.wav";
let shot3 = GetCurrentScriptDirectory~"sfx\shot2.wav";
let shot2 = GetCurrentScriptDirectory~"sfx\shot2.wav";
let shot = GetCurrentScriptDirectory~"sfx\shot.wav";
let charge = GetCurrentScriptDirectory~"sfx\Charge.wav";
let wtf = GetCurrentScriptDirectory~"sfx\kira00.wav";
let ping = GetCurrentScriptDirectory~"sfx\ping.wav";
let b = 0;
let hitbox = true;
let collision = true;
let timer = GetTimer;
let time1 = GetCurrentScriptDirectory~"sfx\time1.wav";
let time2 = GetCurrentScriptDirectory~"sfx\time2.wav";
let warp = GetCurrentScriptDirectory~"sfx\warp.wav";
let caution = GetCurrentScriptDirectory~"sfx\caution.wav";
let laser2 = GetCurrentScriptDirectory~"sfx\laser2.wav";
let acc1 = 0;
let acc2 = 0;
let acc3 = 0;
let acc5 = 0;
let ang = 0;
let anim1 = 0;
let c = 0;
let angle = 0;
let capture = GetCurrentScriptDirectory~"sfx\capture.wav";
let anim2 = 0;
let anim3 = 0;
let radius = 0;
let angle = 0;
let CBG1 = GetCurrentScriptDirectory~"sprites\CBG1.png";
let CBG2 = GetCurrentScriptDirectory~"sprites\CBG2.png";
let CBG3 = GetCurrentScriptDirectory~"sprites\CBG3.png";
let CBG4 = GetCurrentScriptDirectory~"sprites\CBG4.png";
let CBG5 = GetCurrentScriptDirectory~"sprites\CBG5.png";
let ang = 0;
let shot3 = GetCurrentScriptDirectory~"sfx\shot3.wav";
let shot4 = GetCurrentScriptDirectory~"sfx\shot4.wav";
let shot4q = GetCurrentScriptDirectory~"sfx\shot4q.wav";
let objbullets = [];
let objgrowers = [];
let variation = 0;
let imglifebar = GetCurrentScriptDirectory~"lifebar_thWW.png";
let familiarspawn = GetCurrentScriptDirectory~"sfx\Shadow.wav";
let bgm = GetCurrentScriptDirectory~"mu\bgm.mp3";
let SP = GetCurrentScriptDirectory~"sprites\futo.png";
let laser = GetCurrentScriptDirectory~"sfx\laser.wav";
let MC = GetCurrentScriptDirectory~"sprites\NMC.png";
let patchyx = 0;
let patchyy = 0;
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	#include_function ".\cutin.dnh"
	#include_function ".\DATA\lib_anime_Eirin.dnh"
	@MainLoop{

	SetCommonData("BossX", GetX);
	SetCommonData("BossY", GetY);
	
	if(GetTimer!=timer && (GetTimer < 10 && GetTimer>3)){
		PlaySE(time1);
			}

	if(GetTimer!=timer && GetTimer < 4){
		PlaySE(time2);
	

	
			}
	timer = GetTimer;
		
patchyy = GetCommonDataDefault("patchyy", 0);
patchyx = GetCommonDataDefault("patchyx", 0);
	
	if(hitbox==true){
	SetCollisionA(GetX, GetY, 22);
	}
	if(collision==true){
	SetCollisionB(GetX, GetY, 16);
	}
	yield;


	
	}

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



sub ExMove { ExMove_(GetClipMinY+120, 10, rand(15, 30)); }
function ExMove_(height, ud, length) {
	SetAction(ACT_MOVE, 60);
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length+20, rand(height+4 - ud, height + ud), 20, 2);
		} else {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 20, 2);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 20, 2);
		} else {
			SetMovePosition03(GetX + length+20, rand(height - ud, height + ud), 20, 2);
		}
	}
}

sub ExMoveFar { ExMove_2(GetClipMinY+120, 20, rand(30, 70)); }
function ExMove_2(height, ud, length) {
	SetAction(ACT_MOVE, 90);
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length+20, rand(height+4 - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 1);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX + length+20, rand(height - ud, height + ud), 5, 1);
		}
	}
}



sub ExMoveHigher { ExMove_3(GetClipMinY+60, 20, rand(40, 65)); }
function ExMove_3(height, ud, length) {
	SetAction(ACT_MOVE, 90);
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length+20, rand(height+4 - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 1);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 1);
		} else {
			SetMovePosition03(GetX + length+20, rand(height - ud, height + ud), 5, 1);
		}
	}
}

task SpellDeclare {
SetAction(ACT_SPELL, 90);
wait(90);
SetAction(ACT_MOVE, 10000);
}

task CreateLifebar(type) {
	let initlife = GetLife; yield;
	let sides=80;
	let totalradius=64;
	let repeat=2;
	let Z=-90;
	let IN=0;
	let OUT=8;
	task lifeseparation {
		let obj = Obj_Create(OBJ_EFFECT);
		ObjEffect_SetTexture(obj, imglifebar);
		ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLEFAN);
		ObjEffect_CreateVertex(obj, 4);
		ObjEffect_SetVertexUV(obj, 0, 16, 0);
		ObjEffect_SetVertexUV(obj, 1, 24, 0);
		ObjEffect_SetVertexUV(obj, 2, 24, 11);
		ObjEffect_SetVertexUV(obj, 3, 16, 11);
		ObjEffect_SetVertexXY(obj, 0, -4, -11/2);
		ObjEffect_SetVertexXY(obj, 1, 4, -11/2);
		ObjEffect_SetVertexXY(obj, 2, 4, 11/2);
		ObjEffect_SetVertexXY(obj, 3, -4, 11/2);
		let totalradius_ = totalradius+OUT*3/4;
		ObjEffect_SetScale(obj, 1, 5/4);
		loop { ObjEffect_SetAngle(obj, 0, 0, 90+360*0.15); Obj_SetPosition(obj, GetX+totalradius_*cos(-90-360*0.15), GetY+totalradius_*sin(-90-360*0.15)); yield; }
	}
	let objL = Obj_Create(OBJ_EFFECT);
	let objB = Obj_Create(OBJ_EFFECT);
	if(type == 0 || type == 1) { lifeseparation; }
	ascent(n in 0..2) {
		let d=0;
		let objid = [objB, objL][n];
		Obj_SetX(objid,GetX);
		Obj_SetY(objid,GetY);
		ObjEffect_SetScale(objid,1,1);
		ObjEffect_SetPrimitiveType(objid,PRIMITIVE_TRIANGLESTRIP);
		ObjEffect_SetRenderState(objid,ALPHA);
		ObjEffect_SetTexture(objid,imglifebar);
		ObjEffect_CreateVertex(objid,2+sides*2);
		ascent(i in 0..sides+1){
			ObjEffect_SetVertexUV(objid,i*2,8+8*n,d*repeat/sides);
			ObjEffect_SetVertexUV(objid,i*2+1,8*n,d*repeat/sides);
			d+=-256;
		}
	}
	if(type!=0 && type!=1 && type!=2){type=2}
	let expand = [0, 1, 0, 0][type];
	let this = [0.85, 0.15, 1][type];
	let left = [0.15, 0, 0][type];
	loop {
		Obj_SetPosition(objL, GetX, GetY);
		Obj_SetPosition(objB, GetX, GetY);
		let ratio = GetLife/initlife*this+left; if(expand<1){expand+=1/15;}else if(expand>1){expand=1}
		ascent(i in 0..sides+1){
			let radiusINX=(totalradius+IN)*cos(i*360*ratio*expand/sides+Z);
			let radiusINY=(totalradius+IN)*sin(i*360*ratio*expand/sides+Z);
			let radiusOUTX=(totalradius+OUT)*cos(i*360*ratio*expand/sides+Z);
			let radiusOUTY=(totalradius+OUT)*sin(i*360*ratio*expand/sides+Z);
			ObjEffect_SetVertexXY(objL,i*2,-radiusINX,radiusINY);
			ObjEffect_SetVertexXY(objL,i*2+1,-radiusOUTX,radiusOUTY);
			let radiusINX=(totalradius+IN)*cos(i*360*expand/sides+Z);
			let radiusINY=(totalradius+IN)*sin(i*360*expand/sides+Z);
			let radiusOUTX=(totalradius+OUT)*cos(i*360*expand/sides+Z);
			let radiusOUTY=(totalradius+OUT)*sin(i*360*expand/sides+Z);
			ObjEffect_SetVertexXY(objB,i*2,-radiusINX,radiusINY);
			ObjEffect_SetVertexXY(objB,i*2+1,-radiusOUTX,radiusOUTY);
		}
		yield;
	}
}


function GetDistance(x1,y1,x2,y2){
return(((x2-x1)^2+(y2-y1)^2)^(1/2))
} 


 @DrawLoop {

DrawBoss(imageFile);
}


@Finalize {
if(GetCommonDataDefault("last", false)==true){
PlaySE(explode);
}
if(GotSpellCardBonus==true && GetCommonDataDefault("last", false)==false){
PlaySE(capture);
}

}