task cutin_boss(name,cutaninus,colorrr,cuttype){
	InstallFont(GetCurrentScriptDirectory ~ "../font/MonoSpatial.ttf");
	CutPhoto(cutaninus,0,0,1,0.79);
	if(cuttype == "Normal"){LineSpellThing;}
	else{CAUTIONBITCH;}
	_PlaySE(0);
	wait(20);
	CutName(name);

	task CutPhoto(path,x,y,dir,pri){
		let obj = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj, GetMainStgScriptDirectory ~ "img/cutin/" ~ path ~ ".png");
		Obj_SetRenderPriority(obj, pri);
		ObjSprite2D_SetSourceRect(obj, 0, 0, GetTextureWidth(GetMainStgScriptDirectory ~ "img/cutin/" ~ path ~ ".png"), GetTextureHeight(GetMainStgScriptDirectory ~ "img/cutin/" ~ path ~ ".png"));
		ObjSprite2D_SetDestCenter(obj);
		
		ascent(a in 1..31){
			ObjRender_SetPosition(obj,400+100*(a-35)/45,340+120*sin(180+45-a/30*180),0);
			ObjRender_SetAlpha(obj,a/30*255);
			if(a%6 == 0){AfterImage(400+100*(a-35)/45,340+120*sin(180+45-a/30*180), 30, 1.5, colorrr[0], colorrr[1], colorrr[2]);}
			yield;
		}

		ascent(a in 1..61){
			ObjRender_SetPosition(obj,400+100*(a/3-5)/45,340+120*sin(45-a/60*60),0);
			if(a%6 == 0){AfterImage(400+100*(a/3-5)/45,340+120*sin(45-a/60*60), 30, 1.5, colorrr[0], colorrr[1], colorrr[2]);}
			yield;
		}

		ascent(a in 1..31){
			ObjRender_SetPosition(obj,400+100*(a+15)/45,340+120*sin(-15-a/30*180),0);
			if(a%6 == 0){AfterImage(400+100*(a+15)/45,340+120*sin(-15-a/30*180), 30, 1.5, colorrr[0], colorrr[1], colorrr[2]);}
			ObjRender_SetAlpha(obj,(30-a)/60*255);
			yield;
		}
		Obj_Delete(obj);
		task AfterImage(x,y, frame, rate, R, G, Bl){
				let scale = 1.0;
				let scale_rate = (rate-1.0)/frame;
				let alpha = 255;
				let alpha_rate = 255/frame;

				let obj=ObjPrim_Create(OBJ_SPRITE_2D);
				ObjRender_SetBlendType(obj, BLEND_ADD_RGB);
				ObjRender_SetPosition(obj, x,y, 0);
				ObjPrim_SetTexture(obj, GetMainStgScriptDirectory ~ "img/cutin/" ~ path ~ ".png");
				Obj_SetRenderPriority(obj, pri-0.01);
				ObjSprite2D_SetSourceRect(obj, 0, 0, GetTextureWidth(GetMainStgScriptDirectory ~ "img/cutin/" ~ path ~ ".png"), GetTextureHeight(GetMainStgScriptDirectory ~ "img/cutin/" ~ path ~ ".png"));
				ObjSprite2D_SetDestCenter(obj);  
				ObjRender_SetAlpha(obj, 255);
				let sx = 0.85;
				let sy = 0.85;
				loop(frame){
					ObjRender_SetScaleXYZ(obj, sx * scale, sy * scale, 1.0);
					ObjRender_SetColor(obj, R * alpha/255, G * alpha/255, Bl * alpha/255);
					alpha -= alpha_rate;
					scale += scale_rate;
					yield;
				}
				Obj_Delete(obj);
			}
	}

	task CutName(name){
		let obj = ObjText_Create;
		
		let maxx = GetAreaCommonData("Boss","SpellCutin",0);
		let score = GetAreaCommonData("Boss","Score",0);
		
		ObjText_SetText(obj,name);
		ObjText_SetFontType(obj, "MonoSpatial");
		Obj_SetRenderPriority(obj, 0.93);
		ObjText_SetHorizontalAlignment(obj,ALIGNMENT_RIGHT);
		ObjText_SetMaxWidth(obj, maxx);
		ObjRender_SetX(obj, maxx-maxx);
		ObjRender_SetY(obj,GetStgFrameHeight/2+50+44);
		ObjText_SetFontSize(obj,15);
		ObjText_SetFontColorTop(obj, 255, 255, 255);
		ObjText_SetFontColorBottom(obj, 255, 120, 120);
		ObjText_SetFontBorderWidth(obj, 1);
		ObjText_SetFontBorderColor(obj, 0,0,0);
		ObjText_SetFontBorderType(obj, BORDER_FULL);

		let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
		ObjPrim_SetTexture(obj2, GetMainStgScriptDirectory ~ "img/system/Default_System.png");
		Obj_SetRenderPriorityI(obj2, 93);
		ObjSprite2D_SetSourceRect(obj2, 0, 56, 256,59);
		ObjSprite2D_SetDestCenter(obj2);
		ObjRender_SetPosition(obj2,532-256/2,44+18,0);
		ObjRender_SetAlpha(obj2,0);
		ObjRender_SetBlendType(obj2,BLEND_ADD_ARGB);

		ascent(a in 0..20){
			ObjRender_SetAlpha(obj,255*sin(a*9/2));
			maxx = GetAreaCommonData("Boss","SpellCutin",0);
			ObjText_SetMaxWidth(obj, maxx);
			ObjRender_SetX(obj, maxx-maxx);
			ObjText_SetFontSize(obj,25-a/19*10);
			
			yield;
		}
		
		loop(60){
			yield;
			}
		
		ascent(a in 0..20){
			ObjRender_SetY(obj,GetStgFrameHeight/2+50+44-(GetStgFrameHeight/2+50)*sin(a*4.5));//50
			maxx = GetAreaCommonData("Boss","SpellCutin",0);
			ObjText_SetMaxWidth(obj, maxx);
			ObjRender_SetX(obj, maxx-maxx);
			
			yield;
		}
		
		let a = 0;
		let as = 0;
		
		while(! Obj_IsDeleted(obj)){
			if(GetPlayerY < 105 && GetPlayerY > 45){a = min(120,a+120/7);}
			else{a = max(0,a-120/7);}
			maxx = GetAreaCommonData("Boss","SpellCutin",0);
			as = min(1,as+1/20);

			ObjRender_SetAlpha(obj,255-a);
			ObjRender_SetAlpha(obj2,(255-a)*as);

			yield;
		}
	}

	task LineSpellThing(){
		let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
		ObjPrim_SetTexture(obj, GetMainStgScriptDirectory ~ "img/system/eff_line.png");
		Obj_SetRenderPriority(obj, 0.78);
		ObjRender_SetAngleXYZ(obj,180,180,-70);
		ObjRender_SetPosition(obj,centerX,centerY,0);

		let t = 0;
		let alpha = 0;

		loop(120){
			ObjSpriteList2D_ClearVertexCount(obj);
			ascent(a in -3..4){
				ObjSpriteList2D_SetSourceRect(obj,99,
				t*6*[1,-1][(a+9)%2],109,800+t*6*[1,-1][(a+9)%2]);
				ObjSpriteList2D_SetDestRect(obj,a*60-10,-400,a*60+10,400);
				ObjSpriteList2D_AddVertex(obj);
			}

			if(t < 20){alpha+=255/20;}
			else if (t < 100){}
			else{alpha-=255/20;}
			ObjRender_SetAlpha(obj,alpha);
			
			t++;

			yield;
		}

		Obj_Delete(obj);
	}

	task CAUTIONBITCH(){
		let obj = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
		ObjPrim_SetTexture(obj, GetMainStgScriptDirectory ~ "img/effect/CAUTION.png");
		Obj_SetRenderPriority(obj, 0.78);
		ObjRender_SetAngleXYZ(obj,0,0,20);
		ObjRender_SetPosition(obj,centerX,centerY,0);
		ObjRender_SetScaleXYZ(obj,0.9,0.9,0);

		let t = 0;
		let alpha = 0;

		loop(120){
			ObjSpriteList2D_ClearVertexCount(obj);
			ascent(a in -1..2){
				ObjSpriteList2D_SetSourceRect(obj,t*5,
				1,t*5+256*6,128);
				ObjSpriteList2D_SetDestRect(obj,-256*3,1+280*a-64,256*3,128+280*a-64);
				ObjSpriteList2D_AddVertex(obj);

				ObjSpriteList2D_SetSourceRect(obj,-t*5,
				220,-t*5+256*6,256);
				ObjSpriteList2D_SetDestRect(obj,-256*3,-36+280*a-64,256*3,280*a-64);
				ObjSpriteList2D_AddVertex(obj);

				ObjSpriteList2D_SetSourceRect(obj,-t*5,
				220,-t*5+256*6,256);
				ObjSpriteList2D_SetDestRect(obj,-256*3,128+280*a-64,256*3,128+36+280*a-64);
				ObjSpriteList2D_AddVertex(obj);
			}

			if(t < 20){alpha+=255/20;}
			else if (t < 100){}
			else{alpha-=255/20;}
			ObjRender_SetAlpha(obj,alpha);
			
			t++;

			yield;
		}

		Obj_Delete(obj);
	}
}