task cutin(cutinImg,type,type2,r,g,b){
	yield;
	let obj = Obj_Create(OBJ_EFFECT);
	let alphret = 0;
	let as = 0;
	let c = 0;
	let x = -100;
	let y = -100;
	Obj_SetPosition(obj,x,y);
	ObjEffect_SetRenderState(obj,ALPHA);
	ObjEffect_SetTexture(obj,cutinImg);
	ObjEffect_SetLayer(obj,2);
	cutinEffect_Alphret(obj,as,alphret);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexXY(obj, 0, -128, -256);
	ObjEffect_SetVertexUV(obj, 0, 0+256*type, 0);
	ObjEffect_SetVertexXY(obj, 1, 128, -256);
	ObjEffect_SetVertexUV(obj, 1, 256+256*type, 0);
	ObjEffect_SetVertexXY(obj, 2, -128, 256);
	ObjEffect_SetVertexUV(obj, 2, 0+256*type, 512);
	ObjEffect_SetVertexXY(obj, 3, 128, 256);
	ObjEffect_SetVertexUV(obj, 3, 256+256*type, 512);
	while(! Obj_BeDeleted(obj)){
		alternative(type2)
		case(0) {
			if(c==0){ x = GetClipMaxX+256; y = GetCenterY-120; }
			if(c<21){x-=20; y+=5}
			if(c>=21 && c<100){x--; y+=0.5;}
			if(c>=100){x-=20; y+=5;}
			if(c>120){ Obj_Delete(obj); }
		}
		case(1) {
			if(c==0){ x = GetCenterX-80; y = GetCenterY-416; }
			if(c<21){x-=1; y+=20}
			if(c>=21 && c<100){x-=1/32; y+=1/2;}
			if(c>=100){x--; y+=20;}
			if(c>120){ Obj_Delete(obj); }
		}
		case(2) {
			if(c==0){ x = GetCenterX+80; y = GetCenterY+480; }
			if(c<21){x+=1; y-=20}
			if(c>=21 && c<100){x+=1/32; y-=1/2;}
			if(c>=100){x++; y-=20;}
			if(c>120){ Obj_Delete(obj); }
		}
		Obj_SetPosition(obj,x,y);
		if(GetCommonDataDefaultEx("Config", "Boss Effects", true)) {
			if(c%[2,1][type2==0] == 0) { cutinAura(x, y, cutinImg, type, r, g, b); }
		}
		c++;
		yield;
	}
}

task cutinAura(x,y,cutinImg,type,r,g,b){
	//yield;
	let obj = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,x,y);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetTexture(obj,cutinImg);
	ObjEffect_SetLayer(obj,1);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexXY(obj, 0, -128, -256);
	ObjEffect_SetVertexUV(obj, 0, 512+256*type, 0);
	ObjEffect_SetVertexXY(obj, 1, 128, -256);
	ObjEffect_SetVertexUV(obj, 1, 512+256+256*type, 0);
	ObjEffect_SetVertexXY(obj, 2, -128, 256);
	ObjEffect_SetVertexUV(obj, 2, 512+256*type, 512);
	ObjEffect_SetVertexXY(obj, 3, 128, 256);
	ObjEffect_SetVertexUV(obj, 3, 512+256+256*type, 512);
	let t = 30; let e = 1/10;
	descent(i in 0..t) {
		ObjEffect_SetScale(obj, 1+(t-i)/t*1/2, 1+(t-i)/t*1/3);
		ascent(j in 0..4) { ObjEffect_SetVertexColor(obj, j, 255, r*i/t*e, g*i/t*e, b*i/t*e); }
		yield;
	}
	Obj_Delete(obj);
}

task cutinEffect_Alphret(obj,as,alphret) {
	let c = 0;
	loop{
	  	ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
	 	ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);
		if(as==0){alphret+=20; if(alphret>250){as=1;} }
		if(as==1){c++; if(c==90){ as=2; } }
		if(as==2){alphret-=10; if(alphret<10){as=4;} }	
		yield;
	}
}

task spellcardattack {
	if(GetCommonDataDefaultEx("Config", "Boss Effects", true)) {
		summontext;
		summonhexagon;
	}
}

task summontext {
	let yyPos = 0;
	loop(5){
		spellcardtext(GetClipMinX,GetClipMaxY-22-yyPos,1.5);
		spellcardtext(GetClipMaxX,GetClipMinY-30+yyPos,-1.5);
		yyPos+=54;
		yield;
	}
} 

task summonhexagon {
	let dir = 0;
	loop(8){
		hexagontext(GetCenterX+100,GetCenterY+150,1.5,dir,1.4,1.4);
		hexagontext(GetCenterX+100,GetCenterY+150,1.5,dir,1.2,1.2);
		hexagontext(GetCenterX+100,GetCenterY+150,-1.5,-dir,1.0,1.0);
		hexagontext(80,100,1.5,dir,0.8,0.8);
		dir+=45;
		yield;
	}
}

