let imgEffectPower=GetCurrentScriptDirectory~"/img/power_effect.png";
let imgEffectString=GetCurrentScriptDirectory~"/img/string.png";
let priority=30;
let flag=GetCurrentScriptDirectory~"/img/flag.png";
let majora=GetCurrentScriptDirectory~"/img/mask.png";
let emblem=GetCurrentScriptDirectory~"/img/XByo.png";

task CallShot(ID){
let r=0; let shots=[];
let x=ObjMove_GetX(ID); let y=ObjMove_GetY(ID);
while(r<10){
r+=2;
shots=GetShotIdInCircleA2(x, y, r, TARGET_ENEMY);
ascent(i in 0..length(shots)){
if (!ObjShot_IsSpellResist(shots[i])){
BulletBreak([ObjMove_GetX(shots[i]), ObjMove_GetY(shots[i])],rand(0,360),ObjShot_GetImageID(shots[i]),BLEND_ALPHA);
}}
yield;}
}

task ExplosionA3(id, color){

PlaySoundEffect("se_enep02");
//PlaySoundEffect("len_se02");
let rcolor=[0, 0, 0];
alternative (color) 
	case("red"){rcolor=[255, 50, 50];}
	case("orange"){rcolor=[255, 100, 50];}
	case("yellow"){rcolor=[255, 255, 50];}
	case("green"){rcolor=[50, 255, 50];}
	case("blue"){rcolor=[50, 50, 255];}
	case("cyan"){rcolor=[50, 255, 255];}
	case("purple"){rcolor=[255, 50, 255];}
	case("white"){rcolor=[255, 255, 255];}
	
ConcentrationRing;
loop(40){
Sakura(rand(50,150), rand(0.5, 1), rand(0,360));
}
task Sakura(radius, size, angle2){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"/system/img/cherry.png");
	ObjSprite2D_SetSourceRect(obj, 0, 0, 256, 256);
	ObjSprite2D_SetDestCenter(obj);
	let s=0; 
	let r=radius;
	let alpha=240;
	let a=-90;
	let angle=rand(0,360); 
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	loop(50){
	ObjRender_SetPosition(obj, ObjRender_GetX(id)+r*cos(angle2), ObjRender_GetY(id)+r*sin(angle2), 0);
	a+=9/5;
	r=radius*cos(a);
	if (alpha>0){alpha-=6;}
	s+=size/60; ObjRender_SetScaleXYZ(obj, s, s, s);
	ObjRender_SetAlpha(obj, alpha);
	angle+=1;
	ObjRender_SetAngleXYZ(obj, angle, angle, angle);
	yield;}
	Obj_Delete(obj);
}

task ConcentrationRing{
	let circle=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(circle, GetCurrentScriptDirectory~"/img/ring00.png");
	ObjSprite2D_SetSourceRect(circle, 0, 0, 512, 512);
	ObjSprite2D_SetDestCenter(circle);
	let s=1.5; let alpha=180;
	let angle=-90; ObjRender_SetBlendType(circle, BLEND_ADD_ARGB);
	loop(30){angle+=3; s=1*cos(angle); 
	alpha-=6;
	ObjRender_SetAlpha(circle, alpha);
	ObjRender_SetColor(circle, rcolor[0], rcolor[1], rcolor[2]);
	ObjRender_SetScaleXYZ(circle, s, s, 0);
	ObjRender_SetPosition(circle, ObjRender_GetX(id), ObjRender_GetY(id), 0);
	yield;}
	Obj_Delete(circle);
	}
}


task StartSpellMiddle(name, img,base2, r,g,b,rect1,rect2,scale){
PlaySoundEffect("se_cat00");
ScreenShake(60,8);
ObjCutin_SetSpellcardS4(name, "", NAZRIN, 240, 50, 50);
CutinS3(NAZRIN, "", "Normal");
CutInImageBase(img,r,g,b,rect1,rect2,scale);
CutInImageParticle1(base2,rect1,rect2,scale);
DrawMedal(name);
ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID);
}

task CutInImageBase(directory,r,g,b,rect1,rect2,scale){
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, directory);
let sca=1; let rect=[0, 0];
let c=[0, 0, 0];
let v=10; let angle=0; let alpha=0;
if (directory==GetCurrentScriptDirectory~"img/cutin1.png"){rect=[512, 540]; sca=0.85;
c=[0, 255, 0];}
else{rect=[rect1,rect2]; sca=scale; c=[r,g,b];}
ObjRender_SetScaleXYZ(obj, sca, sca, 1);
let x=320; let y=GetStgFrameHeight+10;
ObjSprite2D_SetSourceRect(obj, 0, 0, rect[0], rect[1]);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 90);

MotionBlur;

loop(60){
y+=-v;
x+=0; ObjRender_SetPosition(obj, x, y, 0);
v-=12/60; angle+=90/60; alpha=255*sin(angle);
ObjRender_SetAlpha(obj, alpha);
ObjRender_SetAngleXYZ(obj, 0,0, -45);
yield;}

loop(30){
ObjRender_SetPosition(obj, x, y, 0); 
ObjRender_SetAlpha(obj, alpha);
yield; 
}


Obj_Delete(obj);

	task MotionBlur{
	while(!Obj_IsDeleted(obj)){
	Blur(directory, rect[0], rect[1], sca, c[0], c[1], c[2]);
	loop(2){yield;}}
	}
	task Blur(img, x, y, scale, r, g, b){
	let obj2=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetAngleXYZ(obj2, 0,0, -45);
	ObjPrim_SetTexture(obj2, img);
	ObjSprite2D_SetSourceRect(obj2, 0, 0, x, y);
	ObjSprite2D_SetDestCenter(obj2);
	Obj_SetRenderPriorityI(obj2, 89);
	let alpha=150;
	ObjRender_SetPosition(obj2, ObjRender_GetX(obj), ObjRender_GetY(obj), 0);
	ObjRender_SetColor(obj2, r, g, b);
	ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
	loop(15){
	scale+=0.01; alpha-=10;
	ObjRender_SetScaleXYZ(obj2, scale, scale, 0);
	ObjRender_SetAlpha(obj2, alpha);
	yield;}
	Obj_Delete(obj2);
	}

}

task CutInImageParticle1(directory,rect1,rect2,scale){
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, directory);
let sca=1; let rect=[0, 0];
let c=[0, 0, 0];
let v=10; let angle=0; let alpha=0;
if (directory==GetCurrentScriptDirectory~"img/cutin1.png"){rect=[512, 540]; sca=0.85;
c=[0, 255, 0];}
else{rect=[rect1,rect2]; sca=scale; c=[rand(0,255), rand(0,255), rand(0,255)];}
ObjRender_SetScaleXYZ(obj, sca, sca, 1);
let x=320; let y=GetStgFrameHeight+10;
ObjSprite2D_SetSourceRect(obj, 0, 0, rect[0], rect[1]);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 89);

MotionBlur;

loop(60){
y+=-v;
ObjRender_SetScaleXYZ(obj, scale-0.25, scale-0.25, 0);
scale+=0.2/30;
x+=0; ObjRender_SetPosition(obj, x, y, 0);
v-=12/60; angle+=90/60; alpha=255*sin(angle);
ObjRender_SetAlpha(obj, alpha);

yield;}

loop(30){
ObjRender_SetPosition(obj, x, y, 0); 
ObjRender_SetAlpha(obj, alpha);
yield; 
}

Obj_Delete(obj);

	task MotionBlur{
	while(!Obj_IsDeleted(obj)){
	Blur(directory, rect[0], rect[1], sca);
	loop(2){yield;}}
	}
	task Blur(img, x, y, scale){
	let obj2=ObjPrim_Create(OBJ_SPRITE_2D);
	
	ObjPrim_SetTexture(obj2, img);
	Obj_SetRenderPriorityI(obj2, 90);
	ObjSprite2D_SetSourceRect(obj2, 0, 0, x, y);
	ObjSprite2D_SetDestCenter(obj2);
	let alpha=150;
	ObjRender_SetPosition(obj2, ObjRender_GetX(obj), ObjRender_GetY(obj), 0);
	ObjRender_SetColor(obj2, 247, 0, 37);
	ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
	loop(15){
	scale+=0.02; alpha-=10;
	ObjRender_SetScaleXYZ(obj2, scale, scale, 0);
	ObjRender_SetAlpha(obj2, alpha);
	yield;}
	Obj_Delete(obj2);
	}

}

task ScreenShake(period, intensity)
	{
		loop(period)
		{
			Set2DCameraFocusX(GetStgFrameWidth / 2 + rand(-intensity/2, intensity/2));
			Set2DCameraFocusY(GetStgFrameHeight / 2 + rand(-intensity/2, intensity/2));
			yield;
		}

		Reset2DCamera();
	}

task JunkoBG{
let x = 0;
let r = 60;
	let dir = 190;
	let dir2 = -10;
	let dir3= 270;
	while(x<2){
	CreateJunkoAuraPiece(r*cos(dir),r*sin(dir),dir);
	CreateJunkoAuraPiece(r*cos(dir2),r*sin(dir2),dir2);
	CreateJunkoAuraPiece(r*cos(dir3),r*sin(dir3),dir3);
	dir += 360/9;
	dir2 -= 360/9;
	x++;
	r++;
	wait(8);
}
x = 0;
dir -= 3;
}

