#include"./LoadGraphics.txt"
let attack = 0;
let animFrame = 0;
let animFrame2 = 0;
let animFrame3 = 0;

task TEnemyMarker(){
	let object = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(object, enemysign);
	Obj_SetRenderPriorityI(object, 100);
	ObjSprite2D_SetSourceRect(object, 0, 0, 100, 16);
	ObjSprite2D_SetDestCenter(object);
	while(!Obj_IsDeleted(bossObj)){
		ObjRender_SetPosition(object, ObjMove_GetX(bossObj)+30, 472, 0);
	yield;}
	Obj_Delete(object);}

task animateBossM{
	let dir;
	let speed;
	let time = 0;
	let timetrue = 0;
	let hover = 0;

	if(GetCommonData("bossAURA",0) == 0){BossAura(bossObj,255,60,60);}
	if(GetCommonData("bossAURA",0) == 1){BossAura(bossObj,60,255,60);}
	if(GetCommonData("bossAURA",0) == 2){BossAura(bossObj,60,60,255);}
	if(GetCommonData("bossAURA",0) == 3){BossAura(bossObj,180,180,180);}
	if(GetCommonData("bossAURA",0) == 4){}

	while(!Obj_IsDeleted(bossObj)){
	ObjPrim_SetTexture(bossObj,imgBoss);
	ObjSprite2D_SetDestRect(bossObj,-70,-100+20*cos(hover),70,100+20*cos(hover));
	ObjRender_SetScaleXYZ(bossObj,0.4,0.4,0);
	hover+=2;

		dir = ObjMove_GetAngle(bossObj);
		speed = ObjMove_GetSpeed(bossObj);

		if(speed==0){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame < 60){ObjSprite2D_SetSourceRect(bossObj,0,0,140,200);}
			if(animFrame >= 60 && animFrame < 70){ObjSprite2D_SetSourceRect(bossObj,141,0,281,200);}
			if(animFrame >= 70 && animFrame < 80){ObjSprite2D_SetSourceRect(bossObj,284,0,424,200);}
			if(animFrame >= 80){ObjSprite2D_SetSourceRect(bossObj,141,0,281,200);}
			animFrame2 = 0;
			timetrue = 1;}
		else if(cos(dir) > 0){
	 		ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame2 < 6){ObjSprite2D_SetSourceRect(bossObj,0,200,140,400);}
			if(animFrame2 >= 6 && animFrame2 < 18){ObjSprite2D_SetSourceRect(bossObj,145,200,285,400);ObjRender_SetAngleXYZ(bossObj,0,0,5);}
			if(animFrame2 >= 18){ObjSprite2D_SetSourceRect(bossObj,290,198,430,398);ObjRender_SetAngleXYZ(bossObj,0,0,8);}
			timetrue = 0;}
		else if(cos(dir) < 0){
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame2 < 6){ObjSprite2D_SetSourceRect(bossObj,0,400,140,600);}
			if(animFrame2 >= 6 && animFrame2 < 18){ObjSprite2D_SetSourceRect(bossObj,140,400,280,600);ObjRender_SetAngleXYZ(bossObj,0,0,-5);}
			if(animFrame2 >= 18){ObjSprite2D_SetSourceRect(bossObj,290,400,430,600);ObjRender_SetAngleXYZ(bossObj,0,0,-8);}
			timetrue = 0;}

		if(timetrue==1){time++;}
		if(timetrue==0){time = 0;}

		if(attack==1){
			animFrame3++;
			ObjRender_SetAngleXYZ(bossObj,0,0,0);
			if(animFrame3 < 6){ObjSprite2D_SetSourceRect(bossObj,488,0,628,200);}
			if(animFrame3 >= 12 && animFrame3 < 18){ObjSprite2D_SetSourceRect(bossObj,619,0,759,200);}
			if(animFrame3 >= 18 && animFrame3 < 24){ObjSprite2D_SetSourceRect(bossObj,490,204,630,404);}
			if(animFrame3 >= 24){ObjSprite2D_SetSourceRect(bossObj,630,204,770,404);}
			timetrue = 1;}

		if(attack==0){
			animFrame3 = 0;
			timetrue = 1;}

		animFrame++;
		animFrame2++;
		if(animFrame > 90){animFrame = 0;}
		yield;}
	return;}

