function SpellCard(time, name, colors, image, image2, y, y2, scale){
	let objScene = GetEnemyBossSceneObjectID();
	ObjEnemyBossScene_StartSpell(objScene);
	BarName(time, name, colors);
	CutinItself(image, image2, y, y2, scale, time);
	ChainSet(time);
	ChainSet2(time);
	Card(colors);
	Black;

	loop(time){yield;}
}

task CutinItself(image, image2, y, y2, scale, time){
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	
	ObjPrim_SetTexture(obj, image);
	Obj_SetRenderPriority(obj, 1);
	ObjSprite2D_SetSourceRect(obj,0,0,GetTextureWidth(image),GetTextureHeight(image));
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetScaleXYZ(obj,scale,scale,0);
	ObjRender_SetAngleXYZ(obj,0,0,0);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	ObjRender_SetColor(obj, 255, 255, 255);
	
	ObjPrim_SetTexture(obj2, image2);
	Obj_SetRenderPriority(obj2, 0.6);
	ObjSprite2D_SetSourceRect(obj2,0,0,GetTextureWidth(image),GetTextureHeight(image));
	ObjSprite2D_SetDestCenter(obj2);	
	ObjRender_SetScaleXYZ(obj2,scale*1.5,scale*1.5,0);
	ObjRender_SetAngleXYZ(obj2,0,0,0);
	ObjRender_SetBlendType(obj2, BLEND_ALPHA);
	ObjRender_SetAlpha(obj2, 122);
	ObjRender_SetColor(obj2, 255, 255, 255);
	
	ObjRender_SetY(obj, GetStgFrameHeight/2+y/2);
	ObjRender_SetX(obj, GetStgFrameWidth+40);
	
	ObjRender_SetY(obj2, GetStgFrameHeight/2+y2);
	ObjRender_SetX(obj2, GetStgFrameWidth/2);
	
	go(obj2);
	
	task go(obj2){
	let a = 0;
	ascent(i in 0..10){
	//ObjRender_SetX(obj2, GetStgFrameWidth/2-15*tan((i+130)*1.1-90));
	ObjRender_SetAlpha(obj2, 0+i*15);
	yield;
	}
	loop(time*0.75){yield;}
	ascent(i in 0..30){
	//ObjRender_SetX(obj2, GetStgFrameWidth/2-15*tan((i+130)*1.1-90));
	ObjRender_SetAlpha(obj2, 122-i*4);
	yield;
	}
	Obj_Delete(obj2);
	}
	
	let a = 0;
	let scaleX = scale;
	
	ascent(i in 0..time){
	ObjRender_SetX(obj, GetStgFrameWidth/2-75*tan(a*1-90));
	ObjRender_SetY(obj, GetStgFrameHeight/2+50*cos(90-a)+y);
	a+=180/time;
	yield;
	}

	/*//SPIN
	ascent(i in 0..time*2){
	ObjRender_SetX(obj, -20+i*5);
	ObjRender_SetAngleZ(obj, i*12);
	yield;
	}*/
	
	
	Obj_Delete(obj);
}

task Black{
	let count = 0;
	let a = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	
	Obj_SetRenderPriority(obj,0.26);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "/img/effects/dummy.png");
	ObjSprite2D_SetSourceRect(obj,0,0,1024,1024);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetBlendType(obj,BLEND_ALPHA);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2, GetStgFrameHeight/2,0);
	ObjRender_SetColor(obj, 0, 0, 0);
	ObjRender_SetAlpha(obj, 255);
	loop{
	if(a>60){ObjRender_SetAlpha(obj, 255-count*2);
	count++;}
	a++;
	yield;
	}
	Obj_Delete(obj);
}