task hexagontext(x,y,v,draai,sx,sy) {
	let obj = Obj_Create(OBJ_EFFECT);
	let alphret = 0;
	let as = 0;
	let c = 0;
	let angle = draai;
	let speed = v;

	Obj_SetPosition(obj,x,y);	
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetTexture(obj,hudenemy);
	ObjEffect_SetScale(obj, sx, sy);
	ObjEffect_SetLayer(obj,2);

	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);

	ObjEffect_SetVertexXY(obj, 0, -48, -128);
	ObjEffect_SetVertexUV(obj, 0, 128, 48);
	ObjEffect_SetVertexXY(obj, 1, 48, -128);
	ObjEffect_SetVertexUV(obj, 1, 256, 48);
	ObjEffect_SetVertexXY(obj, 2, -48, -116);
	ObjEffect_SetVertexUV(obj, 2, 128, 64);
	ObjEffect_SetVertexXY(obj, 3, 48, -116);
	ObjEffect_SetVertexUV(obj, 3, 256, 64);

	while(! Obj_BeDeleted(obj)){
		ObjEffect_SetAngle(obj,0,0,angle);
	  	ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
	 	ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);

		if(as==0){alphret+=20; if(alphret>185){as=1;} }
		if(as==1){c++; if(c==90){as=2;} }		
		if(as==2){alphret-=10; if(alphret<0){ Obj_Delete(obj); } }
		angle += speed;

		yield;
	}
}

task spellcardtext(x,y,v) {
	let obj = Obj_Create(OBJ_EFFECT);
	let alphret = 0;
	let as = 0;
	let c = 0;
	
	Obj_SetPosition(obj,x,y);
	Obj_SetSpeed(obj,v);
	Obj_SetAngle(obj,-35);
	ObjEffect_SetAngle(obj,0,0,-35);
	ObjEffect_SetRenderState(obj,ADD);
	ObjEffect_SetTexture(obj,"spell_line");
	ObjEffect_SetLayer(obj,2);

	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexXY(obj, 0, -512, -8);
	ObjEffect_SetVertexUV(obj, 0, 0, 0);
	ObjEffect_SetVertexXY(obj, 1, 512, -8);
	ObjEffect_SetVertexUV(obj, 1, 1024, 0);
	ObjEffect_SetVertexXY(obj, 2, -512, 8);
	ObjEffect_SetVertexUV(obj, 2, 0, 16);
	ObjEffect_SetVertexXY(obj, 3, 512, 8);
	ObjEffect_SetVertexUV(obj, 3, 1024, 16);

	while(! Obj_BeDeleted(obj)){
	  	ObjEffect_SetVertexColor(obj,0,alphret,255,255,255);
	 	ObjEffect_SetVertexColor(obj,1,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,2,alphret,255,255,255);
	  	ObjEffect_SetVertexColor(obj,3,alphret,255,255,255);
		if(as==0){alphret+=20; if(alphret>185){as=1;} }
		if(as==1){c++; if(c==90){as=2;} }		
		if(as==2){alphret-=10; if(alphret<0){ Obj_Delete(obj); } }
		yield;
	}
}