task animateBossT{
	let dir;
	let speed;
	let time = 0;
	let timetrue = 0;
	let hover = 0;
	let w = 5;

	BossAura(bossObj,255,60,180);
	while(!Obj_IsDeleted(bossObj)){
	ObjPrim_SetTexture(bossObj,imgBoss2);
	ObjSprite2D_SetDestRect(bossObj,-46,-64+20*cos(hover),46,64+20*cos(hover));
	ObjRender_SetScaleXYZ(bossObj,0.5,0.5,0);
	hover+=2;

		dir = ObjMove_GetAngle(bossObj);
		speed = ObjMove_GetSpeed(bossObj);

		if(speed==0){
			if(animFrame < w){ObjSprite2D_SetSourceRect(bossObj,0,0,92,128);}
			if(animFrame >= w && animFrame < w*3){ObjSprite2D_SetSourceRect(bossObj,92,0,183,128);}
			if(animFrame >= w*3 && animFrame < w*5){ObjSprite2D_SetSourceRect(bossObj,182,0,273,128);}
			if(animFrame >= w*5 && animFrame < w*7){ObjSprite2D_SetSourceRect(bossObj,92,0,183,128);}
			if(animFrame >= w*7 && animFrame < w*9){ObjSprite2D_SetSourceRect(bossObj,271,0,363,128);}
			if(animFrame >= w*9 && animFrame < w*11){ObjSprite2D_SetSourceRect(bossObj,92,0,183,128);}
			if(animFrame >= w*11 && animFrame < w*13){ObjSprite2D_SetSourceRect(bossObj,182,0,273,128);}
			if(animFrame >= w*13){ObjSprite2D_SetSourceRect(bossObj,92,0,183,128);}
			animFrame2 = 0;}
		else if(cos(dir) > 0){
			if(animFrame2 < w){ObjSprite2D_SetSourceRect(bossObj,0,128,92,256);}
			if(animFrame2 >= w && animFrame2 < w*2){ObjSprite2D_SetSourceRect(bossObj,92,128,183,256);}
			if(animFrame2 >= w*2 && animFrame2 < w*3){ObjSprite2D_SetSourceRect(bossObj,182,128,273,256);}
			if(animFrame2 >= w*3){ObjSprite2D_SetSourceRect(bossObj,271,128,363,256);}}
		else if(cos(dir) < 0){
			if(animFrame2 < w){ObjSprite2D_SetSourceRect(bossObj,271,265,363,393);}
			if(animFrame2 >= w && animFrame2 < w*2){ObjSprite2D_SetSourceRect(bossObj,182,265,273,393);}
			if(animFrame2 >= w*2 && animFrame2 < w*3){ObjSprite2D_SetSourceRect(bossObj,92,265,183,393);}
			if(animFrame2 >= w*3){ObjSprite2D_SetSourceRect(bossObj,0,265,92,393);}}

		if(attack==1){
			animFrame3++;
			if(animFrame3 < w){ObjSprite2D_SetSourceRect(bossObj,0,393,92,521);}
			if(animFrame3 >= w && animFrame3 < w*2){ObjSprite2D_SetSourceRect(bossObj,92,393,183,521);}
			if(animFrame3 >= w*2 && animFrame3 < w*3){ObjSprite2D_SetSourceRect(bossObj,192,393,284,521);}
			if(animFrame3 >= w*3){ObjSprite2D_SetSourceRect(bossObj,290,393,382,521);}}

		if(attack==0){animFrame3 = 0;}

		animFrame++;
		animFrame2++;
		if(animFrame > w*8){animFrame = 0;}
		yield;}
	return;}

task LoadShotData{
	let current = GetCurrentScriptDirectory();
	let path = current ~ "./../../Functions/AllStarShot.txt";
	LoadEnemyShotData(path);}