task CreateJunkoAuraPiece(x,y,ang){
let img = GetCurrentScriptDirectory~"img/backdrop2.png";
let color = 0;
let alpha = 0;
let xx=0;
let yy=0;
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
Obj_SetRenderPriorityI(obj,37);
Obj_SetRenderPriorityI(obj2,37);
ObjPrim_SetTexture(obj,img);
ObjPrim_SetTexture(obj2,img);
ObjSprite2D_SetSourceRect(obj,0,0,128,84);
ObjSprite2D_SetSourceRect(obj2,0,0,128,84);
ObjSprite2D_SetDestCenter(obj);
ObjSprite2D_SetDestCenter(obj2);
ObjRender_SetAngleZ(obj,ang);
ObjRender_SetAngleZ(obj2,ang);
ObjRender_SetAlpha(obj2,0);
Property;
ascent(i in 0..50){
ObjRender_SetScaleY(obj,xx);
ObjRender_SetScaleX(obj,yy);
xx+=0.021;
yy+=0.021;
yield;
}
CreatePulse;

task CreatePulse{
while(!Obj_IsDeleted(obj)){
ObjRender_SetY(obj2,ObjRender_GetY(obj));
	ObjRender_SetX(obj2,ObjRender_GetX(obj));
ascent(i in 0..91){
alpha = 255-i*255/30;
ObjRender_SetColor(obj2,195+52*sin(color),60+52*sin(color),40+82*sin(color));
ObjRender_SetScaleX(obj2,0.70+sin(i*90/20));
ObjRender_SetScaleY(obj2,0.80+sin(i*90/90));
ObjMove_SetPosition(obj2,ObjMove_GetX(obj)+i*cos(ang),ObjMove_GetY(obj)+i*sin(ang));
ObjRender_SetAlpha(obj2,alpha);
yield;
}
}
}

task Property{
while(!Obj_IsDeleted(obj)){
ObjRender_SetX(obj,ObjRender_GetX(enm)+x);
ObjRender_SetY(obj,ObjRender_GetY(enm)+y);
color+=3;
ObjRender_SetColor(obj,191+60*sin(color),64+52*sin(color),200+45*sin(color));
yield;
}
Obj_Delete(obj);
}
}

task MapleExplode(time,num,min,max){ // task for explode maples
	let px = EnemyX;
	let py = EnemyY;
	ascent(i in 0..time){
	loop(num){
	Explode(EnemyX,EnemyY,rand(min,max),rand(0,359),rand(1,3));
	}
	wait(i%2);
	}
	}
	
	task Explode(px,py,spd,dir,size){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"img/eff2.png";
	let r = 0;
	let angle = rand(0,359);
	let alpha = 255;
	let minus = 256/(size/0.03);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,32,226,64,254);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj,255);
	while(alpha>0){
	ObjRender_SetPosition(obj,px+r*cos(dir),py+r*sin(dir),0);
	ObjRender_SetScaleXYZ(obj,size,size,size);
	ObjRender_SetAngleXYZ(obj,0,0,angle);
	ObjRender_SetAlpha(obj,alpha);
	alpha -= minus;
	angle += size*1.5;
	r+= spd;
	spd -= 0.02;
	size -= 0.01;
	yield;
	}
	Obj_Delete(obj);
	}

function TCharge01(px,py,size,frame,r,g,b){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"img/charge.png";
	let set = 360/(frame*4);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,128,128);
	ObjSprite2D_SetDestCenter(obj);
	//ObjRender_SetPosition(obj,ObjMove_GetX(boss),ObjMove_GetY(boss),0);
	ObjRender_SetAlpha(obj,0);
	ObjRender_SetScaleXYZ(obj,size,size,0);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	Obj_SetRenderPriorityI(obj,25);
	TAlpha;
	TShrink;
	return obj;
	task TAlpha{
		let l=10;
		let alpha=255/l;
		loop(l){
			ObjRender_SetAlpha(obj,alpha);
			alpha+=255/(l*2);
			yield;
			}
		}
	task TShrink{
		let l=frame;
		let a = size*2/l/l;
		ascent(i in 0..l){
			ObjRender_SetScaleXYZ(obj,size,size,0);
			ObjRender_SetPosition(obj,px,py,0);
			ObjRender_SetColor(obj,r,g,b);
			size = size-i*a;
			if(Obj_IsDeleted(enm)){Obj_Delete(obj);}
			yield;
			}
		Obj_Delete(obj);
	}
}

task IJNFlag{
PlaySoundEffect("se_kira00");
ascent(i in 0..7){Spoke(i*360/7);}
ascent(i in 0..7){Spoke2(i*360/7);}
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, flag);
ObjSprite2D_SetSourceRect(obj, 0, 0, 128, 128);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 30);
let ang=0;
let sca=0;
let a=0;
while(!Obj_IsDeleted(enm)){
if (a<90){a+=3;}
sca=1.25*sin(a);
ObjRender_SetPosition(obj, ObjRender_GetX(enm), ObjRender_GetY(enm), 0);
ang+=5;
ObjRender_SetScaleXYZ(obj, sca+(sca/20)*sin(ang), sca+(sca/20)*sin(ang), 1);
yield;}
Obj_Delete(obj);
}

task Spoke(angle){
loop(30){yield;}
PlaySoundEffect("se_kira00");
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, flag);
ObjSprite2D_SetSourceRect(obj, 128, 0, 256, 256);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 30);
let ang=0;
let sca=0;
let a=0; 
let angle2=0;
while(!Obj_IsDeleted(enm)){
if (a<90){a+=1.5;}
else{ang+=0.5;}
angle2=angle*sin(a);
sca=1*sin(a);
ObjRender_SetPosition(obj, ObjRender_GetX(enm)+sca*128*cos(angle2+ang-90), ObjRender_GetY(enm)+sca*128*sin(angle2+ang-90), 0);
ObjRender_SetAngleXYZ(obj, 0, 0, angle2+ang);
ObjRender_SetScaleXYZ(obj, sca/1.15, sca, 1);

yield;}
Obj_Delete(obj);
}

task Spoke2(angle){
loop(30){yield;}
PlaySoundEffect("se_kira00");
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, flag);
ObjSprite2D_SetSourceRect(obj, 128, 0, 256, 256);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 30);
let ang=0;
let sca=0;
let a=0; 
let angle2=0;
while(!Obj_IsDeleted(enm)){
if (a<90){a+=1.5;}
else{ang+=-0.5;}
angle2=angle*sin(a);
sca=0.75*sin(a);
ObjRender_SetPosition(obj, ObjRender_GetX(enm)+sca*128*cos(angle2+ang-90), ObjRender_GetY(enm)+sca*128*sin(angle2+ang-90), 0);
ObjRender_SetAngleXYZ(obj, 0, 0, angle2+ang);
ObjRender_SetScaleXYZ(obj, sca/1.15, sca, 1);

yield;}
Obj_Delete(obj);
}


task ChargeUp(ID, pos, angular,num,angle,sig,time,color, type){
PlaySoundEffect("se_ch00");
//pos = the position of the center (array) (in case the center is not the enemy)
//"DARK" for the black charge effect
//"LIGHT" for white charge effect
//anything else for neither
	let f = 2;
	let s = 0;
	if(angular<0){s=-0;}
	ascent(i in 0..time){
	let w = i%2*f;
	ascent(j in 0..num){
		Doteff(ID, pos[0], pos[1],angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,color,90-w, BLEND_ADD_ARGB);
		if (type=="DARK"){Doteff(ID,pos[0], pos[1],angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,[255, 255, 255],90-w, BLEND_SUBTRACT);}
		if (type=="LIGHT"){Doteff(ID,pos[0], pos[1],angle+rand(0,sig)+j*360/num,300+i,angular-0.01*time*s,sig,[255, 255, 255],90-w, BLEND_ADD_ARGB);}
		}
	loop(w){yield;}
	}}
	
