#include".\selibrary.txt"

task Gap(posX,posY,scale,angle,opentime,staytime,closetime,priority){
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj1, GetCurrentScriptDirectory~"./img/gap.png");
	ObjSprite2D_SetSourceRect(obj1, 0, 0, 64, 134);
	ObjRender_SetScaleXYZ(obj1,scale,scale,0);
	ObjRender_SetAngleZ(obj1,angle);
	Obj_SetRenderPriorityI(obj1,priority);
	ObjSprite2D_SetDestCenter(obj1);
	ObjRender_SetPosition(obj1,posX,posY,0);
	ObjRender_SetBlendType(obj1,BLEND_ALPHA);
	
	let angleY = 90;
	loop(opentime){
		angleY-=90/opentime;
		ObjRender_SetAngleY(obj1,angleY);
	yield;}
	loop(staytime){yield;}
	loop(opentime){
		angleY+=90/opentime;
		ObjRender_SetAngleY(obj1,angleY);
	yield;}
	Obj_Delete(obj1);
}

task YukariCutin(targ,name){
	SetCommonData("SpellCard",true);	
	SE_Play(compositespell,100);
	
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	let scaleX = 0;	
	let posY1 = GetScreenHeight;
	let alpha = 255;
	ObjPrim_SetTexture(obj1, GetCurrentScriptDirectory~"./img/yukaricutin.png");
	ObjSprite2D_SetSourceRect(obj1, 0, 0, 395, 508);
	ObjRender_SetScaleXYZ(obj1,scaleX,1,0);
	Obj_SetRenderPriorityI(obj1,78);
	ObjSprite2D_SetDestCenter(obj1);
	ObjRender_SetPosition(obj1,GetStgFrameWidth/2,posY1,0);
	ObjRender_SetBlendType(obj1,BLEND_ALPHA);
	
	let posX2 = (GetStgFrameWidth-120)+300;
	let posY2 = 20;
	let obj2 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj2, GetCurrentScriptDirectory~"./img/spellnamebg.png");
	ObjSprite2D_SetSourceRect(obj2, 0, 0, 255, 34);
	ObjRender_SetScaleXYZ(obj2,1,1,0);
	Obj_SetRenderPriorityI(obj2,76);
	ObjSprite2D_SetDestCenter(obj2);
	ObjRender_SetPosition(obj2,posX2,posY2,0);
	ObjRender_SetBlendType(obj2,BLEND_ALPHA);
	
	let objText = ObjText_Create();
	Obj_SetRenderPriorityI(objText, 77);
	ObjText_SetFontType(objText, "Determination Sans");
	ObjText_SetFontSize(objText, 20);
	ObjText_SetFontBorderType(objText, BORDER_FULL);
	ObjText_SetFontBorderWidth(objText,2);
	ObjText_SetFontBorderColor(objText,0,0,0);
	ObjText_SetFontColorTop(objText, 255,0,255);
	ObjText_SetFontColorBottom(objText, 255,255,255);
	ObjText_SetHorizontalAlignment(objText,ALIGNMENT_RIGHT);
	ObjText_SetMaxWidth(objText, 500);	
	ObjText_SetText(objText, name);
	
	let count = 0;
	loop(15){
	count++;
	scaleX+=1/15;
	posY1-=3;
	ObjRender_SetScaleX(obj1,scaleX);
	ObjRender_SetY(obj1,posY1);
	
	posX2-=300/45;
	ObjRender_SetX(obj2,posX2);
	ObjRender_SetPosition(objText,ObjRender_GetX(obj2)-382,ObjRender_GetY(obj2)-12,0);
	yield;}
	
	loop(60){
	count++;
	if(count<=45){posX2-=300/45;}
	ObjRender_SetX(obj2,posX2);
	
	posY1-=3;
	ObjRender_SetY(obj1,posY1);
	ObjRender_SetPosition(objText,ObjRender_GetX(obj2)-382,ObjRender_GetY(obj2)-12,0);
	yield;}
	
	loop(30){
	alpha-=255/30;
	posY1-=3;
	ObjRender_SetY(obj1,posY1);
	ObjRender_SetAlpha(obj1,alpha);
	yield;}
	
	Obj_Delete(obj1);
	
	alpha = 255;
	while(!Obj_IsDeleted(targ)){
		if(GetPlayerY<=60){
			if(alpha>50){alpha-=12;}
		}
		else{
			if(alpha<255){alpha+=12;}
		}
		ObjRender_SetAlpha(obj2,alpha);
		ObjRender_SetAlpha(objText,alpha);
	yield;}
	
	Obj_Delete(obj2);
	Obj_Delete(objText);
	SetCommonData("SpellCard",false);
}

task AfterImage(tobj,texture,color,scaleinc,time,x1,y1,x2,y2,Yangle){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	let scale = 1.1;
	let alpha = 100;
	let Red = color[0];
	let Green = color[1];
	let Blue = color[2];
	
	ObjPrim_SetTexture(obj, texture);
	ObjSprite2D_SetSourceRect(obj, x1, y1, x2, y2);
	ObjRender_SetScaleXYZ(obj,scale,scale,0);
	Obj_SetRenderPriorityI(obj,26);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,ObjRender_GetX(tobj),ObjRender_GetY(tobj),0);
	ObjRender_SetAlpha(obj,alpha);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetColor(obj,Red,Green,Blue);
	ObjRender_SetAngleY(obj,Yangle);
	
	loop(time){
	scale+=scaleinc/time;
	ObjRender_SetScaleXYZ(obj,scale,scale,0);
	
	alpha-=100/time;
	ObjRender_SetAlpha(obj,alpha);
	yield;}
	Obj_Delete(obj);
}
