
task SpellBG(tobj, graphic){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, graphic);
	Obj_SetRenderPriorityI(obj,22);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj,230);
	ObjSprite2D_SetSourceRect(obj,0,0,453, 279);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj, 2.2, 2.2, NULL);
	ObjRender_SetColor(obj, 104, 104, 250);
	
	SpinBG;
	
	task SpinBG {
		let spin = 5;
		let spin1 = 130;
		let allow=0;
	
			
		while(!Obj_IsDeleted(tobj)){
		
			ObjRender_SetAngleXYZ(obj, 0, 0, 45);
		
			ObjSprite2D_SetSourceRect(obj,spin,0,453+spin,279);
			
			spin+=1.2;
			
			yield;
			}
			
		Obj_Delete(obj);
		}
	}
	
task KonnBG(tobj, graphic, graphic1, scrollspeedX, scrollspeedY, sourceX, sourceY, sourceX1, sourceY1, scale, scale1){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, graphic);
	Obj_SetRenderPriorityI(obj,21);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj,120);
	ObjSprite2D_SetSourceRect(obj,0,0,sourceX, sourceY);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj, scale, scale, NULL);
	ObjRender_SetColor(obj, 104, 104, 200);
	
	let obj1 = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj1, graphic1);
	Obj_SetRenderPriorityI(obj1,23);
	ObjRender_SetBlendType(obj1,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj1,250);
	ObjSprite2D_SetSourceRect(obj1,0,0,sourceX1, sourceY1);
	ObjSprite2D_SetDestCenter(obj1);
	ObjRender_SetPosition(obj1,GetStgFrameWidth/2,GetStgFrameHeight/2,0);
	ObjRender_SetScaleXYZ(obj1, scale1, scale1, NULL);
	//ObjRender_SetColor(obj1, 104, 104, 250);
	
	SpinBG;
	
	task SpinBG {
		let spin = 0;
		let spin1 = 0;
		let allow=0;
		let ALPHA = 200;
	
			
		while(!Obj_IsDeleted(tobj)){
		
			ObjRender_SetAngleXYZ(obj1, 0, 0, 90);
		
			//ObjSprite2D_SetSourceRect(obj,spin,0,sourceX*4+spin,sourceY*3+spin1);
			ObjSprite2D_SetSourceRect(obj1,spin,0,sourceX1*4+spin,sourceY1*3+spin1);
			
			spin+=scrollspeedX;
			spin1+=scrollspeedY;
			
			ObjRender_SetAlpha(obj, ALPHA);
			
			if(ALPHA >=255){
				allow=0;
				}
				
			if(ALPHA<=120){
				allow=1;
				}
				
			if(allow==0){
				ALPHA-=0.2;
				}
			if(allow==1){
				ALPHA+=10.5;
				}
				
			yield;
			}
			
		Obj_Delete(obj);
		Obj_Delete(obj1);
		}
	}
	
task SetSpecialDelete(tobj, graphic){
	let endX = ObjMove_GetX(tobj);
	let endY = ObjMove_GetY(tobj);
	while(!Obj_IsDeleted(tobj)){
		endY = ObjMove_GetY(tobj);
		endX = ObjMove_GetX(tobj);
		yield;
		}
	let obj = CreateShotA1(endX, endY, 0, 0, graphic, 20);
	ObjShot_SetDeleteFrame(obj, 0);
	}
	
task death(tobj) {

	Obj_Delete(tobj);
	
	DeleteShotAll(TYPE_ALL, TYPE_ITEM);
	
	loop(100){	
		DeleteShotAll(TYPE_CHILD, TYPE_IMMEDIATE);
		
		yield;
		}
		
	Obj_Delete(tobj);
		
	CloseScript(GetOwnScriptID());
	
	return;
	
	}
	
task MCircle(tobj, graphic){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj, graphic);
	Obj_SetRenderPriorityI(obj,23);
	ObjRender_SetBlendType(obj,BLEND_ADD_ARGB);
	ObjRender_SetAlpha(obj,130);
	ObjSprite2D_SetSourceRect(obj,0,0,256, 256);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetPosition(obj,ObjMove_GetX(tobj),ObjMove_GetY(tobj),0);
	ObjRender_SetScaleXYZ(obj, 1, 1, NULL);
	let rotate=0;
	let scale = 1;
	let allow=0;
	
	while(!Obj_IsDeleted(tobj)){
		ObjRender_SetPosition(obj,ObjMove_GetX(tobj),ObjMove_GetY(tobj),0);
		ObjRender_SetAngleXYZ(obj, 0, 0, rotate);
		ObjRender_SetScaleXYZ(obj, scale, scale, 1.5);
		
		if(allow==1){
			scale-=0.004;
			}
		if(allow==0){
			scale+=0.004;
			}
		if(scale>1.2){
			allow=1;
			}
		if(scale<0.6){
			allow=0;
			}
			
		rotate+=0.1;
			
		yield;
		}
		
	Obj_Delete(obj);
	}
		
	
	