task Doteff(enm,x,y,ang,r,angular,sig,color,t, blend){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	let img=GetCurrentScriptDirectory~"img/eff_charge.png";
	let v = 0;
	let t2 = t/2;
	let s = rand(1,1.25);
	let acc = ((r-v*(t2/2)))/(t2*t2);
	ObjPrim_SetTexture(obj,img);
	ObjSprite2D_SetSourceRect(obj,0,0,32,32);
	if (blend==BLEND_ADD_ARGB){Obj_SetRenderPriority(obj,0.4);}
	else{Obj_SetRenderPriority(obj,0.41);}
	
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj,blend);
	ObjRender_SetColor(obj,color[0],color[1],color[2]);
	ObjRender_SetScaleXYZ(obj,s,s,0);
	
	Stable;
		loop(t/2){ 
		if(Obj_IsDeleted(enm) || Obj_IsDeleted(obj)){break;}
		r -= v;
		v+= acc;
		ang+=acc*angular*5;
		yield;
		}
		loop(t/2){ 
		if(Obj_IsDeleted(enm) || Obj_IsDeleted(obj)){break;}
		r -= v;
		v-= acc;
		ang+=acc*angular*5;
		yield;
		}
		descent(i in 0..30){
		if(Obj_IsDeleted(enm) || Obj_IsDeleted(obj)){break;}
		ObjRender_SetAlpha(obj,i*8);
		yield;
		}
		Obj_Delete(obj);
		task Stable{
			let ra = rand(-sig,sig)/2;
			let alpha = 0;
			while(!Obj_IsDeleted(obj) && !Obj_IsDeleted(enm)){
			ObjRender_SetAlpha(obj,alpha);
			ObjRender_SetScaleXYZ(obj,s,s,0);
			alpha += 155/t;
			ObjRender_SetPosition(obj,x+r*cos(ang+ra),y+r*sin(ang+ra),0);
			yield;
			}
			Obj_Delete(obj);
			}}
	
////////////////////////////////////////////

let DEBUG = false;
let CutinDifficulty = GetCommonData("rank", "Normal");
let SpellAttack_img = GetCurrentScriptDirectory~"img/SpellAttack.png"; 
let img_SpellAttack = GetCurrentScriptDirectory~"img/SpellAttackText.png"; // Spell Declare
let Alpha_HUD = [255, 255]; //top, bottom

let NAZRIN = "NAZRIN";
let BYAKUREN = "BYAKUREN";
let KANAKO = "KANAKO";
let MOKOU = "MOKOU";
let AYA = "AYA";
let YABUSAME = "LENEN";

let LENEN = "LENEN";

//Script created by gtbot, modified by Sariel

task ObjCutin_SetSpellcardS3(SpellName, R, G, B){
	let r = IntToString(R);
	let g = IntToString(G);
	let b = IntToString(B);
	let boss = enm;
	let spells = Obj_GetValueD(boss, "Spellcards", []);
	spells = spells~[[SpellName, r, g, b, "", ""]];
	Obj_SetValue(boss, "Spellcards", spells);
}

task DrawMedal(SpellName){
loop(180){yield;}
let alpha=0;
		let ran=[ObjPrim_Create(OBJ_SPRITE_2D), ObjPrim_Create(OBJ_SPRITE_2D), ObjPrim_Create(OBJ_SPRITE_2D)];
		ascent(k in 0..3){
		ObjRender_SetPosition(ran[k], 360+k*12+108, 75, 0);
		ObjPrim_SetTexture(ran[k], GetCurrentScriptDirectory~"system/img/medal01.png");
		if (GetAreaCommonData("cutin_History", GetAreaCommonData("cutin_History", "Name", "Noname")~IntToString(k), false)==true){
		ObjSprite2D_SetSourceRect(ran[k], 40-10*(k+2), 0, 40-10*(k+1), 16);
		}
		else{
		ObjSprite2D_SetSourceRect(ran[k], 30, 0, 40, 16);
		}
		ObjSprite2D_SetDestCenter(ran[k]);
		Obj_SetRenderPriorityI(ran[k], 80);
		}
		loop(30){alpha+=255/30; 
		ascent(k in 0..3){ObjRender_SetAlpha(ran[k], alpha);}
		yield;}
		while(!Obj_IsDeleted(ran[0])){
		if(ObjMove_GetY(GetPlayerObjectID)<160){if (alpha>50){alpha-=15;}}else{if (alpha<255){alpha+=15;}}
		ascent(k in 0..3){ObjRender_SetAlpha(ran[k], alpha);}
		yield;}
}

task ObjCutin_SetSpellcardS4(SpellName, image, cuttype, R, G, B){
	let r = IntToString(R);
	let g = IntToString(G);
	let b = IntToString(B);
	let boss = enm;
	let spells = Obj_GetValueD(boss, "Spellcards", []);
	spells = spells~[[SpellName, r, g, b, cuttype, ""]];
	Obj_SetValue(boss, "Spellcards", spells);
}

task ObjCutin_LaunchS3(type, image, difficulty){
	CutinS3(type, image, difficulty);
}

