task renderSeigaAura(boss){
	let framerate = 40;
	loop{
		let boog = ObjPrim_Create(OBJ_SPRITE_2D);
		renderSeigaT(boog, boss); ObjRender_SetPosition(boog, ObjMove_GetX(boss), ObjMove_GetY(boss), 0);
		ahugh(boog, boss, framerate); 
		
		if(Obj_IsDeleted(boss)){Obj_Delete(boog); break;}
		wait(6);
	}

	task ahugh(obj, tummy, framerate){
		let rate;
		ascent(i in 0..framerate+1){
			rate = Interpolate_Smoother(1, 1.4, i/framerate);
			ObjRender_SetScaleXYZ(obj, 1.1*rate, 1.1*rate, 0);

			rate = Interpolate_Smoother(min(110, ObjRender_GetAlpha(tummy)), 0, i/framerate);
			ObjRender_SetAlpha(obj, rate);
			yield;
		}

		Obj_Delete(obj);
	}
}

task renderSeigaT(obj, main){
	if(Obj_IsDeleted(obj) || Obj_IsDeleted(main)){return;}

	let wi = 64;
	let he = 96;
	let wi_ = 96;
	
	let dir;
	let speed;
	let whichway = 0;
	let frame = 0;
	let idleframe = 0;
	let idleway = 1;
	let moveframe = 0;
	let castframe = 0;
	let spin = 0;

	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./spriteimg/KagerouDDCSprite.png");
	ObjSprite2D_SetSourceRect(obj,0,0,wi,he);
	ObjSprite2D_SetDestCenter(obj);
	ObjRender_SetScaleXYZ(obj,1,1,0); ObjRender_SetColor(obj, 153, 0, 0);
	Obj_SetRenderPriority(obj, Obj_GetRenderPriority(main) - 0.1);

	while(!Obj_IsDeleted(obj)){
		if(Obj_IsDeleted(obj)){break;} if(Obj_IsDeleted(main)){break;}
		
		dir = ObjMove_GetAngle(main);
		speed = ObjMove_GetSpeed(main);

		if(speed == 0 && frame > 0){whichway = -1;}
		else if(speed == 0 && frame < 0){whichway = 1;}
		else if(speed == 0 && frame == 0){whichway = 0;}

		else if(cos(dir) < 0){whichway=-1;}
		else if(cos(dir) > 0){whichway=1;}
		
		if(Obj_GetValueD(main,"cast",0) < 1 && speed == 0 && frame == 0 && castframe == 0){

			castframe = 0;
			
			let re = 7-absolute(floor(idleframe/7)-7);
			re = [0,re][re > 0];
			ObjSprite2D_SetSourceRect(obj,wi*re,0,wi*(re+1),he);
			
			if(idleframe == 40 && idleway == 1){idleway=-1;}
			if(idleframe == 0 && idleway == -1){idleway=1;}
			idleframe+=idleway;
			
		}
		
		else if(speed == 0 && frame == 0){
			
			idleframe=0;
			idleway=1;
			if(castframe >= 0 && castframe < 5){ObjSprite2D_SetSourceRect(obj,0,he*2,wi_,he*3);}
			if(castframe >= 5 && castframe < 10){ObjSprite2D_SetSourceRect(obj,wi_,he*2,wi_*2,he*3);}
			if(castframe >= 10 && castframe < 15){ObjSprite2D_SetSourceRect(obj,wi_*2,he*2,wi_*3,he*3);}
			if(castframe >= 15 && castframe < 20){ObjSprite2D_SetSourceRect(obj,wi_*3,he*2,wi_*4,he*3);}
			if(castframe >= 20 && castframe < 25){ObjSprite2D_SetSourceRect(obj,wi_*4,he*2,wi_*5,he*3);}
			if(castframe >= 25 && castframe < 30){ObjSprite2D_SetSourceRect(obj,0,he*3,wi_,he*4);}
			if(castframe >= 30 && castframe < 35){ObjSprite2D_SetSourceRect(obj,wi_,he*3,wi_*2,he*4);}
			
			if(Obj_GetValueD(main,"cast",0) == 1 && castframe < 35){castframe+=1;}
			else if(Obj_GetValueD(main,"cast",0) == 0 && castframe > 0){
				castframe-=1;
				ObjRender_SetAngleZ(main,0);
			}
			if(Obj_GetValueD(main,"cast",0) == 1 && castframe == 35){
				ObjRender_SetAngleZ(main,spin);
				spin+=15;
			}
			if(castframe < 0){castframe=0;}
		}

		else if(speed != 0 || frame != 0){
			
			//LEFT
			if(frame < 0 && frame >= -5){ObjSprite2D_SetSourceRect(obj,0,he,wi,he*2); ObjRender_SetAngleXYZ(obj,0,0,0);}
			if(frame < -5 && frame >= -10){ObjSprite2D_SetSourceRect(obj,wi,he,wi*2,he*2); ObjRender_SetAngleXYZ(obj,0,0,0);}
			if(frame < -10 && frame >= -15){ObjSprite2D_SetSourceRect(obj,wi*2,he,wi*3,he*2); ObjRender_SetAngleXYZ(obj,0,0,0);}
			
			//RIGHT
			if(frame > 0 && frame <= 5){ObjSprite2D_SetSourceRect(obj,0,he,wi,he*2); ObjRender_SetAngleXYZ(obj,0,180,0);}
			if(frame > 5 && frame <= 10){ObjSprite2D_SetSourceRect(obj,wi,he,wi*2,he*2); ObjRender_SetAngleXYZ(obj,0,180,0);}
			if(frame > 10 && frame <= 15){ObjSprite2D_SetSourceRect(obj,wi*2,he,wi*3,he*2); ObjRender_SetAngleXYZ(obj,0,180,0);}
			
			if(frame == 16 || frame == -16){
				if(moveframe >= 0 && moveframe < 5){ObjSprite2D_SetSourceRect(obj,wi*3,he,wi*4,he*2);}
				else if(moveframe >= 5 && moveframe < 10){ObjSprite2D_SetSourceRect(obj,wi*4,he,wi*5,he*2);}
				else if(moveframe >= 10 && moveframe < 15){ObjSprite2D_SetSourceRect(obj,wi*5,he,wi*6,he*2);}
				if(moveframe == 15){moveframe=0;}
				else{moveframe++;}
			}

			if(speed == 0){moveframe=0;}
			
			idleframe=0;
			castframe=0;
			idleway=1;
			
		}

		ObjSprite2D_SetDestCenter(obj);
		frame=frame+whichway;
		if(frame > 16){frame=16;}
		if(frame < -16){frame=-16;}
		yield;
		
	}
	
}