task TEtama{
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,circle);
	Obj_SetRenderPriorityI(obj,29);
	ObjSprite2D_SetSourceRect(obj,0,0,256,256);
	ObjSprite2D_SetDestCenter(obj);
	let ro = 0;
	let zah = 4;
	let fern = 0;
	let scale = 0;
	loop(45){
		ObjRender_SetScaleXYZ(obj,scale,scale,0);
		ObjRender_SetPosition(obj,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
		ObjRender_SetAngleZ(obj,ro);
		ro+=8; scale+=1/45; yield;}
	loop(60){
		ObjRender_SetPosition(obj,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
		ObjRender_SetAngleZ(obj,ro);
		ro+=zah; zah-=7/60; yield;}
		let num = ObjRender_GetScaleX(obj);
		while(!Obj_IsDeleted(obj)){
			ObjRender_SetScaleXYZ(obj,num-fern*cos(scale),num-fern*cos(scale),0);
			ObjRender_SetPosition(obj,ObjMove_GetX(bossObj),ObjMove_GetY(bossObj),0);
			ObjRender_SetAngleZ(obj,ro);
				if(ObjEnemy_GetInfo(bossObj,INFO_LIFE) <= 0){break;}
				if(fern >= 0.1){fern=0.1;}
			ro+=zah; scale+=1;fern+=0.001; yield;}
		Obj_Delete(obj);}

task TSpellBG{
	let move = 0;
	let alpha = 50; yield;
	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,bg1);
	Obj_SetRenderPriorityI(objbg,23);
	ObjSprite2D_SetSourceRect(objbg,0,0,624,624);
	ObjSprite2D_SetDestCenter(objbg);
	ObjRender_SetPosition(objbg,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
	ObjRender_SetAlpha(objbg,alpha);

	let objbg2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg2,bg2);
	Obj_SetRenderPriorityI(objbg2,22);
	ObjSprite2D_SetSourceRect(objbg2,0,0,128,128);
	ObjSprite2D_SetDestRect(objbg2,0,0,GetStgFrameWidth,GetStgFrameHeight);
		while(!Obj_IsDeleted(bossObj)){
			ObjRender_SetAngleZ(objbg,move);
				move+=1; yield;}
		Obj_Delete(objbg);
		Obj_Delete(objbg2);
	return;}

task TSpellBGMID{
	let move = 0;
	let scale = 0;
	let objbg2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg2,black);
	Obj_SetRenderPriorityI(objbg2,20);
	ObjSprite2D_SetSourceRect(objbg2,0,0,640,480);
	ObjSprite2D_SetDestRect(objbg2,0,0,384,448);

	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,mid1);
	Obj_SetRenderPriorityI(objbg,22);
	ObjSprite2D_SetSourceRect(objbg,0,-20000,550,550);
	ObjRender_SetAlpha(objbg,120);
		while(!Obj_IsDeleted(bossObj)){
			ObjSprite2D_SetDestRect(objbg,0,-20000+move,550,550+move);
			if(move % 30 == 0){
				scale = rand(0.05,0.5);
				let objbg3 = ObjPrim_Create(OBJ_SPRITE_2D);
				ObjPrim_SetTexture(objbg3,heartbg);
				Obj_SetRenderPriorityI(objbg3,21);
				ObjSprite2D_SetSourceRect(objbg3,0,0,500,500);
				ObjSprite2D_SetDestCenter(objbg3);
				ObjRender_SetScaleXYZ(objbg3,scale,scale,0);
				ObjRender_SetAlpha(objbg3,100);
				Manage(objbg3);}
			move+=1; yield;}
		Obj_Delete(objbg);
		task Manage(obj){
			let x = rand(0,384);
			let move = 0;
			let speed = rand(1,3);
			loop(480){
				if(Obj_IsDeleted(bossObj)){break;}
				ObjRender_SetPosition(obj,x,448+200-move,0);
			move+=speed; yield;}
			Obj_Delete(obj);}
	return;}