task CutinS3(Type, mimage, difficulty){
	let spells = Obj_GetValueD(enm, "Spellcards", []);
	let boss = enm;
	let spcount = length(spells);
	let IsSpellAttackAnimation = false;
	if(!IsCommonDataAreaExists("cutin_History")){
		CreateCommonDataArea("cutin_History");
	}
	LoadCommonDataAreaA1("cutin_History");


	//if(length(Images)>6)
	//	Images = [Images];
	////	Colors = [Colors];
	//
	//let Colors = [[r, g, b]];

	descent(i in 0..spcount){SpellText(6*i, i);}
	SpawnCutinImage(Type, mimage);
	
	
	let delay = 6;
	while(!Obj_IsDeleted(boss)){
		spells = Obj_GetValueD(enm, "Spellcards", []);
		if(length(spells)!=spcount&&delay==0){
			delay = 6;
			SpellText(0, spcount);
			let newtype = spells[spcount][4];
			if(newtype == ""){newtype = Type;}
			SpawnCutinImage(newtype, spells[spcount][5]);
			spcount++;
		}
		delay = max(delay-1, 0);
		yield;
	}
	
	
	
	task FireCutinA1(x, y, angle, ispeed, itime, mspeed, mtime, img){	
		if(IsSpellAttackAnimation){return;}	
		let SpellCutin = CreateSimple2DImageA1(1, img);
		ObjRender_SetPosition(SpellCutin, x, y, 0);
		ObjRender_SetAlpha(SpellCutin, 0);
		
		
		
		let len = itime;
		ascent(x in 0..len){
			let mod = x/len;
			let locs = [ObjRender_GetX(SpellCutin), ObjRender_GetY(SpellCutin)];
			ObjRender_SetPosition(SpellCutin, floor(locs[0]+ispeed*cos(angle)), floor(locs[1]+ispeed*sin(angle)), 0);
			
			let alph = min(255, 255*(mod*2));
			ObjRender_SetAlpha(SpellCutin, alph);
			yield;
		}
		
		len = mtime;
		let nx = ObjRender_GetX(SpellCutin);
		let ny = ObjRender_GetY(SpellCutin);
		ascent(x in 0..len){
			nx += mspeed*cos(angle);
			ny += mspeed*sin(angle);
			ObjRender_SetPosition(SpellCutin, floor(nx), floor(ny), 0);
			yield;
		}
		//return;
		len = mtime;
		ascent(x in 0..len){
			let mod = x/len;
			let locs = [ObjRender_GetX(SpellCutin), ObjRender_GetY(SpellCutin)];
			ObjRender_SetPosition(SpellCutin, floor(locs[0]+ispeed*cos(angle)), floor(locs[1]+ispeed*sin(angle)), 0);
			yield;
		}
		Obj_Delete(SpellCutin);
	}

	task FireCutinA2(x, y, alpha, img, details){
		if(IsSpellAttackAnimation){return;}
		//[spd, spdinc, ang, anginc, alphachange, time]
		let SpellCutin = CreateSimple2DImageA1(0.9, img);
		ObjRender_SetPosition(SpellCutin, x, y, 0);
		ObjRender_SetAlpha(SpellCutin, alpha);
		
		ascent(i in 0..length(details)){
			let nx = ObjRender_GetX(SpellCutin);
			let ny = ObjRender_GetY(SpellCutin);
			let info = details[i];
			let len = info[5];
			let alphinc = -(alpha-info[4])/len;
			let spdinc = -(info[0]-info[1])/len;
			let mspeed = info[0];
			let cangle = info[2];
			ascent(x in 0..len){
				mspeed+=spdinc;
				cangle+=info[3];
				nx += mspeed*cos(cangle);
				ny += mspeed*sin(cangle);
				ObjRender_SetPosition(SpellCutin, nx, ny, 0);
				yield;
				alpha = min(max(alpha+alphinc, 0), 255);
				ObjRender_SetAlpha(SpellCutin, alpha);
			}
		}
		Obj_Delete(SpellCutin);
	}

	function SpawnCutinImage(type, image){
		//We use another "type" variable (lowercase t) so that
		//spellcards set after the root function is called will play the
		//new set cutin type as opposed to the original one
		// same for image
		if(type == "NAZRIN"){
			FireCutinA2(GetStgFrameWidth+108, GetStgFrameHeight/2-144, 0, image,
			[
				[20.6, 20.6, 158, 0, 255, 20],
				[0.65, 0.65, 158, 0, 255, 90],
				[20.6, 20.6, 158, 0, 255, 20]
			]
			);
			
		}
		else if(type == "KANAKO"){
			FireCutinA2(GetStgFrameWidth+180, GetStgFrameHeight/2-190, 0, image,
			[
				[30, 8, 144, 0, 192, 23],
				[8, 0, 144, 0, 255, 10],
				[0, 2.1, 270, 0, 255, 90],
				[2.1, 2.1, 270, 0, 255, 20],
				[2.1, 1, 270, 0, 0, 20]
			]
			);
			
		}
		else if(type == "BYAKUREN"){
			FireCutinA2(-256, GetStgFrameHeight/2, 0, image,
			[
				[14, 14, 0, 0, 255, 30],
				[0.5, 0.5, 0, 0, 255, 90],
				[14, 14, 0, 0, 0, 30]
			]
			);
			
		}
		else if(type == "LENEN" || type == "YABUSAME"){
			FireCutinA2(GetStgFrameWidth+256, GetStgFrameHeight/2+96, 0, image,
			[
				[32, 1, 182, 0.1, 255, 30],
				[1, 1.25, 180, 14, 255, 10],
				[1.25, 1.75, 315, 0, 255, 80],
				[2, 2.5, 340, -15.75, 192, 10],
				[2.5, 31, 182.5, 0, 0, 20],
			]
			);
			
		}
		else if(type == "AYA"){
			
		}
		else if(type == "MOKOU"){
		}
		else{RaiseError("Not a valid cutin type.");}
	}
	
	task SpellText(delay, num){
		let tspell = spells[num];
		let SpellName = tspell[0];
		let r = atoi(tspell[1]);
		let g = atoi(tspell[2]);
		let b = atoi(tspell[3]);
		
		let Colors = [[r,g,b]];
		
		//These are long-looking common data group names
		let SpellDataAttempt = SpellName~"|"~CutinDifficulty~"|"~GetPlayerID~"|"~"Attempt";
		let SpellDataGet = SpellName~"|"~CutinDifficulty~"|"~GetPlayerID~"|"~"Get";
		//This is actually the common data retrieval
		let SpellValueAttempt = GetAreaCommonData("cutin_History", SpellDataAttempt, 0);
		let SpellValueGet = GetAreaCommonData("cutin_History", SpellDataGet, 0);
		SetAreaCommonData("cutin_History", "Name", SpellName~CutinDifficulty~GetPlayerID);
		SaveCommonDataAreaA1("cutin_History");
		if(!IsReplay&&!DEBUG&&num==0){
			SpellValueAttempt++;
			SetAreaCommonData("cutin_History", SpellDataAttempt, SpellValueAttempt);
			SaveCommonDataAreaA1("cutin_History");
		}
	
		let SpellBG = CreateSimple2DImageA2(0.99, SpellAttack_img, 0, 0, 255, 48);
		ObjSprite2D_SetDestRect(SpellBG, -224, -12, 32, 36);
		ObjRender_SetPosition(SpellBG, GetScreenWidth/2+64+90, 320+40*num, 0);
		ObjRender_SetAlpha(SpellBG, 0);
		ObjRender_SetColor(SpellBG, Colors[0][0], Colors[0][1], Colors[0][2]);
		
		let SpellText = ObjText_Create;
		ObjText_SetText(SpellText,SpellName);
		ObjText_SetFontSize(SpellText,12);
		ObjText_SetFontBold(SpellText, true);
		ObjText_SetFontColorTop(SpellText,255,255,255);
		ObjText_SetFontColorBottom(SpellText,255,255,255);
		ObjText_SetFontBorderType(SpellText,BORDER_FULL);
		ObjText_SetFontBorderColor(SpellText,0,0,0);
		ObjText_SetFontBorderWidth(SpellText,1);
		ObjText_SetHorizontalAlignment(SpellText, ALIGNMENT_RIGHT);
		ObjText_SetMaxWidth(SpellText, GetStgFrameWidth-190);
		Obj_SetRenderPriorityI(SpellText, 100);
		ObjRender_SetPosition(SpellText, 0, 320+40*num, 0);
		ObjRender_SetAlpha(SpellText, 0);
		
		
		let SpellInfo = ObjPrim_Create(OBJ_SPRITE_LIST_2D);
		let bonus = 0;
		let count = GetNumSize(bonus);
		let scount = max(2, GetNumSize(SpellValueAttempt));
		ObjPrim_SetTexture(SpellInfo, SpellAttack_img);
		ObjRender_SetBlendType(SpellInfo, BLEND_ALPHA);
		Obj_SetRenderPriorityI(SpellInfo, 100);
		ObjRender_SetY(SpellInfo, 36);
		ObjRender_SetAlpha(SpellInfo, 0);
		
		//-------------Introduction--------------------------
		
		loop(delay){yield;}
		let len = 30;
		ascent(i in 0..len){
			let mod = i/len;
			let tmod = min(1, ((i*2)/len));
			ObjRender_SetScaleXYZ(SpellBG, 4-3*mod, 4-3*mod, 1);
			ObjRender_SetAlpha(SpellBG, 255*mod);
			ObjRender_SetX(SpellText, (GetStgFrameWidth-24)*(1-mod)+50);
			//ObjRender_SetScaleXYZ(SpellText, 4-3*tmod, 4-3*tmod, 1);
			ObjRender_SetAlpha(SpellText, 255*tmod);
			yield;
		}
		loop(40){yield;}
		let mov = 0;
		
		if(Type == "MOKOU"){SpellcardDeclareMovement([ObjRender_GetY(SpellText), 12+32*num, 0.175, 9]);loop(60){yield;}}
		else{RegularSpellCardDeclare([ObjRender_GetY(SpellText), 50+32*num, 0.135, 12]);}
		//32 is the offset from the top of the screen
		//If using a system where the lifebar is on the boss rather than the top of the screen, 12 is a good value

		
		loop(delay*0.65){yield;}
		
		ascent(i in 0..80){
			let endspeed = 0.5+i/2.5;
			ObjRender_SetX(SpellBG, ObjRender_GetX(SpellBG)+endspeed);
			ObjRender_SetX(SpellText, ObjRender_GetX(SpellText)+endspeed);
			yield;
		}
		
		Obj_Delete(SpellBG);
		Obj_Delete(SpellText);
		
		function SpellcardDeclareMovement(dest){
			ObjRender_SetY(SpellInfo, 24+dest[1]);
			while(dest[0]>dest[1]){
				dest[0] = ObjRender_GetY(SpellText);
				mov = min(mov+dest[2], (dest[0]-dest[1])/dest[3]+0.125);
				ObjRender_SetY(SpellBG, dest[0]-mov);
				ObjRender_SetY(SpellText, dest[0]-mov);
				yield;
			}
		}
		
		function RegularSpellCardDeclare(dest){
			if(num!=0){Obj_Delete(SpellInfo);}
			SpellcardDeclareMovement(dest);
			ascent(i in 0..20){
				ObjRender_SetAlpha(SpellInfo, 255/20*i);
				DrawScoreBonus;
				yield;
			}
			let timerf = ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_ORGTIMERF);
			let startdiff = timerf-(timerf-5*60);
			while(!Obj_IsDeleted(boss)){
				ObjRender_SetAlpha(SpellBG, Alpha_HUD[0]);
				ObjRender_SetAlpha(SpellText, Alpha_HUD[0]);
				ObjRender_SetAlpha(SpellInfo, Alpha_HUD[0]);
				
			//	let modif = min(1, ((ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_TIMERF))/(ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_ORGTIMERF)-startdiff)));
			//	bonus = ((sscore*0.20)+(sscore*((modif)*0.80)));
				DrawScoreBonus;
				yield;
			}
			Obj_Delete(SpellInfo);
			
			if(bonus>=1&&ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_TIMERF)>0){
			//	GotSpellCard(bonus);
			//	AddScore(bonus);
				if(!IsReplay&&!DEBUG&&num==0){
					SpellValueGet++;
					SetAreaCommonData("cutin_History", SpellDataGet, SpellValueGet);
					SaveCommonDataAreaA1("cutin_History");
				}
			}else{
			//	FailedSpellCard;
			}
		}
		sub DrawScoreBonus{
			if(GetPlayerY<128+32*length(spells)){Alpha_HUD[0] = max(Alpha_HUD[0]-10, 85);}else{Alpha_HUD[0] = min(Alpha_HUD[0]+11, 255);}
			
			ObjSpriteList2D_ClearVertexCount(SpellInfo);
				
			ObjSpriteList2D_SetSourceRect(SpellInfo, 0, 48, 128, 60);
			ObjSpriteList2D_SetDestCenter(SpellInfo);
			ObjRender_SetX(SpellInfo, 382-40);
			ObjSpriteList2D_AddVertex(SpellInfo);
			//Bonus Score
			bonus = ObjEnemyBossScene_GetInfo(GetEnemyBossSceneObjectID, INFO_SPELL_SCORE);
			count = GetNumSize(bonus);
			let listNum = DigitToArray(min(99999999, bonus), count);
			let objScene = GetEnemyBossSceneObjectID;
			if(ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SHOOTDOWN_COUNT) +
			ObjEnemyBossScene_GetInfo(objScene, INFO_PLAYER_SPELL_COUNT) == 0){
				SetCommonData("bonus", bonus);
				ascent(iObj in 0 .. count){
				
					let num = listNum[iObj];
					ObjRender_SetX(SpellInfo, 382-4-(8*count) + iObj * 7);
					ObjSpriteList2D_SetSourceRect(SpellInfo, num * 8, 64, (num + 1) * 8, 76);
					ObjSpriteList2D_SetDestCenter(SpellInfo);
					ObjSpriteList2D_AddVertex(SpellInfo);
				}
			}else{
					bonus = 0;
					SetCommonData("bonus", 0);
					ObjRender_SetX(SpellInfo, 382-41);
					ObjSpriteList2D_SetSourceRect(SpellInfo, 144, 48, 176, 60);
					ObjSpriteList2D_SetDestCenter(SpellInfo);
					ObjSpriteList2D_AddVertex(SpellInfo);
			}
			//History
			listNum = DigitToArray(SpellValueGet, scount) ~ [10] ~ DigitToArray(SpellValueAttempt, scount);
				
			ascent(iObj in 0 .. scount*2+1){
				let num = listNum[iObj];
				ObjRender_SetX(SpellInfo, 382+32 + iObj * 8);
				ObjSpriteList2D_SetSourceRect(SpellInfo, num * 8, 64, (num + 1) * 8, 76);
				ObjSpriteList2D_SetDestCenter(SpellInfo);
				ObjSpriteList2D_AddVertex(SpellInfo);
			}
		}
	}
	
	
}

