action leaf() {
my.flags |= FLAG2;
my.push = -100;
var accUp = 0;
var accDown = -0.5;
var distDown = 0;
trace_mode = IGNORE_ME + IGNORE_PASSABLE + IGNORE_PASSENTS;
VECTOR vDirection;
VECTOR vDistance;
VECTOR vDifference;
ANGLE targetPan;
vec_set(vDirection, vector(0,0,0));
vec_set(vDistance, vector(0,0,0));
vec_set(vDifference, vector(0,0,0));
while(me) {
vec_diff(vDifference, vDirection, d_direction_current);
vec_accelerate(vDistance, vDirection, vDifference, 2.5);
distDown = c_trace(my.x,vector(my.x,my.y,my.z-1000),trace_mode);
if (w_speed_current > 0) {
if (w_speed_current > 0.5) {
accUp = w_speed_current * 2 * time_step;
my.roll += 5 * time_step;
my.tilt += 8 * time_step;
} else {
my.roll += w_speed_current * 10 * time_step;
my.tilt += w_speed_current * 10 * time_step;
accUp = 0;
}
} else {
if (my.tilt < 0) {
if (0 - my.tilt - 5 > 5) {
my.tilt += 5 * time_step;
} else {
my.tilt = 0;
}
} else {
if (0 - my.tilt + 5 < 5) {
my.tilt -= 5 * time_step;
} else {
my.tilt = 0;
}
}
if (my.roll < 90) {
if (80 - my.roll - 5 > 5) {
my.roll += 5 * time_step;
} else {
my.roll = 0;
}
} else {
if (90 - my.roll + 5 < 5) {
my.roll -= 5 * time_step;
} else {
my.roll = 0;
}
}
}
vec_to_angle(targetPan, d_direction_current);
if (my.pan < targetPan.pan) {
if (targetPan.pan - my.pan > 5) {
my.pan += 5 * time_step;
} else {
my.pan = targetPan.pan;
}
} else {
if (targetPan.pan - my.pan < 5) {
my.pan -= 5 * time_step;
} else {
my.pan = targetPan.pan;
}
}
accDown = accUp - 0.2 - random(0.5) * time_step;
if (distDown < 0.4) {
accDown = 0;
}
c_move(me, vDistance, vector(0,0,accDown), IGNORE_PASSABLE | IGNORE_PASSENTS | GLIDE);
wait(1);
}
}