task BossAura(obj,r,g,b){
	while(ObjEnemy_GetInfo(bossObj,INFO_LIFE) > 0){
		FireAura();
		MainAura();
	loop(6){yield;}}
	
	task FireAura(){ let alpha = 255;
		let x = 24;let y = 24;
		let ac = 255;let bc = 255;let cc = 255;
		let aura = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(aura,pathaura);
		Obj_SetRenderPriorityI(aura,30);
		ObjSprite2D_SetSourceRect(aura,0,0,48,48);
		ObjRender_SetAngleXYZ(aura,0,0,rand(-25,25));
		ObjRender_SetBlendType(aura,BLEND_ADD_ARGB);
		loop(45){
			ObjSprite2D_SetDestRect(aura,-15-x,-24-y,15+x,24);
			ObjRender_SetPosition(aura,ObjMove_GetX(obj),ObjMove_GetY(obj),0);
			ObjRender_SetAlpha(aura,alpha);
			ObjRender_SetColor(aura,ac,bc,cc);
			ac-=(255-r)/15;if(ac<=r){ac=r;}
			bc-=(255-g)/15;if(bc<=g){bc=g;}
			cc-=(255-b)/15;if(cc<=b){cc=b;}
			alpha-=255/45;y+=3;x+=0.2;yield;}
		Obj_Delete(aura);}

	task MainAura(){ let alpha = 255;let s = 1;
		let size = 0;let z = rand(0,180)*2;
		let rad = rand(-2,2);
		let ac = 255;let bc = 255;let cc = 255;
		let aura = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(aura,pathaura);
		Obj_SetRenderPriorityI(aura,31);
		ObjSprite2D_SetSourceRect(aura,48,0,96,48);
		ObjSprite2D_SetDestCenter(aura);
		ObjRender_SetBlendType(aura,BLEND_ADD_ARGB);
		loop(45){
			ObjRender_SetPosition(aura,ObjMove_GetX(obj),ObjMove_GetY(obj),0);
			ObjRender_SetScaleXYZ(aura,1.5+1.2*sin(s),1.5+1.2*sin(s),0);
			ObjRender_SetAngleXYZ(aura,0,0,z);
			ObjRender_SetColor(aura,ac,bc,cc);
			ObjRender_SetAlpha(aura,alpha);
			ac-=(255-r)/15;if(ac<=r){ac=r;}
			bc-=(255-g)/15;if(bc<=g){bc=g;}
			cc-=(255-b)/15;if(cc<=b){cc=b;}
			alpha-=255/45;s+=4;z+=rad;yield;}
		Obj_Delete(aura);}}

task TSurvival{
	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,survival);
	ObjSprite2D_SetSourceRect(objbg,0,0,220,80);
	ObjRender_SetBlendType(objbg,BLEND_ADD_ARGB);
	ObjSprite2D_SetDestCenter(objbg);
	Obj_SetRenderPriorityI(objbg,100);
	ObjRender_SetPosition(objbg,530,370,0);
	let z = 20;let a = 0;let s = 2;
	loop(105){
		ObjRender_SetAlpha(objbg,a);
		ObjRender_SetAngleZ(objbg,20*sin(z));
		ObjRender_SetScaleXYZ(objbg,s,s,0);
		z+=5;a+=255/105;s-=1.2/105;yield;}
	loop(720){yield;}
	loop(200){
		ObjRender_SetAlpha(objbg,a);
	a-=255/200;yield;}
	Obj_Delete(objbg);}

task ShotAura(object,r,g,b){
	let alpha = 150;let scale = 0.3;
	let objbg = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(objbg,halo);
	ObjSprite2D_SetSourceRect(objbg,0,0,256,256);
	ObjRender_SetBlendType(objbg,BLEND_ADD_ARGB);
	ObjSprite2D_SetDestCenter(objbg);
	Obj_SetRenderPriorityI(objbg,30);
	ObjRender_SetColor(objbg,r,g,b);
	ObjRender_SetPosition(objbg,ObjMove_GetX(object)+rand(-20,20),ObjMove_GetY(object)+rand(-20,20),0);
		loop(30){
			//if(ObjEnemy_GetInfo(bossObj, INFO_LIFE) <= 0){break;}
			if(Obj_IsDeleted(bossObj)){break;}
			ObjRender_SetScaleXYZ(objbg,scale,scale,0);
			ObjRender_SetAlpha(objbg,alpha);
			alpha-=3;scale-=0.01;yield;}
		Obj_Delete(objbg);}