task FadeInA1(obj, ftime){
	ascent(i in 0..ftime){
		ObjRender_SetAlpha(obj, 255/ftime*i);
		yield;
	}
}
task FadeInB1(obj, alpha, ftime){
	ascent(i in 0..ftime){
		ObjRender_SetAlpha(obj, alpha/ftime*i);
		yield;
	}
}

task FadeOutA1(obj, ftime){
	descent(i in 0..ftime){
		ObjRender_SetAlpha(obj, 255/ftime*i);
		yield;
	}
}

task FadeOutB1(obj, initalpha, ftime){
	descent(i in 0..ftime){
		ObjRender_SetAlpha(obj, initalpha/ftime*i);
		yield;
	}
}



function CreateSimple2DImageA1(pri, image){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, pri);
	ObjPrim_SetTexture(obj, image);
	let test = [GetTextureWidth(image), GetTextureHeight(image)];
	ObjSprite2D_SetSourceRect(obj, 0, 0, test[0]-1, test[1]-1);
	ObjSprite2D_SetDestRect(obj, -(test[0]/2+0.5), -(test[1]/2), (test[0]/2), (test[1]/2));
	return obj;
}

function CreateSimple2DImageA2(pri, image, x1, y1, x2, y2){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjRender_SetBlendType(obj, BLEND_ALPHA);
	Obj_SetRenderPriority(obj, pri);
	ObjPrim_SetTexture(obj, image);
	ObjSprite2D_SetSourceRect(obj, x1, y1, x2, y2);
	ObjSprite2D_SetDestCenter(obj);
	return obj;
}



function DigitToArray(digit, count){
	let res = [];
	digit = truncate(digit);

	loop{
		let tnum = truncate(digit % 10);
		digit /= 10;
		res = [tnum] ~ res;
		if(truncate(digit) == 0){break;}
	}

	loop(max(0, count - length(res))){
		res = [0] ~ res;
	}

	return res;
}

function GetNumSize(value){
	if(value<=1){return 1;}
	else{return truncate(log10(value))+1;}
}

task StartSpell(name, img, R, G, B){
PlaySoundEffect("se_cat00");
ObjCutin_SetSpellcardS4(name, "", NAZRIN, 240, 50, 50);
CutinS3(NAZRIN, "", "Normal");
CutInImage(img);
DrawMedal(name);
ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID);
}



task CutInImage(directory){
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, directory);
let sca=1; let rect=[0, 0];
let c=[0, 0, 0];
let v=10; let angle=0; let alpha=0;
if (directory==GetCurrentScriptDirectory~"img/cutin1.png"){rect=[374, 489]; sca=0.85;
c=[0, 255, 0];}
else{rect=[307, 512]; sca=1.09; c=[249, 252, 55];}
ObjRender_SetScaleXYZ(obj, sca, sca, 1);
let x=100; let y=GetScreenHeight/2-30;
ObjSprite2D_SetSourceRect(obj, 0, 0, rect[0], rect[1]);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 70);

MotionBlur;

loop(60){
y+=v/5;
x+=v; ObjRender_SetPosition(obj, x, y, 0);
v-=9/60; angle+=90/60; alpha=255*sin(angle);
ObjRender_SetAlpha(obj, alpha);
yield;}

loop(30){
x+=v; ObjRender_SetPosition(obj, x, y, 0); yield;}

loop(90){
x+=v; ObjRender_SetPosition(obj, x, y, 0);
v+=9/90; angle+=90/60; alpha=255*sin(angle);
ObjRender_SetAlpha(obj, alpha);
yield;}
Obj_Delete(obj);

	task MotionBlur{
	while(!Obj_IsDeleted(obj)){
	Blur(directory, rect[0], rect[1], sca, c[0], c[1], c[2]);
	loop(2){yield;}}
	}
	task Blur(img, x, y, scale, r, g, b){
	let obj2=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj2, img);
	ObjSprite2D_SetSourceRect(obj2, 0, 0, x, y);
	ObjSprite2D_SetDestCenter(obj2);
	let alpha=150;
	ObjRender_SetPosition(obj2, ObjRender_GetX(obj), ObjRender_GetY(obj), 0);
	ObjRender_SetColor(obj2, r, g, b);
	ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
	loop(15){
	scale+=0.01; alpha-=10;
	ObjRender_SetScaleXYZ(obj2, scale, scale, 0);
	ObjRender_SetAlpha(obj2, alpha);
	yield;}
	Obj_Delete(obj2);
	}

}

task CutInImage2(directory){
let obj=ObjPrim_Create(OBJ_SPRITE_2D);
ObjPrim_SetTexture(obj, directory);
let sca=1; let rect=[0, 0];
let c=[0, 0, 0];
let v=10; let angle=0; let alpha=0;
if (directory==GetCurrentScriptDirectory~"img/cutin1.png"){rect=[315, 512]; sca=1;
c=[0, 255, 0];}
else{rect=[315, 512]; sca=1; c=[255, 155, 0];}
ObjRender_SetScaleXYZ(obj, sca, sca, 1);
let x=-80; let y=GetScreenHeight/2+40;
ObjSprite2D_SetSourceRect(obj, 0, 0, rect[0], rect[1]);
ObjSprite2D_SetDestCenter(obj);
Obj_SetRenderPriorityI(obj, 70);

MotionBlur;

loop(60){
y+=v/5;
x+=v; ObjRender_SetPosition(obj, x, y, 0);
v-=9/60; angle+=90/60; alpha=255*sin(angle);
ObjRender_SetAlpha(obj, alpha);
yield;}

loop(30){
x+=v; ObjRender_SetPosition(obj, x, y, 0); yield;}

loop(90){
x+=v; ObjRender_SetPosition(obj, x, y, 0);
v+=9/90; angle+=90/60; alpha=255*sin(angle);
ObjRender_SetAlpha(obj, alpha);
yield;}
Obj_Delete(obj);

	task MotionBlur{
	while(!Obj_IsDeleted(obj)){
	Blur(directory, rect[0], rect[1], sca, c[0], c[1], c[2]);
	loop(2){yield;}}
	}
	task Blur(img, x, y, scale, r, g, b){
	let obj2=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj2, img);
	ObjSprite2D_SetSourceRect(obj2, 0, 0, x, y);
	ObjSprite2D_SetDestCenter(obj2);
	let alpha=150;
	ObjRender_SetPosition(obj2, ObjRender_GetX(obj), ObjRender_GetY(obj), 0);
	ObjRender_SetColor(obj2, r, g, b);
	ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
	loop(15){
	scale+=0.01; alpha-=10;
	ObjRender_SetScaleXYZ(obj2, scale, scale, 0);
	ObjRender_SetAlpha(obj2, alpha);
	yield;}
	Obj_Delete(obj2);
	}

}

task BulletBreak(pos,angle,ImgID,Blend){

	let ID		= ObjPrim_Create(OBJ_SPRITE_2D);
	let animC	= 0;
	let anim1	= 0;
	let anim2	= 0;
	let rectX	= 128;
	let rectY	= 128;
	
	ObjRender_SetPosition(ID, pos[0], pos[1], 0 );
	ObjPrim_SetTexture(ID, GetCurrentScriptDirectory~"/system/img/bulletbreak00.png");
	Obj_SetRenderPriorityI(ID, 40);
	ObjRender_SetBlendType(ID, Blend );
	ObjRender_SetAngleXYZ(ID, 0, 0, rand(0,360) );
	ObjRender_SetAlpha(ID, 192 );
	ObjSprite2D_SetSourceRect(ID, 0 + rectX*anim1, 0 + rectY*anim2, rectX + rectX*anim1, rectY + rectY*anim2 );
	ObjSprite2D_SetDestCenter(ID);
	
	ShotColor(ID, ImgID, Blend );
	
	let sca	= 0.7;
	let pn	= 0;
	if( Blend == BLEND_ADD_ARGB ){
		sca += 0.1;
		ObjRender_SetScaleXYZ(ID, sca, sca, 0 );
	}
	else{
		ObjRender_SetScaleXYZ(ID, sca/1.2, sca/1.2, 0 );
	}
	
	while( anim2 < 2 ){
		ObjSprite2D_SetSourceRect(ID, 0 + rectX*anim1, 0 + rectY*anim2, rectX + rectX*anim1, rectY + rectY*anim2 );
		
		
		animC++;
		if( animC > 0 && animC%3 == 0 ){
			if( anim1 >= 3 ){
				anim1 = 0;
				anim2++;
			}
			anim1++;
		}
		
		yield;
	}
	Obj_Delete(ID);
}



