C++ Gamesense Movement Fix [roll angles fix]

get good get legendware
Участник
Статус
Оффлайн
Регистрация
22 Сен 2020
Сообщения
438
Реакции[?]
201
Поинты[?]
48K
C++:
void Movement::FixMove(CUserCmd* cmd, ang_t& wanted_move, bool a7)
{
    // Declare and initialize variables
    float move_magnitude = 0.0f;
    float forwardY = 0.0f, forwardZ = 0.0f, forwardX = 0.0f;
    float rightY = 0.0f, rightZ = 0.0f, rightX = 0.0f;
    float upZ = 1.0f;

    // Copy the input wanted_move and view angles
    ang_t inputAngles = wanted_move;
    ang_t viewAngles = cmd->m_view_angles;

    // Check if wanted_move is the same as the view angles
    if (wanted_move == viewAngles)
        return;

    // Calculate the magnitude of movement
    move_magnitude = std::sqrt((cmd->m_forward_move * cmd->m_forward_move) + (cmd->m_side_move * cmd->m_side_move));

    // If there's no movement, return
    if (move_magnitude == 0.0f)
        return;

    // Check if the local player's move type is 8 (LADDER) or 9 (NOCLIP)
    if (g_cl.m_local->m_MoveType() == 8 || g_cl.m_local->m_MoveType() == 9)
        return;

    // Calculate forward, right, and up vectors based on input angles
    vec3_t forwardVector, rightVector, upVector;
    math::AngleVectors(inputAngles, &forwardVector, &rightVector, &upVector);

    // Extract components of the forward vector
    forwardY = forwardVector.y;
    forwardZ = forwardVector.z;

    // Set upZ to 1.0 if forwardVector.z is zero, otherwise calculate forwardX, forwardY, and forwardXNormalized
    if (forwardVector.z != 0.0f) {
        forwardZ = 0.0f;
        float forwardVectorLength2D = forwardVector.length_2d();
        if (forwardVectorLength2D >= 0.00000011920929f) {
            forwardY = forwardVector.y * (1.0f / forwardVectorLength2D);
            forwardX = forwardVector.x * (1.0f / forwardVectorLength2D);
        } else {
            forwardY = 0.0f;
            forwardX = 0.0f;
        }
    }

    // Extract components of the right vector
    rightY = rightVector.y;
    rightZ = rightVector.z;

    // Set rightX and rightZ to components of the right vector
    if (rightVector.z != 0.0) {
        rightZ = 0.0f;
        float rightVectorLength2D = rightVector.length_2d();
        if (rightVectorLength2D < 0.00000011920929f) {
            rightY = 0.0f;
            rightX = 0.0f;
        } else {
            rightY = rightVector.y * (1.0f / rightVectorLength2D);
            rightX = rightVector.x * (1.0f / rightVectorLength2D);
        }
    }

    // Set upZ to 0.0 if upVector.z is small
    if (upVector.z < 0.00000011920929f)
        upZ = 0.0f;

    // Handle special case for cmd->m_forward_move if viewAngles.z is 180.0 and a7 is false
    if (viewAngles.z == 180.0 && !a7)
        cmd->m_forward_move = std::abs(cmd->m_forward_move);

    // Calculate vectors based on view angles
    math::AngleVectors(viewAngles, &rightVector, &forwardVector, &upVector);

    // Extract components of the right and forward vectors
    rightZ = rightVector.z;
    if (rightVector.z == 0.0f) {
        rightY = rightVector.y;
        rightX = rightVector.x;
    } else {
        rightZ = 0.0f;
        float rightVectorLength2D = rightVector.length_2d();
        if (rightVectorLength2D < 0.00000011920929f) {
            rightY = 0.0f;
            rightX = 0.0f;
        } else {
            rightX = rightVector.x * (1.0f / rightVectorLength2D);
            rightY = rightVector.y * (1.0f / rightVectorLength2D);
        }
    }

    float forwardZView = forwardVector.z;
    if (forwardVector.z == 0.0f) {
        float forwardYView = forwardVector.y;
        float forwardXView = forwardVector.x;
    } else {
        forwardZView = 0.0f;
        float forwardVectorLength2D = forwardVector.length_2d();
        if (forwardVectorLength2D < 0.00000011920929f) {
            float forwardYView = 0.0f;
            float forwardXView = 0.0f;
        } else {
            float forwardXView = forwardVector.x * (1.0f / forwardVectorLength2D);
            float forwardYView = forwardVector.y * (1.0f / forwardVectorLength2D);
        }
    }

    // Set upZ to 0.0 if upVector.z is small
    if (upVector.z < 0.00000011920929f)
        upZ = 0.0f;

    // Calculate new movement values for cmd
    float rightMove = rightY * cmd->m_side_move;
    float forwardMove = forwardX * cmd->m_forward_move;
    float upMove = upZ * cmd->m_up_move;

    cmd->m_forward_move = ((((rightMove * rightY) + (rightX * rightX)) + (rightZ * forwardYView)) + (((upMove * rightY) + (forwardMove * rightX)) + (rightMove * forwardZView))) + (((upMove * rightY) + (upMove * rightX)) + (upZ * forwardZView));
    cmd->m_side_move = ((((rightMove * forwardY) + (rightX * forwardXView)) + (rightZ * forwardZView)) + (((upMove * forwardY) + (forwardMove * forwardXView)) + (rightMove * forwardZView))) + (((upMove * forwardY) + (upMove * forwardXView)) + (upZ * forwardZView));
    cmd->m_up_move = ((((rightMove * 0.0f) + (rightX * 0.0f)) + (rightZ * upZ)) + (((upMove * 0.0f) + (forwardMove * 0.0f)) + (rightMove * upZ))) + (((upMove * 0.0f) + (upMove * 0.0f)) + (upZ * upZ));
}
 
ЧВК YAROSLAV
Забаненный
Статус
Оффлайн
Регистрация
25 Дек 2019
Сообщения
595
Реакции[?]
184
Поинты[?]
31K
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
gamesense (legendware) true movement fix:imp:
 
Участник
Статус
Оффлайн
Регистрация
19 Апр 2020
Сообщения
1,180
Реакции[?]
314
Поинты[?]
152K
p2c roll fix:
cmd->upmove = sin(DEG2RAD(cmd->viewangles.roll)) * sin(DEG2RAD(cmd->viewangles.pitch)) * cmd->sidemove;
    cmd->forwardmove = cos(DEG2RAD(cmd->viewangles.roll)) * cmd->forwardmove + sin(DEG2RAD(cmd->viewangles.pitch)) * sin(DEG2RAD(cmd->viewangles.roll)) * cmd->sidemove;
 
1337
Пользователь
Статус
Оффлайн
Регистрация
13 Ноя 2022
Сообщения
90
Реакции[?]
50
Поинты[?]
45K
C++:
    // Calculate the magnitude of movement
    move_magnitude = std::sqrt((cmd->m_forward_move * cmd->m_forward_move) + (cmd->m_side_move * cmd->m_side_move));

    // If there's no movement, return
    if (move_magnitude == 0.0f)
        return;
 
Сверху Снизу