function PagodarLaser(x,y,dir,length,delay,time,color){
		let shot = CreateShotA1(x,y,0,dir,1,0);
		let co = [0,0,0];
		ObjShot_SetIntersectionEnable(shot,false);
		ObjShot_SetSpellResist(shot,true);
		Obj_SetVisible(shot,false);
		if(color=="RED"){co = [255,0,0];}
		if(color=="GREEN"){co = [0,255,0];}
		if(color=="BLUE"){co = [0,0,255];}
		if(color=="ORANGE"){co = [255,128,0];}
		if(color=="YELLOW"){co = [255,255,0];}
		if(color=="AQUA"){co = [0,255,255];}
		if(color=="PURPLE"){co = [255,0,255];}
		if(color=="PINK"){co = [255,0,128];}
		if(color=="BLACK"){co = [255,255,255];}
		if(color=="WHITE"){co = [255,255,255];}
		CoreLaser(255,255,255,1,-30);
		CoreLaser(co[0],co[1],co[2],1.5,0);
		LineLaser(224,224,224,1);
		LineLaser(co[0],co[1],co[2],1.2);
		LineLaser(co[0],co[1],co[2],1.2);
		return shot;
		task CoreLaser(r,g,b,size,px){
		let obj=ObjPrim_Create(OBJ_SPRITE_2D);
		let img=GetCurrentScriptDirectory ~ "./../../Image/Slaser.png";
		ObjPrim_SetTexture(obj,img);
		ObjRender_SetAngleXYZ(obj,0,0,ObjMove_GetAngle(shot));
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		if(color=="BLACK"){ObjRender_SetBlendType(obj,BLEND_SUBTRACT);}
		ObjRender_SetColor(obj,r,g,b);
		ObjRender_SetScaleXYZ(obj,size,size,0);
		ManageEffect;
		CheckDelete(obj,px,0);
			task ManageEffect{
				let c = 0;
				while(!Obj_IsDeleted(obj) && c<time && !Obj_IsDeleted(shot)){
				ObjSprite2D_SetSourceRect(obj,1,256-133,124,256);
				ObjSprite2D_SetDestCenter(obj);
				yield;
				yield;
				c+=2;
				ObjSprite2D_SetSourceRect(obj,126,256-133,253,256);
				ObjSprite2D_SetDestCenter(obj);
				yield;
				yield;
				c+=2}
				descent(i in 0..50){
				if(Obj_IsDeleted(shot)){break;}
				ObjRender_SetScaleXYZ(obj,size,size*(i/50),0);
				yield;}
				Obj_Delete(obj);}}
		task LineLaser(r,g,b,size){
		let obj=ObjPrim_Create(OBJ_SPRITE_2D);
		let img=GetCurrentScriptDirectory ~ "./../../Image/Slaser.png";
		let t = 0; // specific counter
		let ysize = 0.3;
		ObjPrim_SetTexture(obj,img);
		ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
		ObjRender_SetPosition(obj,x+63*cos(dir),y+63*sin(dir),0);
		ObjRender_SetColor(obj,r,g,b);
		ObjRender_SetScaleXYZ(obj,1,ysize/2,1);
		if(color=="BLACK"){ObjRender_SetBlendType(obj,BLEND_SUBTRACT);}
		ManageEffect;
		CheckDelete(obj,0,1);
		if(delay!=999){
			loop(delay){
			if(Obj_IsDeleted(shot)){break;}
			yield;}}
			ascent(i in 10..100){
			if(t>time-45){break;}
			if(Obj_IsDeleted(shot)){break;}
			ObjRender_SetScaleXYZ(obj,1,(i/100)*ysize*4,1);
			SetShotIntersectionLine(ObjMove_GetX(shot)-10*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)-10*sin(ObjMove_GetAngle(shot)),ObjMove_GetX(shot)+length*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)+length*sin(ObjMove_GetAngle(shot)),(i/3)*ysize);
			wait(i%2);}
			if(delay!=999){
				loop(time-delay-40){
				if(Obj_IsDeleted(shot)){break;}
				SetShotIntersectionLine(ObjMove_GetX(shot)-10*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)-10*sin(ObjMove_GetAngle(shot)),ObjMove_GetX(shot)+length*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)+length*sin(ObjMove_GetAngle(shot)),100/3*ysize);
				yield;}}
			if(t<time){
				descent(i in 0..100){
				if(Obj_IsDeleted(shot)){break;}
				ObjRender_SetScaleXYZ(obj,1,(i/100)*ysize*4,1);
				ObjRender_SetColor(obj,(i/60)*r,(i/60)*g,(i/60)*b);
				if(i>50){SetShotIntersectionLine(ObjMove_GetX(shot)-10*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)-10*sin(ObjMove_GetAngle(shot)),ObjMove_GetX(shot)+length*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)+length*sin(ObjMove_GetAngle(shot)),(i/3)*ysize);}
				wait(i%2);}}
			Obj_Delete(shot);
				task ManageEffect{
				let p = 0;
				while(!Obj_IsDeleted(obj) && !Obj_IsDeleted(shot)){
				ObjSprite2D_SetSourceRect(obj,p,0,255*3.5+p,32);
				ObjSprite2D_SetDestRect(obj,128-length,-16,128,16);
				p+=11;
				yield;}}}
		task CheckDelete(obj,px,type){
			while(!Obj_IsDeleted(bossObj) && !Obj_IsDeleted(obj) && !Obj_IsDeleted(shot)){
			if(type==0){
			ObjRender_SetPosition(obj,ObjMove_GetX(shot)+px*cos(ObjMove_GetAngle(shot))+90*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)+px*sin(ObjMove_GetAngle(shot))+90*sin(ObjMove_GetAngle(shot)),0);
			ObjRender_SetAngleXYZ(obj,0,0,ObjMove_GetAngle(shot));}
			if(type==1){
			ObjRender_SetPosition(obj,ObjMove_GetX(shot)+63*cos(ObjMove_GetAngle(shot))+90*cos(ObjMove_GetAngle(shot)),ObjMove_GetY(shot)+63*sin(ObjMove_GetAngle(shot))+90*sin(ObjMove_GetAngle(shot)),0);
			ObjRender_SetAngleXYZ(obj,0,0,ObjMove_GetAngle(shot)+180);}
			yield;}
			Obj_Delete(obj);}}