task ShotColor(ID,ImgID,Blend){
let color = GetShotDataInfoA1(ImgID,TARGET_ENEMY,INFO_DELAY_COLOR);
	
	ObjRender_SetColor(ID, color[0], color[1], color[2] );
}



task DelayShot(x, y, sprite, angle, speed, blend, size, delay){
let obj=ObjShot_Create(OBJ_SHOT);
ObjShot_SetSpellResist(obj,true);
ObjShot_SetIntersectionEnable(obj, false);
ObjShot_SetGraphic(obj, sprite); ObjRender_SetBlendType(obj, blend);
ObjShot_Regist(obj);
ObjMove_SetPosition(obj, x, y);
ObjMove_SetAngle(obj, angle); 
ObjMove_SetSpeed(obj, speed);
let s=(size-1)/delay;
let alpha=0;
loop(delay){size-=s; ObjRender_SetScaleXYZ(obj, size, size, 0);
alpha+=255/delay; 
ObjRender_SetColor(obj, alpha, alpha, alpha);
yield;}
Obj_Delete(obj);
}


task StarConcentration(duration, color, ringcolor){
PlaySoundEffect("se_ch00");
let rcolor=[0, 0, 0];
alternative (ringcolor) 
	case("red"){rcolor=[2, 1, 1];}
	case("orange"){rcolor=[2, 1, 0.5];}
	case("yellow"){rcolor=[2, 2, 1];}
	case("green"){rcolor=[1, 2, 1];}
	case("blue"){rcolor=[1, 1, 2];}
	case("cyan"){rcolor=[1, 2, 2];}
	case("purple"){rcolor=[2, 1, 2];}
	case("white"){rcolor=[2, 2, 2];}


let number=round(duration/5); let t=0;
loop(number){
t++; if (t%3==0){ConcentrationRing;}
ascent(angle in 0..5){ConcentrationStar(angle*360/5);}
loop(5){yield;}}
	task ConcentrationRing{
	let circle=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(circle, GetCurrentScriptDirectory~"/img/ring00.png");
	ObjSprite2D_SetSourceRect(circle, 0, 0, 512, 512);
	ObjSprite2D_SetDestCenter(circle);
	let s=1.5; let alpha=0;
	let angle=0; ObjRender_SetBlendType(circle, BLEND_ADD_ARGB);
	loop(45){angle+=90/45; s=1.5*cos(angle); alpha+=6; 
	ObjRender_SetColor(circle, alpha*rcolor[0], alpha*rcolor[1], alpha*rcolor[2]);
	ObjRender_SetScaleXYZ(circle, s, s, 0);
	ObjRender_SetPosition(circle, ObjMove_GetX(enm), ObjMove_GetY(enm), 0);
	yield;}
	}
	task ConcentrationStar(angle){
	let r=300; let r2=100; let x=0; let y=0;
	let obj=ObjShot_Create(OBJ_SHOT); ObjShot_Regist(obj); ObjShot_SetAutoDelete(obj, false);
	ObjShot_SetIntersectionEnable(obj, false);
	ObjShot_SetGraphic(obj, color);
	let size=1.5;
	ObjRender_SetScaleXYZ(obj, size, size, 0);
	ObjRender_SetColor(obj, 155,155,155);
	let a=0;
	loop(40){
	a+=90/40;
	angle+=4;
	r=300*cos(a); r2=100*cos(a);
	x=r*cos(angle); y=+r2*sin(angle);
	ObjMove_SetPosition(obj, ObjMove_GetX(enm)+x+r*cos(angle+40), ObjMove_GetY(enm)+y-r*sin(angle+40));
	yield;}
	Obj_Delete(obj);
	}

}

task SakuraConcentration(duration, color){


PlaySoundEffect("se_ch00");
let rcolor=[0, 0, 0];
alternative (color) 
	case("red"){rcolor=[255, 50, 50];}
	case("orange"){rcolor=[255, 100, 50];}
	case("yellow"){rcolor=[255, 255, 50];}
	case("green"){rcolor=[50, 255, 50];}
	case("blue"){rcolor=[50, 50, 255];}
	case("cyan"){rcolor=[50, 255, 255];}
	case("purple"){rcolor=[255, 50, 255];}
	case("white"){rcolor=[255, 255, 255];}
	
ConcentrationRing;
loop(25){
loop(3){Sakura(rand(150,250), rand(1, 1.5), rand(0,360));}
yield; yield;}
task Sakura(radius, size, angle2){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"/system/img/cherry.png");
	ObjSprite2D_SetSourceRect(obj, 0, 0, 256, 256);
	ObjSprite2D_SetDestCenter(obj);
	let s=size; 
	let r=radius;
	let alpha=0;
	let a=0;
	let angle=rand(0,360); 
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	loop(60){
	ObjRender_SetPosition(obj, ObjMove_GetX(enm)+r*cos(angle2), ObjMove_GetY(enm)+r*sin(angle2), 0);
	a+=1.5;
	r=radius*cos(a);
	if (alpha<240){alpha+=6;}
	s-=size/60; ObjRender_SetScaleXYZ(obj, s, s, s);
	ObjRender_SetAlpha(obj, alpha);
	angle+=1;
	ObjRender_SetAngleXYZ(obj, angle, angle, angle);
	yield;}
	Obj_Delete(obj);
}

task ConcentrationRing{
	let circle=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(circle, GetCurrentScriptDirectory~"/img/ring00.png");
	ObjSprite2D_SetSourceRect(circle, 0, 0, 512, 512);
	ObjSprite2D_SetDestCenter(circle);
	let s=1.5; let alpha=0;
	let angle=0; ObjRender_SetBlendType(circle, BLEND_ADD_ARGB);
	loop(duration){angle+=90/duration; s=1.5*cos(angle); 
	alpha+=6; if (alpha>240){alpha=240;} 
	ObjRender_SetAlpha(circle, alpha);
	ObjRender_SetColor(circle, rcolor[0], rcolor[1], rcolor[2]);
	ObjRender_SetScaleXYZ(circle, s, s, 0);
	ObjRender_SetPosition(circle, ObjMove_GetX(enm), ObjMove_GetY(enm), 0);
	yield;}
	Obj_Delete(circle);
	}
}


task ExplosionA2(id, color){


PlaySoundEffect("len_se02");
let rcolor=[0, 0, 0];
alternative (color) 
	case("red"){rcolor=[255, 50, 50];}
	case("orange"){rcolor=[255, 100, 50];}
	case("yellow"){rcolor=[255, 255, 50];}
	case("green"){rcolor=[50, 255, 50];}
	case("blue"){rcolor=[50, 50, 255];}
	case("cyan"){rcolor=[50, 255, 255];}
	case("purple"){rcolor=[255, 50, 255];}
	case("white"){rcolor=[255, 255, 255];}
	
ConcentrationRing;
loop(40){
Sakura(rand(100,300), rand(1, 1.5), rand(0,360));
}
task Sakura(radius, size, angle2){
	let obj=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, GetCurrentScriptDirectory~"/system/img/cherry.png");
	ObjSprite2D_SetSourceRect(obj, 0, 0, 256, 256);
	ObjSprite2D_SetDestCenter(obj);
	let s=0; 
	let r=radius;
	let alpha=240;
	let a=-90;
	let angle=rand(0,360); 
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	loop(50){
	ObjRender_SetPosition(obj, ObjRender_GetX(id)+r*cos(angle2), ObjRender_GetY(id)+r*sin(angle2), 0);
	a+=9/5;
	r=radius*cos(a);
	if (alpha>0){alpha-=6;}
	s+=size/60; ObjRender_SetScaleXYZ(obj, s, s, s);
	ObjRender_SetAlpha(obj, alpha);
	angle+=1;
	ObjRender_SetAngleXYZ(obj, angle, angle, angle);
	yield;}
	Obj_Delete(obj);
}

task ConcentrationRing{
	let circle=ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(circle, GetCurrentScriptDirectory~"/img/ring00.png");
	ObjSprite2D_SetSourceRect(circle, 0, 0, 512, 512);
	ObjSprite2D_SetDestCenter(circle);
	let s=1.5; let alpha=180;
	let angle=-90; ObjRender_SetBlendType(circle, BLEND_ADD_ARGB);
	loop(30){angle+=3; s=1.5*cos(angle); 
	alpha-=6;
	ObjRender_SetAlpha(circle, alpha);
	ObjRender_SetColor(circle, rcolor[0], rcolor[1], rcolor[2]);
	ObjRender_SetScaleXYZ(circle, s, s, 0);
	ObjRender_SetPosition(circle, ObjRender_GetX(id), ObjRender_GetY(id), 0);
	yield;}
	Obj_Delete(circle);
	}
}



