if( place_free(x,y+1) ){
	air = true;
	gravity = 0.98;
	gravity_direction = 270;
}else{
	air = false;
	hspeed = hspeed*0.8;
	gravity = 0;
	gravity_direction = 0;
}

BIND_CHECK(5,0,2);

switch(motion){
	case 10 :
		Parts[03].depth_mode = true; Parts[03].depth = objPlayer.depth+1;
		Parts[04].depth_mode = true; Parts[04].depth = objPlayer.depth+1;
		Parts[05].depth_mode = true; Parts[05].depth = objPlayer.depth+1;
	case  8 : 
	case  9 :
		Parts[10].depth_mode = true; Parts[10].depth = objPlayer.depth+1;
		Parts[11].depth_mode = true; Parts[11].depth = objPlayer.depth+1;
		Parts[12].depth_mode = true; Parts[12].depth = objPlayer.depth+1;
		break;
	case 13 :
		with(objPlayer){
			Parts[4].depth_mode = true; Parts[4].depth = other.depth-1;
			Parts[5].depth_mode = true; Parts[5].depth = other.depth-1;
			Parts[8].depth_mode = true; Parts[8].depth = other.depth-1;
		}
		break;
}


if(BIND){
	switch(motion){
		case 8 : 
		case 9 :
		case 10 :
			objPlayer.speed = 0;
			objPlayer.gravity = 0;	
			objPlayer.x = x-image_xscale*20;
			objPlayer.y = y+8;
			break;
		case 11 : 
		case 12 : 
			if(number==5 && KEYFRAME ){
				check = collision_enemy(x,y,400,0,0,DAMAGE[BINDED,4],0,10,10);
				if(check){
					if( random(100)<70 ) with(objHead){ Blood(x,y,5,0.01,0.1,250,40,0,5,c_white); }
					sound_play(sndHit03);
					quake(50,20);
					flash(c_red,0.3,0.1);
					if( random(100)<5 ){
						with(objHead){ Blood(x,y,5,0.2,0.1,250,40,0,5,c_red); }
						with(objBody_Bottom){ event_user(0); }
					}
				}
			}
			objPlayer.speed = 0;
			objPlayer.gravity = 0;	
			objPlayer.x = Parts[5].x-image_xscale*32;
			objPlayer.y = Parts[5].y+20;
			break;
		case 13 : 
			if(number==4 && KEYFRAME ){
				check = collision_enemy(x,y,400,0,0,DAMAGE[BINDED,0],0,5,10);
				if(check){
					sound_play(sndHit01);
					quake(30,10);
					if( random(100)<5 ) with(objBody_Bottom){ event_user(0); }
				}
			}
			if(number==13 && KEYFRAME ){
				check = collision_enemy(x,y,400,0,0,DAMAGE[BINDED,5],0,5,10);
				if(check){
					quake(10,7);
					if( random(100)<90 ) with(objBody_Bottom){ event_user(0); }
					with(objHead){ Blood(x,y,15,0.01,0.1,70,40,5,2,c_white); }
				}
				VAR[0] = 0;
			}else if(number>13) quake(2,5);

			if(number==14 && KEYFRAME ){
				if( random(100)<3 ){
					with(objHead){ Blood(x,y,15,0.01,0.1,80,20,2,2,c_white); }
					if(objPlayer.HP<0) with(objHead){ Blood(x,y,5,0.1,0.1,80,20,3,2,c_red); }
					check = collision_enemy(x,y,400,0,0,DAMAGE[BINDED,5],0,4,10);
					if(check) with(objBody_Bottom){ event_user(0); }
				}else{
					if(random(100)<5){
						with(objHead){ Blood(x,y,1,0.05,0.1,80,20,2,1,c_white); }
						if(objPlayer.HP<0) with(objHead){ Blood(x,y,1,0.05,0.1,80,20,10,1,c_red); }
					}
					check = collision_enemy(x,y,400,0,0,NULL,0,3,10);
				}
			}
			if( (objPlayer.b1>=2 || objPlayer.b2>=2 || objPlayer.b3>=2) && objPlayer.HP>0) VAR[0] += 1;

			objPlayer.speed = 0;
			objPlayer.gravity = 0;
			if(number<4){
				objPlayer.x = Parts[5].x-image_xscale*15;
				objPlayer.y = Parts[5].y+20;
			}else{
				objPlayer.x = Parts[8].x-image_xscale*15;
				objPlayer.y = Parts[8].y-10;
			}
			break;
	}
}else{
	if( !force_change){
		if( motion==0 || motion==1){
			if( point_distance(x,y,objPlayer.x,objPlayer.y) < 400 ){
				if( point_distance(x,y,objPlayer.x,objPlayer.y) < 50 && motion<=1 && ((!place_meeting(x+128,y,objBlock)&&!image_xscale) || (!place_meeting(x-128,y,objBlock)&&image_xscale)) ){
					if(objPlayer.x > x) image_xscale = -1;
					else image_xscale = 1;
					force_motion(11,0,5);
				}else if( point_distance(x,y,objPlayer.x,objPlayer.y) < 130 && motion<=1 ){
					if(objPlayer.x > x) image_xscale = -1;
					else image_xscale = 1;
					force_motion(6,0,5);
				}else if( point_distance(x,y,objPlayer.x,objPlayer.y) < 140 && motion<=1 ){
					if(objPlayer.x > x) image_xscale = -1;
					else image_xscale = 1;
					force_motion(2,0,5);
				}

				if(motion==0){
					if(objPlayer.x > x){
						image_xscale = -1;
						if(motion!=1) force_motion(1,0,5);
					}else{
						image_xscale = 1;
						if(motion!=1) force_motion(1,0,5);
					}
				}
			}else if( point_distance(x,y,objPlayer.x,objPlayer.y) > 410 ){
				if( motion<=1 ){
					if(objPlayer.x > x) image_xscale = -1;
					else image_xscale = 1;
					force_motion(7,0,5);
				}
			}else if(motion==1) force_motion(0,0,5);
		}
	}
}

