//Boss Animation Libary

let Anim_Attack = 0;
let Anim_Declare = 0;

task SpellDeclare(frames) {
	let objEnemy = GetEnemyBossObjectID[0];
	loop(4) { yield; }
	// while(ObjMove_GetSpeed(objEnemyMain)*cos(ObjMove_GetAngle(objEnemyMain)) < 0.5 && ObjMove_GetSpeed(objEnemyMain)*cos(ObjMove_GetAngle(objEnemyMain)) > -0.5){ yield; }
	while(ObjMove_GetSpeed(objEnemy)*cos(ObjMove_GetAngle(objEnemy)) >= 0.5 || ObjMove_GetSpeed(objEnemy)*cos(ObjMove_GetAngle(objEnemy)) <= -0.5){ yield; }
	loop(37) { yield; } // Changed from 22 to 15 //TrickyComment: Changed from 15 to 37
	Anim_Declare = 1;
	loop(8) { yield; }
	ObjEnemyBossScene_StartSpell(GetEnemyBossSceneObjectID);
	loop(frames) { yield; }
	Anim_Declare = 0;
}
task AnimateBossLB(objID){
	let count = 0;
	let enemyang = 0;
	let enemyspd = 0;
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/LeBlanc.png");
	ObjSprite2D_SetSourceRect(objID, 0, 0, 256, 533);
	ObjSprite2D_SetDestCenter(objID);  
	ObjRender_SetScaleXYZ(objID, 0.25, 0.20, 0.25);
	while(!Obj_IsDeleted(objID)){
		enemyang = absolute(ObjMove_GetAngle(objID));
		enemyspd = absolute(ObjMove_GetSpeed(objID));
		while(enemyang>360){
			enemyang = enemyang-360;
		}
		if(enemyspd > 0.25){
			if(enemyang<90 || enemyang>270){ ObjRender_SetAngleZ(objID, count*15.765); }
			else if(enemyang< 270 && enemyang > 90){ ObjRender_SetAngleZ(objID, -count*15.765); }
			else{ }
		}
		else{ ObjRender_SetAngleZ(objID, 0); }
		count++;
		yield;
	}
}
task AnimateBossM1_old(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 0;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let m = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 1/FutoBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		if(Anim_Attack==1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+96); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+96); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+96); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+96); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+96); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+96); }
			if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*3, y, x*4, y+96); }
			if(count >= r*7){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			x = 64;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			x = 80;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+192, x*1, y+288); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+192, x*2, y+288); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, x*2, y+192, x*3, y+288); }
			if(count >= r*3-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			x = 80;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+192, x*3, y+288); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+192, x*2, y+288); }
			if(count >= r*2){  ObjSprite2D_SetSourceRect(objID, x*0, y+192, x*1, y+288); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+288, x*1, y+384); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM1(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 1/FutoBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 9){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*4-r/2){ type=9; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM2_old(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 64;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 2/AkiBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
			ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM2(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 2/MinorikoBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-48,-48+float,48,48);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-48,-48+float,48,48+float);
			float+=0.15*cos(3*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 8){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		// ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM3(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 8;
	let move = 2;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 3/AyaBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 9){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) == 0) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*6){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*4, y*1, x*5, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*4, y*1, x*5, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*5-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*4-r/2){ type=9; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM4(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 4/CirnoBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 9){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*4-r/2){ type=9; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM5(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 5/YamameBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 9){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*6){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*4-r/2){ type=9; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM6A(objID){
	let count = 0;
	let type = 0;
	
	let x = 50;
	let y = 80;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 6/PrismBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35+float);
			float+=0.2*cos(1.5*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*4, y+0, x*5, y+70); }
			if(count >= r*2-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*4, y+0, x*5, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			if(count >= r*2-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*4, y+0, x*5, y+70); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM6B(objID){
	let count = 0;
	let type = 0;
	
	let x = 50;
	let y = 323;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 6/PrismBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35+float);
			float+=0.2*cos(1.5*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+80, x*3, y+150); }
			if(count >= r*3-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+80, x*3, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y+80, x*3, y+150); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossM6C(objID){
	let count = 0;
	let type = 0;
	
	let x = 50;
	let y = 165;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 6/PrismBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			ObjSprite2D_SetDestRect(objID,-25,-35+float,25,35+float);
			float+=0.2*cos(1.5*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			//if(count >= r*4-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y+0, x*4, y+70); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y+0, x*3, y+70); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y+0, x*2, y+70); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y+0, x*1, y+70); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r*2-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*0, y+80, x*1, y+150); }
			if(count >= r*2-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*1, y+80, x*2, y+150); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		//ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE1_old(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 96;
	
	let idle = 10;
	
	let r = idle;
	let m = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 1/TojikoBoss.png");
	ObjRender_SetScaleX(objID, -1);
	
	while(!Obj_IsDeleted(objID)){
		
		if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, 0, x*1, y); }
		if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, 0, x*2, y); }
		if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, 0, x*3, y); }
		if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, 0, x*1, y); }
		if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*1, 0, x*2, y); }
		if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, 0, x*3, y); }
		if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*3, 0, x*4, y); }
		if(count >= r*7){ count = 0; }
		
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE1(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 1/TojikoBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 8){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*7){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE2_old(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 64;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 2/AkiBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*2-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE2(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 2/ShizuhaBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 8){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*7){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r*8){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE3(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 64;
	
	let idle = 10;
	let move = 4;
	let attack = 3;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 3/MomijiBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.5) { 
				if(type == 0) {
					count = 0;
					type = 2;
				}
				ObjSprite2D_SetDestRect(objID,-32,-32,32,32);
			}
			else if (ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.5) {
				if(type == 0) {
					count = 0;
					type = 2.5;
				}
				ObjSprite2D_SetDestRect(objID,-32,-32,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
				else if(type == 2.5) {
					count = 0;
					type = 3.5;
				}
			ObjSprite2D_SetDestRect(objID,-32,-32,32,32);
			// float+=0.1*cos(2*t);
			// t++;
			}
		}
		else {
			r = attack;
			if(type != 4 && type != 6){
				count = -10;
				type = 4;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		// if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving right
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==2.5){ //Idle to moving left
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving right to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==3.5){ //Moving left to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*3-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= -15){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*3, x*4, y*4); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Attack to idle
			r = attack;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*3, x*4, y*4); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*3, x*4, y*4); }
			if(Anim_Attack == 0) { type=5; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE4(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 5;
	let move = 4;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 4/DaiBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 8){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*6){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE5_old(objID){
	let count = 0;
	let type = 0;
	
	let x = 64;
	let y = 64;
	
	let idle = 10;
	
	let r = idle;
	let m = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 5/KisumeBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		
		if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, 0, x*1, y); }
		if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, 0, x*2, y); }
		if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, 0, x*3, y); }
		if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, 0, x*4, y); }
		if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*0, y, x*1, y+64); }
		if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*1, y, x*2, y+64); }
		if(count >= r*6){ ObjSprite2D_SetSourceRect(objID, x*2, y, x*3, y+64); }
		if(count >= r*7){ ObjSprite2D_SetSourceRect(objID, x*3, y, x*4, y+64); }
		if(count >= r*8){ count = 0; }
		
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}
task AnimateBossE5(objID){
	let count = 0;
	let type = 0;
	
	let x = 96;
	let y = 96;
	
	let idle = 10;
	let move = 3;
	let attack = 6;
	let declare = 6;
	
	let r = idle;
	let m = 0;
	
	let float = 0;
	let t = 0;
	
	ObjPrim_SetTexture(objID, MD ~ "IMG/Enemy/Stage 5/KisumeBoss.png");
	
	while(!Obj_IsDeleted(objID)){
		if(Anim_Attack==0 && Anim_Declare==0){
			if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.2 || ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.2){
				if(type == 0) {
					count = 0;
					type = 2;
				}
				// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32);
			}
			else {
				if(type == 2) {
					count = 0;
					type = 3;
				}
			// ObjSprite2D_SetDestRect(objID,-32,-32+float,32,32+float);
			float+=0.1*cos(2*t);
			t++;
			}
		}
		else if(Anim_Declare==1){
			r = declare;
			if(type != 4 && type != 6){
				count = 0;
				type = 4;
			}
		}
		else if(Anim_Attack==1){
			r = attack;
			if(type != 7 && type != 9){
				count = 0;
				type = 7;
			}
		}
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) >= 0.1) { ObjRender_SetScaleXYZ(objID, 1, 1, 1); }
		if(ObjMove_GetSpeed(objID)*cos(ObjMove_GetAngle(objID)) <= -0.1){ ObjRender_SetScaleXYZ(objID, -1, 1, 1); }
		
		if(type==0){ //Idle
			r = idle;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*0, x*1, y*1); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*0, x*4, y*1); }
			if(count >= r*4){ ObjSprite2D_SetSourceRect(objID, x*2, y*0, x*3, y*1); }
			if(count >= r*5){ ObjSprite2D_SetSourceRect(objID, x*1, y*0, x*2, y*1); }
			if(count >= r*6){ count = 0; }
		}
		if(type==1){ //Moving
			r = move;
			// if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y+96, x*1, y+192); }
			// if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y+96, x*2, y+192); }
			// if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y+96, x*3, y+192); }
			// if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y+96, x*4, y+192); }
			// if(count >= r*4){ count = 0; }
		}
		if(type==2){ //Idle to moving
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			//if(count >= r*3-r/2){ type=1; count=0; }
		}
		if(type==3){ //Moving to idle
			r = move;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*1, x*4, y*2); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*2, y*1, x*3, y*2); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*1, x*2, y*2); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*1, x*1, y*2); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==4){ //Idle to declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*4-r/2){ type=6; count=0; }
		}
		if(type==5){ //Declare to idle
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*2, x*4, y*3); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*2, x*3, y*3); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*2, x*2, y*3); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*2, x*1, y*3); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==6){ //Declare
			r = declare;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*3, x*1, y*4); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*1, y*3, x*2, y*4); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*3, x*3, y*4); }
			if(count >= r*3){ count = 0; }
			if(Anim_Declare == 0) { type=5; count=0; }
		}
		if(type==7){ //Idle to attack
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*4-r/2){ type=9; count=0; }
		}
		if(type==8){ //Attack to idle
			r = attack;
			ObjRender_SetScaleXYZ(objID, 1, 1, 1);
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(count >= r*1){ ObjSprite2D_SetSourceRect(objID, x*2, y*4, x*3, y*5); }
			if(count >= r*2){ ObjSprite2D_SetSourceRect(objID, x*1, y*4, x*2, y*5); }
			if(count >= r*3){ ObjSprite2D_SetSourceRect(objID, x*0, y*4, x*1, y*5); }
			if(count >= r*4-r/2){ type=0; count=0; }
		}
		if(type==9){ //Attack
			r = attack;
			if(count >= 0){ ObjSprite2D_SetSourceRect(objID, x*3, y*4, x*4, y*5); }
			if(Anim_Attack == 0) { type=8; count=0; }
		}
		m+=1;
		count++;
		ObjSprite2D_SetDestCenter(objID);
		yield;
	}
}