void (entity tiltee, vector v1, vector v2, vector v3, vector v4) entity_tilt =
{
	local vector v;
	local float l1;
	local float l2;
	local float l3;
	local float l4;
	local float r1;
	local float r2;

	v = self.angles;
	v_x = 0;
	makevectors (v);
	traceline ((v1 + (64 * v_up)), (v1 - (64 * v_up)), TRUE, tiltee);
	l1 = trace_fraction;
	traceline ((v2 + (64 * v_up)), (v2 - (64 * v_up)), TRUE, tiltee);
	l2 = trace_fraction;
	traceline ((v3 + (64 * v_up)), (v3 - (64 * v_up)), TRUE, tiltee);
	l3 = trace_fraction;
	traceline ((v4 + (64 * v_up)), (v4 - (64 * v_up)), TRUE, tiltee);
	l4 = trace_fraction;

	if ((l1 == 1) && (l2 == 1) && (l3 == 1) && (l4 == 1))
		return;

	r1 = (((l1 - l2) + l3) - l4);
	r2 = (((l1 - l3) + l2) - l4);
	v = '0 0.75 0';
	v_x = r1;
	v_z = r2;
	v = normalize (v);
	v2 = vectoangles (v);
	v3 = '0 2 0';
	v3_x = (0 - v2_x);
	v3_y = tiltee.angles_y;
	v3_z = (v2_z - 90);
	v4 = (v3 - tiltee.angles);
	l1 = v4_x;
	if ((l1 > 180))
	{
		l1 = (l1 - 360);
	}
	l2 = v4_z;
	if ((l2 > 180))
	{
		l2 = (l2 - 360);
	}

	tiltee.angles_z = 0;
	tiltee.angles_x = (tiltee.angles_x + (l1 * 0.75));
};


void() tilt =
{
	local vector a1;
	local vector a2;
	local vector a3;
	local vector a4;

	makevectors (self.angles);
	a1 = ((self.origin + (8 * v_forward)) - (12 * v_right));
	a2 = ((self.origin + (8 * v_forward)) + (12 * v_right));
	a3 = ((self.origin - (8 * v_forward)) - (12 * v_right));
	a4 = ((self.origin - (8 * v_forward)) + (12 * v_right));
	entity_tilt (self, a1, a2, a3, a4);
};