task BarName(time, name, colors){
	let objBar = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(objBar, BLEND_ALPHA);
	Obj_SetRenderPriority(objBar, 0.8);
	ObjPrim_SetTexture(objBar, GetCurrentScriptDirectory ~ "/img/SpellBar.png");
	ObjSprite2D_SetSourceRect(objBar, 0, 0, 256, 39);
	ObjSprite2D_SetDestCenter(objBar);
	ObjRender_SetColor(objBar, colors[0], colors[1], colors[2]);
	
	let objText = ObjText_Create;
	Obj_SetRenderPriority(objText, 0.9);
	ObjText_SetText(objText,name);
	ObjText_SetFontType(objText, "Modern No. 20");
	ObjText_SetFontSize(objText,12);
	ObjText_SetFontColorBottom(objText,255,255,255);
	ObjText_SetFontColorTop(objText, colors[0], colors[1], colors[2]);
	ObjText_SetFontBorderType(objText,BORDER_FULL);
	ObjText_SetFontBorderColor(objText,32,32,32);
	ObjText_SetFontBorderWidth(objText,1.5);
	ObjText_SetHorizontalAlignment(objText, ALIGNMENT_CENTER);
	ObjText_SetMaxWidth(objText, 400);
	
	ObjRender_SetX(objBar, GetStgFrameWidth/2);
	ObjRender_SetX(objText, -200+GetStgFrameWidth/2);
	
	let spd = 4;
	let move = 0;
	ascent(i in 0..30){
	ObjRender_SetY(objBar, 480-move);
	ObjRender_SetY(objText, 480-6-move);	
	move+=spd;
	if(spd > 0){spd-=4/30}
	yield;
	}
	loop(time/2){yield;}
	spd = 12;
	ascent(i in 0..60){
	ObjRender_SetY(objBar, 480-move);
	ObjRender_SetY(objText, 480-5-move);	
	move+=spd;
	if(spd > 0){spd-=12/60}
	yield;
	}
}


task ChainSet(time){
	ascent(i in 0..12){
	Chain(0, 24+i*40, 0,  0,  90, time);
	}
}

task ChainSet2(time){
	loop(6){
	Chain(GetStgFrameWidth/2, GetStgFrameHeight/2, rand(0, 0.4),  rand(0, 0.4),  rand(0, 360), time);
	}
}

task Chain(x, y, xvel, yvel, ang, time){
	let alpha = 0;
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriority(obj,0.5);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory~"./img/chain.png");
	ObjSprite2D_SetSourceRect(obj,0,0,20,2200);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,1);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj, alpha);
	ObjRender_SetAngleZ(obj, ang);
	ObjRender_SetPosition(obj, x,y,0);
	let count = 0;
	loop(time){
	if(alpha<255){alpha+=10;}
	ObjRender_SetAlpha(obj, alpha);
	ObjSprite2D_SetSourceRect(obj,0,count,20,count-2200);
	ObjRender_SetPosition(obj, x+(count/6*xvel),y+(count/6*yvel),0);
	count+=6;
	yield;}
	
	loop(30){
	ObjSprite2D_SetSourceRect(obj,0,count,20,count-2200);
	ObjRender_SetPosition(obj, x+(count/6*xvel),y+(count/6*yvel),0);
	count+=6;
	
	alpha-=255/30;
	ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);
}