task TEnd{
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){yield;}

	SetCommonData("Item",1);
	SetCommonData("BG",0);
		yield;
	loop(30){
		DeleteShotInCircle(TYPE_ALL,TYPE_IMMEDIATE,0,0,1);
		yield;}
		Obj_Delete(bossObj);
		yield;
	DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
	CloseScript(GetOwnScriptID());}

task TEnd9{
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){yield;}
	SetCommonData("BG",0);
		yield;
	loop(30){
		DeleteShotInCircle(TYPE_ALL,TYPE_IMMEDIATE,0,0,1);
		yield;}
		Obj_Delete(bossObj);
		yield;
	DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
	CloseScript(GetOwnScriptID());}

task TSamsaraEnd{
	while(ObjEnemy_GetInfo(bossObj, INFO_LIFE) > 0){yield;}
	SetCommonData("Item",1);
	let GetX = ObjMove_GetX(bossObj);
	let GetY = ObjMove_GetY(bossObj);
	SetCommonData("BG",0);
	let b = 1;
	loop(60){
		DeleteShotInCircle(TYPE_SHOT,TYPE_IMMEDIATE,0,0,1);
		Set2DCameraRatioX(b);
		b-=1/60; yield;}
		yield;
		ResetShaderI(0, 99);
		Obj_Delete(bossObj);
		DeleteShotAll(TYPE_ALL,TYPE_IMMEDIATE);
		yield;
		CloseScript(GetOwnScriptID());}

function wait(w){loop(w){yield;}}
function CenterX{return GetStgFrameWidth/2;}
function CenterY{return GetStgFrameHeight/2;}