void func_air_brake()
{
static float orig_pos[3];
static float fall_speed_mult;
static int vkl = 0;
actor_info *info = g_SAMP->getPlayers()->pLocalPlayer->pSAMP_Actor->pGTA_Ped;
if (isKeyPressed(VK_RSHIFT))
menu.air_brake ^= 1;
if (menu.air_brake)
{
vect3_copy(&info->base.matrix[4 * 3], orig_pos);
fall_speed_mult = 1.0f;
vkl = 1;
}
if (!menu.air_brake && vkl)
{
toggleSAMPCursor(0);
TOGGLECURSOR(1);
TOGGLECURSOR(0);
vkl = 0;
}
if (menu.air_brake)
{
float *matrix = info->base.matrix;
// if there's no parachute
if (g_SAMP->getPlayers()->pLocalPlayer->byteCurrentWeapon != 46)
{
vect3_copy(orig_pos, &info->base.matrix[4 * 3]);
vect3_zero(info->speed);
SetIsStanding(1);
float d[4] = { 0.0f, 0.0f, 0.0f, 0.0002f };
if (isKeyDown('W'))
d[0] += 1.0f;
if (isKeyDown('S'))
d[0] -= 1.0f;
if (isKeyDown('A'))
d[1] += 1.0f;
if (isKeyDown('D'))
d[1] -= 1.0f;
if (isKeyDown(VK_UP))
d[2] += 1.0f;
if (isKeyDown(VK_DOWN))
d[2] -= 1.0f;
if (!vect3_near_zero(d))
{
float vect[4] = { -d[1], d[0], d[2], 0.0f };
float out[4];
/* out = matrix * norm(d) */
vect3_normalize(vect, vect);
matrix_vect4_mult(matrix, vect, out);
matrix[4 * 3 + 0] += out[0] * d[3];
matrix[4 * 3 + 1] += out[1] * d[3];
matrix[4 * 3 + 2] += out[2] * d[3];
}
}
vect3_copy(&matrix[4 * 3], orig_pos);
}
}