An old post of mine:
If the hovering vehicle is close to the ground it adapts its orientation to the slope, otherwise it normalizes its rotation.
if(c_trace(my.x,vector(my.x,my.y,my.z-150),IGNORE_ME | IGNORE_PASSABLE)) {
vec_rotate(normal,vector(-my.pan,0,0));
my.tilt = -asin(normal.x);
my.roll = -asin(normal.y);
}
else {
my.tilt += -my.tilt/5*time;
my.roll += -my.roll/5*time;
}