task FEffect(x, y, x2, y2, angle, angle2, time, graphic){
				let vx=(x2-x)/time;
				let vy=(y2-y)/time;
				let r=0;
				let a=0;
					loop(time){
					angle+=2; angle2+=2;
					x+=vx; y+=vy;
					a+=360/time; r=120-120*cos(a);
					ShrinkShot(x+r*cos(angle), y+r*sin(angle2),graphic, 1);
					yield;
					}
				}
				
task FEffect2(x, y, x2, y2, angle, angle2, time, graphic,color){
	let vx=(x2-x)/time;
	let vy=(y2-y)/time;
	let r=0;
	let a=0;
	loop(time){
	angle+=2; angle2+=2;
	x+=vx; y+=vy;
	a+=360/time; r=120-120*cos(a);
	ShrinkShot(x+r*cos(angle), y+r*sin(angle2),graphic,color);
	yield;
	}
	}
				
				
task ShrinkShot(x, y, graphic,color){
	let obj=ObjShot_Create(OBJ_SHOT);
	ObjShot_Regist(obj);
	let sca=1;
	ObjShot_SetIntersectionEnable(obj, false);
	ObjShot_SetSpellResist(obj,true);
	ObjShot_SetGraphic(obj, graphic);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);
	if(color=="BLUE"){ObjRender_SetColor(obj,155,155,255);}
	if(color=="GREEN"){ObjRender_SetColor(obj, 155, 255, 155);}
	if(color=="RED"){ObjRender_SetColor(obj, 255, 155, 155);}
	if(color=="PURPLE"){ObjRender_SetColor(obj, 255, 155, 255);}
	ObjRender_SetAlpha(obj, 200);
	ObjMove_SetPosition(obj, x, y);
	loop(15){
	sca-=1/15;
	ObjRender_SetScaleXYZ(obj, sca, sca, 1);
	yield;}
	Obj_Delete(obj);
	}
				
				
///////////////Charge effect taken from WNSP
	task EffectChargeSetA(objTarget, eff_color, timer)
{
	
	EffectConcentrationA(objTarget, eff_color, timer);
	loop(timer){yield;}
	if (Obj_IsDeleted(objTarget)) { return; }
	EffectExplode(objTarget, eff_color);
}
//集中＋波紋エフェクト
task EffectChargeSetB(objTarget, eff_color, timer)
{
	
	EffectConcentrationA(objTarget, eff_color, timer);
	loop(timer){yield;}
	if (Obj_IsDeleted(objTarget)) { return; }
	
}

//集中エフェクト（渦巻き）
task EffectConcentrationA(objTarget, eff_color, timer)
{
PlaySoundEffect("se_ch00");
	let size = 450;
	let add_a = 1;
	_EffectConcentration(objTarget, eff_color , 0, -add_a, size, timer);
	_EffectConcentration(objTarget, eff_color , 180, add_a, size, timer);
}
task EffectConcentrationB(objTarget, eff_color, timer)
{
	let size = 450;
	let add_a = -0.75;
	_EffectConcentration(objTarget, eff_color , 225, add_a, size, timer);
	_EffectConcentration(objTarget, eff_color , 225+90, -add_a, size, timer);
}

//----------------------------------------
// 集中エフェクト（渦巻き）
//----------------------------------------
task _EffectConcentration(objTarget, c_index, base_angle, add_angle, size, timer)
{
	let t = max(timer/2, timer-60);
	let timer2 = 90;
	if (t < 60) { timer2 = t+30; }
	loop(t)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		_EffectConcentrationP(objTarget, c_index, base_angle+rand(-15,15), add_angle, size, timer2);
		yield;
	}
}
// エフェクト単品
task _EffectConcentrationP(objTarget, c_index, base_angle, add_angle, size, timer)
{
	//初期設定
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj, priority);
	ObjPrim_SetTexture(obj, imgEffectPower);
	ObjSprite2D_SetSourceRect(obj, c_index*32, 32, (c_index+1)*32, 64);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj, BLEND_SUBTRACT);

	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj2, priority-1);
	ObjPrim_SetTexture(obj2, imgEffectPower);
	ObjSprite2D_SetSourceRect(obj2, c_index*32, 0, (c_index+1)*32, 32);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetBlendType(obj2, BLEND_ADD_ARGB);
	
	let tmp_scale = 2; let add_scale = 2/timer;
	let tmp_alpha = 0; let add_alpha = 80/timer; let add_alpha2 = -80/15;
	let r = size; let add_r = -size/timer;
	let az = rand(0,360); let add_az = rand(-10,10);
	
	loop(timer)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		let ix = ObjMove_GetX(objTarget) + r*cos(base_angle*5);
		let iy = ObjMove_GetY(objTarget) + r*sin(base_angle*6);
		ObjRender_SetAngleZ(obj, az);
		ObjRender_SetPosition(obj, ix, iy, 0);
		ObjRender_SetScaleXYZ(obj, tmp_scale, tmp_scale, 1);
		ObjRender_SetAlpha(obj, tmp_alpha);

		ObjRender_SetAngleZ(obj2, az);
		ObjRender_SetPosition(obj2, ix, iy, 0);
		ObjRender_SetScaleXYZ(obj2, tmp_scale, tmp_scale, 1);
		ObjRender_SetAlpha(obj2, tmp_alpha/2);
		az += add_az; base_angle += add_angle;
		tmp_scale += add_scale; tmp_alpha += add_alpha; r += add_r;
		yield;
	}
	loop(15)
	{
		ObjRender_SetAngleZ(obj, az);
		ObjRender_SetAlpha(obj, tmp_alpha);

		ObjRender_SetAngleZ(obj2, az);
		ObjRender_SetAlpha(obj2, tmp_alpha);
		az += add_az; tmp_alpha += add_alpha2;
		yield;
	}
	Obj_Delete(obj);
	Obj_Delete(obj2);
}

task EffectExplode(objTarget, eff_color)
{

	let timer = 45;
	let size = 10;
	loop(15)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		loop(8)
		{
			let tmp = rand(0.2, 1);
			_EffectExplodeP(objTarget, eff_color, rand(0,360), tmp*size, timer*(1+tmp), BLEND_ADD_ARGB);
		}
		yield;
	}
}
task EffectExplodeInv(objTarget, eff_color)
{

	let timer = 45;
	let size = 10;
	loop(15)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		loop(8)
		{
			let tmp = rand(0.2, 1);
			_EffectExplodeP(objTarget, eff_color, rand(0,360), tmp*size, timer*(1+tmp), BLEND_SUBTRACT);
		}
		yield;
	}
}
// エフェクト単品
task _EffectExplodeP(objTarget, c_index, base_angle, size, timer, blend_type)
{
	//初期設定
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(obj, priority);
	ObjPrim_SetTexture(obj, imgEffectPower);
	ObjSprite2D_SetSourceRect(obj, c_index*32, 0, (c_index+1)*32, 32);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetBlendType(obj, blend_type);
	
	let vx = cos(base_angle)*size; let vy = sin(base_angle)*size;
	let tmp_scale = size/2 + 4; let add_scale = 2/timer;
	let tmp_alpha = 48; let add_alpha = -48/(timer+10);
	let az = rand(0,360); let add_az = rand(-10,10);
	let ix = ObjMove_GetX(objTarget); let iy = ObjMove_GetY(objTarget);
	
	ObjRender_SetPosition(obj, ix, iy, 0);
	loop(1)
	{
		ObjRender_SetAngleZ(obj, az);
		ObjRender_SetScaleXYZ(obj, tmp_scale, tmp_scale, 1);
		ObjRender_SetAlpha(obj, tmp_alpha);
		az += add_az; tmp_scale -= 4;
		yield;
	}
	descent(i in 0 .. timer)
	{
		ObjRender_SetAngleZ(obj, az);
		ObjRender_SetPosition(obj, ix, iy, 0);
		ObjRender_SetScaleXYZ(obj, tmp_scale, tmp_scale, 1);
		ObjRender_SetAlpha(obj, tmp_alpha);
		az += add_az;
		tmp_scale += add_scale; tmp_alpha += add_alpha;
		ix += vx * i/timer; iy += vy * i/timer;
		yield;
	}
	loop(10)
	{
		ObjRender_SetAngleZ(obj, az);
		ObjRender_SetScaleXYZ(obj, tmp_scale, tmp_scale, 1);
		ObjRender_SetAlpha(obj, tmp_alpha);
		az += add_az;
		tmp_scale += add_scale; tmp_alpha += add_alpha;
		yield;
	}
	Obj_Delete(obj);
}