switch(motion){
	case 1 : 
		MOVE(3*-image_xscale,0);
		break;
	case 2 : 
		switch(number){
			case 3 : 
				if(KEYFRAME){
					sound_play(sndSwing4);
					MOVE(30*-image_xscale,0);
				}
			case 4 : 
				with(Parts[8]){
					if(BIND_ABLE()){
						if(!image_xscale) check = collision_enemy(x,y,48,30,0,-1,2,50,20);
						else check = collision_enemy(x,y,48,30,180,-1,2,50,20);
						if(check){
							sound_play(sndHit00);
							quake(20,5);
							flash(c_red,0.5,0.1);
							with(other){ if(random(100)<30) force_motion(7,0,5); }
						}
					}
				}
				break;
		}
		break;
	case 6 : 
		switch(number){
			case 3 : 	if(KEYFRAME) sound_play(sndSwing4);
			case 4 : 
				MOVE(4*-image_xscale,0);
				with(Parts[8]){
					if(BIND_ABLE()){
						if(!image_xscale) check = collision_enemy(x,y,48,15,70,-1,2,40,20);
						else check = collision_enemy(x,y,48,15,110,-1,2,40,20);
						if(check){
							sound_play(sndHit00);
							quake(20,5);
							flash(c_red,0.5,0.1);
						}
					}
				}
				break;
		}
		break;
	case 7 : 
		switch(number){
			case 1 : VAR[0] = 0; break;
			case 5 : 	
			case 6 : 
			case 7 : 
				VAR[0] += 1;
				if(VAR[0] > 30) {force_motion(0,0,5);break;}
				MOVE(25*-image_xscale,0);
				with(Parts[0]){
					if(BIND_ABLE()){
						check = collision_enemy(x,y,48,0,0,other.DAMAGE[other.HIGH,other.HARD],0,40,60);
						if(check){
							sound_play(sndHit00);
							quake(20,5);
							flash(c_red,0.5,0.1);
							with(other){ objPlayer.image_xscale=-image_xscale;BIND_ON();force_motion(8,0,1); }
						}
					}
				}
				break;
		}
		break;
	case 9 : 
		switch(number){
			case 1 : if(KEYFRAME) with(objPlayer){ force_motion(DAMAGE[BINDED,1],0,5); }
			case 5 : 
				if(KEYFRAME){
					if(random(100)<10) with(objBody_Top){ event_user(1) };
					if(objPlayer.HP < -300){
						switch( round(random(3)) ){
							case 1	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],19,20,10); break;
							default	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],23,20,10); break;
						}
					}else{
						switch( round(random(4)) ){
							case 1	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],00,20,10); break;
							case 2	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],07,20,10); break;
							case 3	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],16,20,10); break;
							default	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],00,20,10); break;
						}
					}
					if(check){
						sound_play(sndHit03);
						quake(50,10);
						flash(c_red,0.5,0.1);
					}
				}
				break;
			case 7 : 
			case 8 : 
			case 9 : 
				if(objPlayer.HP>80) force_motion(9,2,5);
				break;
		}
		break;
	case 10 : 
		switch(number){
			case 5 : 
			case 8 : 
				if(KEYFRAME){
					if(random(100)<20) with(objBody_Top){ event_user(1) };
					if(objPlayer.HP < -300){
						switch( round(random(3)) ){
							case 1	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],19,20,10); break;
							default	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],23,20,10); break;
						}
					}else{
						switch( round(random(4)) ){
							case 1	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],00,20,10); break;
							case 2	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],07,20,10); break;
							case 3	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],16,20,10); break;
							default	: check = collision_enemy(x,y,200,0,270,DAMAGE[BINDED,2],00,20,10); break;
						}
					}
					if(check){
						if( random(100)<80 ) with(objHead){ Blood(x,y+8,5,0.1,0.1,0,180,0,10,c_red); }
						sound_play(sndHit04);
						quake(50,7);
						flash(c_red,0.3,0.1);
						if( random(100)<5 ) with(objHead){ event_user(0); }
					}
				}
				break;
		}
		break;
	case 11 : 
		switch(number){
			case 1 :
				with(Parts[5]){
					if(BIND_ABLE()){
						check = collision_enemy(x,y,48,0,0,other.DAMAGE[other.BINDED,3],0,40,60);
						if(check){
							sound_play(sndHit01);
							quake(20,5);
							with(other){ objPlayer.image_xscale=-image_xscale;BIND_ON(); }
						}
					}
				}
				break;
			case 4 :
				if(BIND){
					if(random(100)<50) force_motion(12,0,5);
					else force_motion(13,0,5);
				}
				break;
		}
		break;
}

