let Cut = GetCurrentScriptDirectory~"sprites\Cut.png";
let CutY = GetCurrentScriptDirectory~"sprites\CutY.png";
let imageFile = GetCurrentScriptDirectory~"sprites\yuyuko.png";
let imageFile2 = GetCurrentScriptDirectory~"sprites\fan.png";
let f = true;
let variation = 1;
let last = false;
let drift = false;
let variable = 1;
let futo = GetCurrentScriptDirectory~"sprites\futo.png";
let frame = -60;
let shooting = false;
let frame2 = -60;
let familiarspawn = GetCurrentScriptDirectory~"sfx\Shadow.wav";
let die = GetCurrentScriptDirectory~"sfx\se_enep01.wav";
let dream = GetCurrentScriptDirectory~"sfx\dream.wav";
let frame3 = -60;
let border = GetCurrentScriptDirectory~"sfx\border.wav";
let orb = GetCurrentScriptDirectory~"sfx\orb.wav";
let shot3 = GetCurrentScriptDirectory~"sfx\shot3.wav";
let shot4 = GetCurrentScriptDirectory~"sfx\shot4.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 b = 0;
let timer = GetTimer;
let wisps = GetCurrentScriptDirectory~"sfx\wisps.wav";
let wispspawner = GetCurrentScriptDirectory~"sfx\wispspawner.wav";
let ylaser = GetCurrentScriptDirectory~"sfx\ylaser.wav";
let glaser = GetCurrentScriptDirectory~"sfx\glaser.wav";
let alpha = 255;
let time1 = GetCurrentScriptDirectory~"sfx\time1.wav";
let time2 = GetCurrentScriptDirectory~"sfx\time2.wav";
let teleport = GetCurrentScriptDirectory~"sfx\teleport.wav";
let caution = GetCurrentScriptDirectory~"sfx\caution.wav";
let acc1 = 0;
let ping = GetCurrentScriptDirectory~"sfx\ping.wav";
let sfx = GetCurrentScriptDirectory~"sfx\sfx.wav";
let acc2 = 0;
let acc3 = 0;
let acc5 = 0;
let ang = 0;
let anim1 = 0;
	
let YuyukoSensu_SizeX = 0;
 let YuyukoSensu_SizeY = 1/20;
let c = 0;
let angle = 0;
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 ang = 0;
let shot3 = GetCurrentScriptDirectory~"sfx\shot3.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";
	#include_function ".\lib\SHOT_REPLACE\shot_replace.dnh"
	#include_function ".\cutin.dnh"
	#include_function ".\DATA\lib_anime_Yuyuko.dnh"
	@MainLoop{
	if(alpha<0){ alpha = 0; }
	if(GetTimer!=timer && (GetTimer < 10 && GetTimer>3)){
		PlaySE(time1);
			}

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

	
			}
	timer = GetTimer;
	
	if(drift==true){
	SetMovePosition02(GetPlayerX, GetY, 300);
	}
	
	
			SetCollisionB(GetX, GetY, 14.5); 
	                SetCollisionA(GetX, GetY, 32); 
	yield;


	
	}

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


	
task fan{
 YuyukoSensu_Open;
 }

	
task immediatefan{
 YuyukoSensu_OpenQuick;
 }

 function YuyukoSensu_Open {
  descent(i in 0..30) {
   YuyukoSensu_SizeX += i/435;
   yield;
  }
	PlaySE(ping);
  descent(i in 0..60) {
   YuyukoSensu_SizeY += i/1770-1/1200;
   yield;
  }
 }

 function YuyukoSensu_Close {
  descent(i in 0..20) {
   YuyukoSensu_SizeY -= i/190-1/400/2;
   yield;
  }
	PlaySE(ping);
  descent(i in 0..10) {
   YuyukoSensu_SizeX -= i/45/2;
   yield;
  }
	YuyukoSensu_SizeX = 0;
 YuyukoSensu_SizeY = 1/20;
 }


 function YuyukoSensu_OpenQuick {
  descent(i in 0..30) {
   YuyukoSensu_SizeX += i/435;
  
  }
  descent(i in 0..60) {
   YuyukoSensu_SizeY += i/1770-1/1200;
   
  }
 }

 function YuyukoSensu_CloseQuick {
  descent(i in 0..20) {
   YuyukoSensu_SizeY -= i/190-1/400;
   yield;
  }
  descent(i in 0..10) {
   YuyukoSensu_SizeX -= i/45;
   yield;
  }
 }

sub ExMove { ExMove_(GetClipMinY+120, 10, rand(15, 30)); }
function ExMove_(height, ud, length) {
	SetAction(ACT_MOVE, 180);
	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 ExMoveLower { ExMoveL_(GetClipMinY+150, 10, rand(15, 30)); }
function ExMoveL_(height, ud, length) {
	SetAction(ACT_MOVE, 180);
	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 ExMove2 { ExMove_2(GetClipMinY+120, 0, rand(20, 40)); }
function ExMove_2(height, ud, length) {
	SetAction(ACT_MOVE, 180);
	if(GetPlayerX < GetX) {
		if(GetX - length <= GetClipMinX) {
			SetMovePosition03(GetX + length+20, rand(height+4 - ud, height + ud), 5, 0.75);
		} else {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 0.75);
		}
	} else {
		if(GetX + length >= GetClipMaxX) {
			SetMovePosition03(GetX - length-20, rand(height - ud, height + ud), 5, 0.75);
		} else {
			SetMovePosition03(GetX + length+20, rand(height - ud, height + ud), 5, 0.75);
		}
	}
}


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 {

SetTexture(imageFile2);
 SetRenderState(ALPHA);
 SetGraphicRect(0,0,600,300);
  SetAlpha(255);
  SetGraphicScale(YuyukoSensu_SizeX,YuyukoSensu_SizeY);
  SetGraphicAngle(0,0,0);
  DrawGraphic(GetX, GetY);
  SetGraphicScale(0.8,0.8);
SetTexture(imageFile);
SetAlpha(alpha);
 SetGraphicScale(1,1);
DrawBoss(imageFile);


}


@Finalize {
SetShotColor(255, 255, 255);
loop(7-floor((GetMissCount+GetBombCount)/2)){
CreateItem(ITEM_SCORE, GetX+rand(-100, 100), GetY+rand(-45, 44));
}

if(GetCommonDataDefault("lastattack", false)==true){
PlaySE(die);
}
}