///////////////Shiragiku's alphabet charge effect taken from WNSP
task EffectWaveRinne(objTarget, timer)
{
	
	let size = 256;
	let t = max(timer/2, timer-60);
	let timer2 = 60;
	if (t < 60) { timer2 = t+30; }
	ascent(i in 0 .. t)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		let r = (i/t*0.75 + 0.25) * size;
		let sc = 1 + i/t*1.5;
		loop(2)
		{
			_EffectWaveRinne(ObjMove_GetX(objTarget)+rand(-r,r), ObjMove_GetY(objTarget)+rand(-r,r),
				rand(-2, 2), rand(-2, 2), sc, timer2);
		}
		yield;
	}
}
// エフェクト単品
task _EffectWaveRinne(x, y, vx, vy, scale, timer)
{
	//初期設定
	let obj = CreateParticleString([x, y], scale);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);

	let alpha = 0;
	ascent(t in 0 .. timer)
	{
		let tmp = cos((t+1)/timer*90);
		ObjRender_SetPosition(obj, x, y, 0);
		ObjRender_SetAlpha(obj, alpha*tmp);
		ObjRender_SetScaleXYZ(obj, (1+tmp)/4, (1+tmp)/4, 1);
		if (t < 15)
		{
			alpha += 48/15;
		}
		x += vx; y += vy;
		yield;
	}
	Obj_Delete(obj);
}


function CreateParticleString(pos, scale)
{
	let eff_type = trunc(rand(0, 23));
	let ix = (eff_type%8) * 128;
	let iy = trunc(eff_type/8) * 128;
	let iw = 128;
	let ih = 128;
	let obj = ObjPrim_Create(OBJ_PRIMITIVE_2D);
	Obj_SetRenderPriorityI(obj, priority);
	ObjPrim_SetTexture(obj, imgEffectString);
	ObjRender_SetPosition(obj, pos[0], pos[1], 0);
	SetVeterex2D(obj, ix, iy, iw, ih, scale);
	return(obj);
}

function SetVeterex2D(obj, x, y, w, h, scale)
{
	ObjPrim_SetPrimitiveType(obj, PRIMITIVE_TRIANGLESTRIP);
	ObjPrim_SetVertexCount(obj, 4);

	ObjPrim_SetVertexUVT(obj, 0, x, y);
	ObjPrim_SetVertexUVT(obj, 1, x, y+h);
	ObjPrim_SetVertexUVT(obj, 2, x+w, y);
	ObjPrim_SetVertexUVT(obj, 3, x+w, y+h);

	ObjPrim_SetVertexPosition(obj, 0, -w*scale/2, -h*scale/2, 0);
	ObjPrim_SetVertexPosition(obj, 1, -w*scale/2,  h*scale/2, 0);
	ObjPrim_SetVertexPosition(obj, 2,  w*scale/2, -h*scale/2, 0);
	ObjPrim_SetVertexPosition(obj, 3,  w*scale/2,  h*scale/2, 0);
}


task EffectConcentrationStringXY(objTarget, size, timer)
{
	
	let t = max(timer/2, timer-60);
	let timer2 = 90;
	if (t < 60) { timer2 = t+30; }
	loop(t/2)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		_EffectConcentrationStringXYP(objTarget, rand(0,360), rand(0.75, 2), size/2, timer2);
		loop(2){yield;}
	}
}
task EffectConcentrationStringXY2(objTarget, size, timer)
{
	
	let t = max(timer/2, timer-60);
	let timer2 = 90;
	if (t < 60) { timer2 = t+30; }
	loop(t/3)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		_EffectConcentrationStringXYP(objTarget, rand(0,360), rand(0.75, 2)/4, size/4, timer2);
		loop(3){yield;}
	}
}
// エフェクト単品
task _EffectConcentrationStringXYP(objTarget, base_angle, scale, size, timer)
{
	//初期設定
	let obj = CreateParticleString([ObjMove_GetX(objTarget), ObjMove_GetY(objTarget)], scale);
	ObjRender_SetBlendType(obj, BLEND_ADD_ARGB);

	let vx = cos(base_angle);
	let vy = sin(base_angle);
	let alpha = 96;
	
	ascent(t in 0 .. timer)
	{
		if (Obj_IsDeleted(objTarget)) { break; }
		let tmp = cos((t+1)/timer*90);
		let ix = ObjMove_GetX(objTarget) + tmp*size*vx;
		let iy = ObjMove_GetY(objTarget) + tmp*size*vy;
		ObjRender_SetPosition(obj, ix, iy, 0);
		ObjRender_SetAlpha(obj, alpha*(1-tmp));
		ObjRender_SetScaleXYZ(obj, (1+tmp)/4, (1+tmp)/4, 1);
		if (t > timer-5)
		{
			alpha -= 96/5;
		}
		yield;
	}
	Obj_Delete(obj);
}

let Name1 = GetCurrentScriptDirectory ~"./img/stage_title_0_0.png";
let Name2 = GetCurrentScriptDirectory ~"./img/stage_title_0_1.png";

task NameShow(text,R,G,B,delay)
{
	loop(delay){yield;}
	let objBackFrame=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objBackFrame,85);
	ObjPrim_SetTexture(objBackFrame,Name1);
	ObjSprite2D_SetSourceRect(objBackFrame,0,0,181,25);
	ObjSprite2D_SetDestCenter(objBackFrame);
	ObjRender_SetScaleXYZ(objBackFrame,1,1,1);
	ObjRender_SetAngleZ(objBackFrame,-30);
	ObjRender_SetScaleXYZ(objBackFrame,5,5,5);
	ObjRender_SetColor(objBackFrame,R,G,B);
	
	let objFrontFrame=ObjPrim_Create(OBJ_SPRITE_2D);
	Obj_SetRenderPriorityI(objFrontFrame,85);
	ObjPrim_SetTexture(objFrontFrame,Name2);
	ObjSprite2D_SetSourceRect(objFrontFrame,0,0,230,30);
	ObjSprite2D_SetDestCenter(objFrontFrame);
	ObjRender_SetScaleXYZ(objFrontFrame,1.5,1.5,1);
	ObjRender_SetColor(objFrontFrame,R,G,B);
	
	let objText = ObjText_Create();
    ObjText_SetText(objText, text);
	Obj_SetRenderPriorityI(objText,85);
	ObjText_SetFontSize(objText, 40);
	ObjText_SetFontType(objText, "Times New Roman");
	ObjText_SetFontBold(objText, false);
    ObjText_SetFontColorTop(objText, 255, 255, 255);
    ObjText_SetFontColorBottom(objText, 255, 255, 255);
    ObjText_SetFontBorderType(objText, BORDER_NONE);
    ObjText_SetFontBorderColor(objText, 0, 0, 0);
    ObjText_SetFontBorderWidth(objText, 2);
	ObjRender_SetAlpha(objText,0);
	ObjRender_SetScaleXYZ(objFrontFrame,ObjText_GetTotalWidth(objText)/230+0.75,ObjText_GetTotalHeight(objText)/30+0.25,1);
	
	let Alpha = 0;
	let XX = 0-230*2;
	let Distance = 500;
	loop(30)
	{
		ObjRender_SetPosition(objBackFrame,GetStgFrameWidth/2+Distance*cos(150),GetStgFrameHeight/2+Distance*sin(150),0);
		Distance-=430/30;
		ObjRender_SetPosition(objFrontFrame,XX,GetStgFrameHeight/2,0);
		ObjRender_SetPosition(objText,ObjRender_GetX(objFrontFrame)-(ObjText_GetTotalWidth(objText)/2),ObjRender_GetY(objFrontFrame)-(ObjText_GetTotalHeight(objText)/2),0);
		XX+=(GetStgFrameWidth+70)/30;
		yield;
	}
	loop(60)
	{
		ObjRender_SetAlpha(objText,Alpha);
		Alpha+=255/10;
		ObjRender_SetPosition(objBackFrame,GetStgFrameWidth/2+Distance*cos(150),GetStgFrameHeight/2+Distance*sin(150),0);
		Distance-=1;
		ObjRender_SetPosition(objFrontFrame,XX,GetStgFrameHeight/2,0);
		ObjRender_SetPosition(objText,ObjRender_GetX(objFrontFrame)-(ObjText_GetTotalWidth(objText)/2),ObjRender_GetY(objFrontFrame)-(ObjText_GetTotalHeight(objText)/2),0);
		XX+=1;
		yield;
	}
	Alpha =255;
	loop(30)
	{
		ObjRender_SetAlpha(objText,Alpha);
		Alpha-=(255)/10;
		ObjRender_SetPosition(objBackFrame,GetStgFrameWidth/2+Distance*cos(150),GetStgFrameHeight/2+Distance*sin(150),0);
		Distance-=60;
		ObjRender_SetPosition(objFrontFrame,XX,GetStgFrameHeight/2,0);
		ObjRender_SetPosition(objText,ObjRender_GetX(objFrontFrame)-(ObjText_GetTotalWidth(objText)/2),ObjRender_GetY(objFrontFrame)-(ObjText_GetTotalHeight(objText)/2),0);
		XX+=(GetStgFrameWidth+30)/30;
		yield;
	}
	Obj_Delete(objBackFrame);
	Obj_Delete(objFrontFrame);
	Obj_Delete(objText);
}
