task Attack(time){
SetCommonData("BossAttack", true);
wait(time);
SetCommonData("BossAttack", false);
}

task RenderCharacter(tar){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 48;
	let y = 80;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/boss.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	ObjRender_SetAlpha(obj, GetCommonData("BossAlpha", 255));
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 180, GetCommonData("BossAngle", 0));}
	}
	
	if(GetCommonData("BossAttack", false) == true){Obj_SetValue(tar, "State", "Attack");}
	
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2);}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2);}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,y*2,x,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,y*2,x*2,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,y*2,x*3,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*2,x*4,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 32) {aframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task RenderReimu(tar){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 64;
	let y = 82;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/reimu.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjRender_SetScaleXYZ(obj, 1,1,1);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 180, GetCommonData("BossAngle", 0));}
	}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 20)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 19*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 18*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 17*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task RenderMarisa(tar){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 64;
	let y = 78;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/marisa.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjRender_SetScaleXYZ(obj, 1.22,1.22,1);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 180, GetCommonData("BossAngle", 0));}
	}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 20)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 19*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 18*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 17*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task RenderSanae(tar){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 64;
	let y = 64;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/sanae.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjRender_SetScaleXYZ(obj, 1.25,1.25,1.25);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 180, GetCommonData("BossAngle", 0));}
	}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 20)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 19*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 18*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 17*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task RenderNue(tar){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 96;
	let y = 110;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/boss2.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjRender_SetScaleXYZ(obj, 1,1,1);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	ObjRender_SetAlpha(obj, GetCommonData("MidBossAlpha", 255));
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
	}
	
	if(GetCommonData("MidBossAlpha", 255) != 0){
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y); Tail(tar, 7, -10+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, -25, -10+3*sin(bob*3), 0, 180, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20, -10+3*sin(bob*3), 0, 0, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 20)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 19*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 18*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 17*cos(ObjRender_GetAngleY(obj)+180), -10+3*sin(bob*3), 0, ObjRender_GetAngleY(obj)+180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	}
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task RenderKogasa(tar){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 64;
	let y = 96;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/boss3.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjRender_SetScaleXYZ(obj, 1,1,1);
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 180, GetCommonData("BossAngle", 0));}
	}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y); Tail(tar, 7, 0+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y); Tail(tar, 7, 0+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y); Tail(tar, 7, 0+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y); Tail(tar, 7, 0+3*sin(bob*3), 0, 0, 0)}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 20, 0+3*sin(bob*3), 0, 0, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 20, 0+3*sin(bob*3), 0, 0, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 20, 0+3*sin(bob*3), 0, 0, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20, 0+3*sin(bob*3), 0, 0, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, -25, 0+3*sin(bob*3), 0, 180, 5)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, -25, 0+3*sin(bob*3), 0, 180, 10)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, -25, 0+3*sin(bob*3), 0, 180, 15)}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, -25, 0+3*sin(bob*3), 0, 180, 20)}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2); Tail(tar, 20*cos(ObjRender_GetAngleY(obj)), 0+3*sin(bob*3), 0, ObjRender_GetAngleY(obj), 20)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2); Tail(tar, 19*cos(ObjRender_GetAngleY(obj)), 0+3*sin(bob*3), 0, ObjRender_GetAngleY(obj), 15)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2); Tail(tar, 18*cos(ObjRender_GetAngleY(obj)), 0+3*sin(bob*3), 0, ObjRender_GetAngleY(obj), 10)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2); Tail(tar, 17*cos(ObjRender_GetAngleY(obj)), 0+3*sin(bob*3), 0, ObjRender_GetAngleY(obj), 5)}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task RenderMami(tar, color){
	let sframe = 0;
	let mframe = 0;
	let nframe = 0;
	let aframe = 0;
	let x = 48;
	let y = 80;
	let bob = 0;
	
	Obj_SetValue(tar, "State", "Idle");
	
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);
	ObjPrim_SetTexture(obj,GetCurrentScriptDirectory ~ "./img/Ingame/boss.png");
	Obj_SetRenderPriorityI(obj, 35);
	
	ObjSprite2D_SetSourceRect(obj,0,0,x,y);
	ObjSprite2D_SetDestCenter(obj);	
	ObjRender_SetColor(obj, color[0], color[1], color[2]);
	
	while(!Obj_IsDeleted(obj)){
	let BossX = ObjMove_GetX(tar);
	let BossY = ObjMove_GetY(tar);
	let dir = ObjMove_GetAngle(tar);
	let speed = ObjMove_GetSpeed(tar);
	
	ObjRender_SetAlpha(obj, GetCommonData("BossAlpha", 255));
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight" && speed == 0) {Obj_SetValue(tar, "State", "StopMoving");}
	if(speed == 0 && Obj_GetValueD(tar, "State", 0) != "StopMoving") {Obj_SetValue(tar, "State", "Idle"); ObjRender_SetAngleXYZ(obj,0,0,GetCommonData("BossAngle",0)) }
	if(speed != 0){
		if(cos(dir) > 0) {Obj_SetValue(tar, "State", "MoveLeft"); ObjRender_SetAngleXYZ(obj, 0, 0, GetCommonData("BossAngle", 0));}
		if(cos(dir) < 0) {Obj_SetValue(tar, "State", "MoveRight"); ObjRender_SetAngleXYZ(obj, 0, 180, GetCommonData("BossAngle", 0));}
	}
	
	if(GetCommonData("BossAttack", false) == true){Obj_SetValue(tar, "State", "Attack");}
	
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,0,x,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,0,x*2,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,0,x*3,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,0,x*4,y);}
	if(Obj_GetValueD(tar, "State", 0) == "Idle" && sframe >= 32) {sframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2);}
	
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe <= 6) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 6) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 12) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "MoveRight" && mframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2);}
	
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe <= 6) {ObjSprite2D_SetSourceRect(obj,x*3,y*1,x*4,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 6) {ObjSprite2D_SetSourceRect(obj,x*2,y*1,x*3,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 12) {ObjSprite2D_SetSourceRect(obj,x,y*1,x*2,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 24) {ObjSprite2D_SetSourceRect(obj,0,y*1,x,y*2);}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving" && nframe >= 32) {Obj_SetValue(tar, "State", "Idle")}
	
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe <= 8) {ObjSprite2D_SetSourceRect(obj,0,y*2,x,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 8) {ObjSprite2D_SetSourceRect(obj,x,y*2,x*2,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 16) {ObjSprite2D_SetSourceRect(obj,x*2,y*2,x*3,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 24) {ObjSprite2D_SetSourceRect(obj,x*3,y*2,x*4,y*3);}
	if(Obj_GetValueD(tar, "State", 0) == "Attack" && aframe >= 32) {aframe = 0;}
	
	if(Obj_GetValueD(tar, "State", 0) == "Idle") {sframe++; mframe = 0; nframe = 0; aframe = 0;}
	if(Obj_GetValueD(tar, "State", 0) == "StopMoving") {nframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "Attack") {aframe++;}
	if(Obj_GetValueD(tar, "State", 0) == "MoveLeft" || Obj_GetValueD(tar, "State", 0) == "MoveRight") {mframe++;}
	SetCommonData("DisguiseBob", bob);
	bob++;
	
	ObjRender_SetPosition(obj,BossX,BossY+3*sin(bob*3),0);
	yield;
	}
}

task Tail(obj2, x, y, X, Y, Z){
	let obj = ObjPrim_Create(OBJ_SPRITE_2D);

	let alpha = 255;
	let count = 0;

		ObjPrim_SetTexture(obj, GetCurrentScriptDirectory ~ "img/Ingame/tail.png");
		Obj_SetRenderPriorityI(obj, 34);
		ObjSprite2D_SetSourceRect(obj,0,0,53,46);
		ObjSprite2D_SetDestCenter(obj);	
		ObjRender_SetScaleXYZ(obj,1,1,0);
		ObjRender_SetAngleXYZ(obj,X,Y,Z);
		ObjRender_SetBlendType(obj, BLEND_ALPHA);
		ObjRender_SetAlpha(obj, alpha);
		ObjRender_SetPosition(obj, GetX(obj2)+x, GetY(obj2)+y, 0);
		yield;
		Obj_Delete(obj);
}