distance = point_distance(x,y,objPlayer.x,objPlayer.y);

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

switch(motion){
	case STAND_MOT : 
		if(objPlayer.x > x) image_xscale = -1;
		else image_xscale = 1;
		if(distance>300) force_motion(RUN_MOT,0,3);
		else if(distance>100) force_motion(WALK_MOT,0,3);
		break;
	case WALK_MOT : 
		if(objPlayer.x > x) image_xscale = -1;
		else image_xscale = 1;
		if(distance>300) force_motion(RUN_MOT,0,3);
		else if(distance<100) force_motion(STAND_MOT,0,3);
		MOVE(3*-image_xscale,0);
		break;
	case RUN_MOT : 
		if(objPlayer.x > x) image_xscale = -1;
		else image_xscale = 1;
		if(distance<100) force_motion(STAND_MOT,0,3);
		MOVE(12*-image_xscale,0);
		break;
	case DAMAGEMOT[0] :
		switch(number){
			case 0 :
				if(hspeed>0) image_xscale = 1;
				else image_xscale = -1;
				break;
		}
		break;
	case DAMAGEMOT[1] :
		switch(number){
			case 0 :
				if(hspeed>0) image_xscale = 1;
				else image_xscale = -1;
				break;
		}
		break;
	case DAMAGEMOT[2] :
		switch(number){
			case 0 :
				if(hspeed>0) image_xscale = 1;
				else image_xscale = -1;
				break;
			case 2 : 
			case 3 : 
			case 4 : 
			case 5 :
				MOVE(5*image_xscale,0);
				break;
		}
		break;
}