task Card(colors){
let a =ObjPrim_Create(OBJ_SPRITE_2D);
let b =ObjPrim_Create(OBJ_SPRITE_2D);
let c =ObjPrim_Create(OBJ_SPRITE_2D);
let d =ObjPrim_Create(OBJ_SPRITE_2D);
let e =ObjPrim_Create(OBJ_SPRITE_2D);
let f =ObjPrim_Create(OBJ_SPRITE_2D);
let g =ObjPrim_Create(OBJ_SPRITE_2D);
let h =ObjPrim_Create(OBJ_SPRITE_2D);
let SplitCard = [a, b, c, d, e, f, g, h];

	ascent(i in 0..length(SplitCard)){
	ObjPrim_SetTexture(SplitCard[i], CardAr[i]);
	ObjRender_SetBlendType(SplitCard[i], BLEND_ALPHA);
	Obj_SetRenderPriority(SplitCard[i], 0.9);
	ObjSprite2D_SetSourceRect(SplitCard[i], 0, 0, 190, 500);
	ObjSprite2D_SetDestCenter(SplitCard[i]);
	ObjRender_SetColor(SplitCard[i], colors[0], colors[1], colors[2]);
	ObjRender_SetAlpha(SplitCard[i], 0);
	ObjRender_SetScaleXYZ(SplitCard[i], 4, 4, 1);
	ObjRender_SetPosition(SplitCard[i], GetStgFrameWidth/2, GetStgFrameHeight/2, 0);
	ScaleDown(SplitCard[i]);
	}
	wait(30);
	let angle = 45;
	CornerMove(SplitCard[0],0, 180, -1);
	CornerMove(SplitCard[1],90, 90, 1);
	CornerMove(SplitCard[2],180, 90, 1);
	CornerMove(SplitCard[3],270, 180, -1);
	
	BorderSpin(SplitCard[4]);
	
	let Scaling = 0;
	
	ScaleUpABit(SplitCard[5], 1);
	ScaleUpABit(SplitCard[6], 200);
	
	ScalaleUpdown(SplitCard[5], 1.5);
	
	Spiiiin(SplitCard[5], 1);
	Spiiiin(SplitCard[6], -1);
	Spiiiin(SplitCard[7], 1);
	
	wait(60);
	
	AlphaDownAndDelete(SplitCard[5],100);
	AlphaDownAndDelete(SplitCard[6],100);
	wait(30);
	AlphaDownAndDelete(SplitCard[4],100);
	AlphaDownAndDelete(SplitCard[7],100);
	AlphaDownAndDelete(SplitCard[0],100);
	AlphaDownAndDelete(SplitCard[1],100);
	AlphaDownAndDelete(SplitCard[2],100);
	AlphaDownAndDelete(SplitCard[3],100);
	
	task AlphaDownAndDelete(obj,mult){
	let alpha = 255;
	loop(mult){
	alpha-=255/mult;
	ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);
	}
	
	task ScalaleUpdown(obj, mult){
	wait(35);
	while(!Obj_IsDeleted(obj)){
	Scaling+=0.002*mult;
	ObjRender_SetScaleXYZ(obj, 1+Scaling, 1+Scaling, 1);
	yield;}
	}
	
	task Spiiiin(obj, mult){
	wait(30);
		while(!Obj_IsDeleted(obj)){
		let angle = ObjRender_GetAngleZ(obj);
		ObjRender_SetAngleZ(obj, angle+(6*mult));
		yield;
		}
	}
	
	task ScaleUpABit(obj, mult){
	loop(5){
	Scaling+=0.0005*(mult*0.7);
	ObjRender_SetScaleXYZ(obj, 1+Scaling, 1+Scaling, 1);
	yield;}
	}
	
	
	task BorderSpin(obj){
	let scale = 0;
		while(!Obj_IsDeleted(obj)){
		let angle = ObjRender_GetAngleZ(obj);
		ObjRender_SetAngleZ(obj, angle+6);
		scale+=0.002;
		ObjRender_SetScaleXYZ(obj, 0.7+scale, 0.7+scale, 1);
		yield;
		}
	}
	
	task ScaleDown(obj){
	let alpha = 0;
	let scale = 0;
	loop(15){
	alpha+=4.1*4;
	ObjRender_SetAlpha(obj,alpha);
	scale+=0.055*4;
	ObjRender_SetScaleXYZ(obj, 4-scale, 4-scale, 1);
	yield;}
	}	
		task CornerMove(obj, i,mult, multi){
		let radius = 0;
		let X = GetStgFrameWidth/2;
		let Y = GetStgFrameHeight/2;
		loop(10){
		ObjRender_SetPosition(obj, X+radius*cos(angle+(i*360/4)+mult), Y+radius*sin(angle+(i*360/4)+mult), 0);
		radius+=6;
		yield;
		}
		wait(40);
		loop(160){
		ObjRender_SetPosition(obj, X+radius*cos(angle+(i*360/4)+mult), Y+radius*sin(angle+(i*360/4)+mult), 0);
		ObjRender_SetAngleZ(obj, ObjRender_GetAngleZ(obj)+(1*multi));
		radius-=0.5;
		yield;
		}
		}
}
let C1 =  GetCurrentScriptDirectory~"./img/Card/card1.png";
let C2 =  GetCurrentScriptDirectory~"./img/Card/card2.png";
let C3 =  GetCurrentScriptDirectory~"./img/Card/card3.png";
let C4 =  GetCurrentScriptDirectory~"./img/Card/card4.png";
let C5 =  GetCurrentScriptDirectory~"./img/Card/card5.png";
let C6 =  GetCurrentScriptDirectory~"./img/Card/card6.png";
let C7 =  GetCurrentScriptDirectory~"./img/Card/card7.png";
let C8 =  GetCurrentScriptDirectory~"./img/Card/card8.png";
let CardAr = [C1, C2, C3, C4, C5, C6, C7, C8];