task spellcardattack2 {
	let obj = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj,GetCenterX,GetCenterY-96);
	Obj_SetSpeed(obj,-3); ObjEffect_SetRenderState(obj,ALPHA);
	ObjEffect_SetTexture(obj,shield); ObjEffect_SetLayer(obj,4);
	ObjEffect_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj, 4);
	ObjEffect_SetVertexUV(obj, 0, 0, 384); ObjEffect_SetVertexUV(obj, 1, 2048, 384);
	ObjEffect_SetVertexUV(obj, 2, 0, 448); ObjEffect_SetVertexUV(obj, 3, 2048, 448);
	ObjEffect_SetVertexXY(obj, 0, -1024, -32); ObjEffect_SetVertexXY(obj, 1, 1024, -32);
	ObjEffect_SetVertexXY(obj, 2, -1024, 32); ObjEffect_SetVertexXY(obj, 3, 1024, 32);
	let obj4 = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj4,GetCenterX,GetCenterY+96);
	Obj_SetSpeed(obj4,-3); ObjEffect_SetRenderState(obj4,ALPHA);
	ObjEffect_SetTexture(obj4,shield); ObjEffect_SetLayer(obj4,4);
	ObjEffect_SetPrimitiveType(obj4, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj4, 4);
	ObjEffect_SetVertexUV(obj4, 0, 0, 384); ObjEffect_SetVertexUV(obj4, 1, 2048, 384);
	ObjEffect_SetVertexUV(obj4, 2, 0, 448); ObjEffect_SetVertexUV(obj4, 3, 2048, 448);
	ObjEffect_SetVertexXY(obj4, 0, -1024, -32); ObjEffect_SetVertexXY(obj4, 1, 1024, -32);
	ObjEffect_SetVertexXY(obj4, 2, -1024, 32); ObjEffect_SetVertexXY(obj4, 3, 1024, 32);
	let obj2 = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj2,GetCenterX,GetCenterY-160);
	Obj_SetSpeed(obj2,-3); ObjEffect_SetRenderState(obj2,ALPHA);
	ObjEffect_SetTexture(obj2,shield); ObjEffect_SetLayer(obj2,4);
	ObjEffect_SetPrimitiveType(obj2, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj2, 4);
	ObjEffect_SetVertexUV(obj2, 0, 0, 448); ObjEffect_SetVertexUV(obj2, 1, 2048, 448);
	ObjEffect_SetVertexUV(obj2, 2, 0, 512); ObjEffect_SetVertexUV(obj2, 3, 2048, 512);
	ObjEffect_SetVertexXY(obj2, 0, -1024, -32); ObjEffect_SetVertexXY(obj2, 1, 1024, -32);
	ObjEffect_SetVertexXY(obj2, 2, -1024, 32); ObjEffect_SetVertexXY(obj2, 3, 1024, 32);
	let obj5 = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj5,GetCenterX,GetCenterY+160);
	Obj_SetSpeed(obj5,-3); ObjEffect_SetRenderState(obj5,ALPHA);
	ObjEffect_SetTexture(obj5,shield); ObjEffect_SetLayer(obj5,4);
	ObjEffect_SetPrimitiveType(obj5, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj5, 4);
	ObjEffect_SetVertexUV(obj5, 0, 0, 448); ObjEffect_SetVertexUV(obj5, 1, 2048, 448);
	ObjEffect_SetVertexUV(obj5, 2, 0, 512); ObjEffect_SetVertexUV(obj5, 3, 2048, 512);
	ObjEffect_SetVertexXY(obj5, 0, -1024, -32); ObjEffect_SetVertexXY(obj5, 1, 1024, -32);
	ObjEffect_SetVertexXY(obj5, 2, -1024, 32); ObjEffect_SetVertexXY(obj5, 3, 1024, 32);
	let obj3 = Obj_Create(OBJ_EFFECT);
	Obj_SetPosition(obj3,GetCenterX,GetCenterY);
	Obj_SetSpeed(obj3,2); ObjEffect_SetRenderState(obj2,ALPHA);
	ObjEffect_SetTexture(obj3,shield); ObjEffect_SetLayer(obj3,4);
	ObjEffect_SetPrimitiveType(obj3, PRIMITIVE_TRIANGLESTRIP);
	ObjEffect_CreateVertex(obj3, 4);
	ObjEffect_SetVertexUV(obj3, 0, 0, 256); ObjEffect_SetVertexUV(obj3, 1, 2048, 256);
	ObjEffect_SetVertexUV(obj3, 2, 0, 384); ObjEffect_SetVertexUV(obj3, 3, 2048, 384);
	ObjEffect_SetVertexXY(obj3, 0, -1024, -64); ObjEffect_SetVertexXY(obj3, 1, 1024, -64);
	ObjEffect_SetVertexXY(obj3, 2, -1024, 64); ObjEffect_SetVertexXY(obj3, 3, 1024, 64);
	descent(i in 0..60) {
	  	ascent(j in 0..4) {
			ObjEffect_SetVertexColor(obj,j,255*cos(i*90/60),255,255,255);
			ObjEffect_SetVertexColor(obj2,j,255*cos(i*90/60),255,255,255);
			ObjEffect_SetVertexColor(obj3,j,255*cos(i*90/60),255,255,255);
			ObjEffect_SetVertexColor(obj4,j,255*cos(i*90/60),255,255,255);
			ObjEffect_SetVertexColor(obj5,j,255*cos(i*90/60),255,255,255);
		}
		yield;
	}
	loop(60) { yield; }
	descent(i in 0..60) {
	  	ascent(j in 0..4) {
			ObjEffect_SetVertexColor(obj,j,255*i/60,255,255,255);
			ObjEffect_SetVertexColor(obj2,j,255*i/60,255,255,255);
			ObjEffect_SetVertexColor(obj3,j,255*i/60,255,255,255);
			ObjEffect_SetVertexColor(obj4,j,255*i/60,255,255,255);
			ObjEffect_SetVertexColor(obj5,j,255*i/60,255,255,255);
		}
		yield;
	}
	Obj_Delete(obj);
	Obj_Delete(obj2);
	Obj_Delete(obj3);
	Obj_Delete(obj4);
	Obj_Delete(obj5);
}