Исходник How to fix movement after update

Начинающий
Начинающий
Статус
Оффлайн
Регистрация
17 Ноя 2023
Сообщения
73
Реакции
10
C++:
Expand Collapse Copy
class c_in_button_state
{
public:
    void* __vfptr; //0x0000
    uint64_t button_state; //0x0008
    uint64_t button_state2; //0x0010
    uint64_t button_state3; //0x0018

    enum e_button_state_t : int8_t
    {
        in_button_up = 0,
        in_button_down = 1,
        in_button_down_up = 2,
        in_button_up_down = 3,
        in_button_up_down_up = 4,
        in_button_down_up_down = 5,
        in_button_down_up_down_up = 6,
        in_button_up_down_up_down = 7
    };

    void set_button_state(const uint64_t& u_value, int e_button_state)
    {
        switch (e_button_state)
        {
        case in_button_up:
        {
            button_state &= ~u_value;
            button_state2 &= ~u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_down:
        {
            button_state |= u_value;
            button_state2 &= ~u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_down_up:
        {
            button_state &= ~u_value;
            button_state2 |= u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_up_down:
        {
            button_state |= u_value;
            button_state2 |= u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_up_down_up:
        {
            button_state &= ~u_value;
            button_state2 &= ~u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_down_up_down:
        {
            button_state |= u_value;
            button_state2 &= ~u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_down_up_down_up:
        {
            button_state &= ~u_value;
            button_state2 |= u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_up_down_up_down:
        {
            button_state |= u_value;
            button_state2 |= u_value;
            button_state3 |= u_value;
            break;
        }
        }
    }
};
static_assert(sizeof(c_in_button_state) == 0x20);

void c_movement::fix_cmd_buttons()
{
    if (ctx.base_cmd->forwardmove() > 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_FORWARD, c_in_button_state::e_button_state_t::in_button_down);
    else if (ctx.base_cmd->forwardmove() < 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_BACK, c_in_button_state::e_button_state_t::in_button_down);

    if (ctx.base_cmd->leftmove() > 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_MOVELEFT, c_in_button_state::e_button_state_t::in_button_down);
    else if (ctx.base_cmd->leftmove() < 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_MOVERIGHT, c_in_button_state::e_button_state_t::in_button_down);
}

call fix_cmd_buttons in the CreateMove hook AFTER ALL calls

credits: @King Gizzard
 
Последнее редактирование:
C++:
Expand Collapse Copy
class c_in_button_state
{
public:
    void* __vfptr; //0x0000
    uint64_t button_state; //0x0008
    uint64_t button_state2; //0x0010
    uint64_t button_state3; //0x0018

    enum e_button_state_t : int8_t
    {
        in_button_up = 0,
        in_button_down = 1,
        in_button_down_up = 2,
        in_button_up_down = 3,
        in_button_up_down_up = 4,
        in_button_down_up_down = 5,
        in_button_down_up_down_up = 6,
        in_button_up_down_up_down = 7
    };

    void set_button_state(const uint64_t& u_value, int e_button_state)
    {
        switch (e_button_state)
        {
        case in_button_up:
        {
            button_state &= ~u_value;
            button_state2 &= ~u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_down:
        {
            button_state |= u_value;
            button_state2 &= ~u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_down_up:
        {
            button_state &= ~u_value;
            button_state2 |= u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_up_down:
        {
            button_state |= u_value;
            button_state2 |= u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_up_down_up:
        {
            button_state &= ~u_value;
            button_state2 &= ~u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_down_up_down:
        {
            button_state |= u_value;
            button_state2 &= ~u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_down_up_down_up:
        {
            button_state &= ~u_value;
            button_state2 |= u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_up_down_up_down:
        {
            button_state |= u_value;
            button_state2 |= u_value;
            button_state3 |= u_value;
            break;
        }
        }
    }
};
static_assert(sizeof(c_in_button_state) == 0x20);

void c_movement::fix_cmd_buttons()
{
    if (ctx.base_cmd->forwardmove() > 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_FORWARD, c_in_button_state::e_button_state_t::in_button_down);
    else if (ctx.base_cmd->forwardmove() < 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_BACK, c_in_button_state::e_button_state_t::in_button_down);

    if (ctx.base_cmd->leftmove() > 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_MOVELEFT, c_in_button_state::e_button_state_t::in_button_down);
    else if (ctx.base_cmd->leftmove() < 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_MOVERIGHT, c_in_button_state::e_button_state_t::in_button_down);
}

call fix_cmd_buttons in the CreateMove hook AFTER ALL calls

credits: @King Gizzard
The code looks to be working for the motion fix after the update. The point is to synchronize the movement buttons (IN_FORWARD, IN_BACK, etc.) with the actual movement values (forwardmove/leftmove) from the original command.

How it works:

c_in_button_state stores button states in three bit masks (button_state, button_state2, button_state3)

set_button_state sets the necessary bits in these masks depending on the complex state of the button (up/down/combination)

fix_cmd_buttons checks the movement values from the original command (base_cmd) and explicitly sets the corresponding button flags in the in_button_down state

Important points:

Call this function in the CreateMove hook after all other processes so that your changes are not overwritten.

Make sure that ctx.base_cmd contains the original, unchanged motion command.

Make sure that IN_FORWARD, IN_BACK, and other constants have the correct values (usually powers of two: 1, 2, 4, 8...)

If the movement still does not work correctly, check if the forwardmove/leftmove values are not overwritten somewhere else after calling your function.
 
The code looks to be working for the motion fix after the update. The point is to synchronize the movement buttons (IN_FORWARD, IN_BACK, etc.) with the actual movement values (forwardmove/leftmove) from the original command.

How it works:

c_in_button_state stores button states in three bit masks (button_state, button_state2, button_state3)

set_button_state sets the necessary bits in these masks depending on the complex state of the button (up/down/combination)

fix_cmd_buttons checks the movement values from the original command (base_cmd) and explicitly sets the corresponding button flags in the in_button_down state

Important points:

Call this function in the CreateMove hook after all other processes so that your changes are not overwritten.

Make sure that ctx.base_cmd contains the original, unchanged motion command.

Make sure that IN_FORWARD, IN_BACK, and other constants have the correct values (usually powers of two: 1, 2, 4, 8...)

If the movement still does not work correctly, check if the forwardmove/leftmove values are not overwritten somewhere else after calling your function.
thank you for this amazing chatgpt c+p text
 
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
да, дружище точно же AFTER ALL CALLS
довольно кстати забавно спустя буквально 11 лет(еще со временем ксго) вальв наконец то начали чекать кнопочки(к слову эта паста есть во всех паблик мувмент фиксах на ксго/кс2) пост по факту бесполезен так еще и в кредиты вписали какого то KInGkIzzArD
Пожалуйста, авторизуйтесь для просмотра ссылки.
кстати референс
 
C++:
Expand Collapse Copy
class c_in_button_state
{
public:
    void* __vfptr; //0x0000
    uint64_t button_state; //0x0008
    uint64_t button_state2; //0x0010
    uint64_t button_state3; //0x0018

    enum e_button_state_t : int8_t
    {
        in_button_up = 0,
        in_button_down = 1,
        in_button_down_up = 2,
        in_button_up_down = 3,
        in_button_up_down_up = 4,
        in_button_down_up_down = 5,
        in_button_down_up_down_up = 6,
        in_button_up_down_up_down = 7
    };

    void set_button_state(const uint64_t& u_value, int e_button_state)
    {
        switch (e_button_state)
        {
        case in_button_up:
        {
            button_state &= ~u_value;
            button_state2 &= ~u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_down:
        {
            button_state |= u_value;
            button_state2 &= ~u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_down_up:
        {
            button_state &= ~u_value;
            button_state2 |= u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_up_down:
        {
            button_state |= u_value;
            button_state2 |= u_value;
            button_state3 &= ~u_value;
            break;
        }
        case in_button_up_down_up:
        {
            button_state &= ~u_value;
            button_state2 &= ~u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_down_up_down:
        {
            button_state |= u_value;
            button_state2 &= ~u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_down_up_down_up:
        {
            button_state &= ~u_value;
            button_state2 |= u_value;
            button_state3 |= u_value;
            break;
        }
        case in_button_up_down_up_down:
        {
            button_state |= u_value;
            button_state2 |= u_value;
            button_state3 |= u_value;
            break;
        }
        }
    }
};
static_assert(sizeof(c_in_button_state) == 0x20);

void c_movement::fix_cmd_buttons()
{
    if (ctx.base_cmd->forwardmove() > 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_FORWARD, c_in_button_state::e_button_state_t::in_button_down);
    else if (ctx.base_cmd->forwardmove() < 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_BACK, c_in_button_state::e_button_state_t::in_button_down);

    if (ctx.base_cmd->leftmove() > 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_MOVELEFT, c_in_button_state::e_button_state_t::in_button_down);
    else if (ctx.base_cmd->leftmove() < 0.f)
        ctx.user_cmd->buttons.set_button_state(IN_MOVERIGHT, c_in_button_state::e_button_state_t::in_button_down);
}

call fix_cmd_buttons in the CreateMove hook AFTER ALL calls

credits: @King Gizzard
oh save me time from looking at this

// Set button stateusing SetButtonStateFunc = void(__fastcall*)(CUserCmd*, int32_t nButtonIndex, int32_t nState);// Pattern: "48 89 5C 24 ? 48 89 6C 24 ? 48 89 74 24 ? 57 48 83 EC 20 41 8B E8"// Address in pseudocode: sub_2F70C0
 
Назад
Сверху Снизу