C++ Local animations for Lw3

Начинающий
Статус
Оффлайн
Регистрация
18 Мар 2021
Сообщения
68
Реакции[?]
29
Поинты[?]
1K
Лень делать под десинк ,пишите сами

C++:
#include "local_animations.h"

void local_animations::run(ClientFrameStage_t stage)
{
    const float WEIGHT_CYCLE_RESET = 0.0f;
    const int LAYER_FAKE_WEIGHT = 3;
    const int LAYER_FAKE_CYCLE = 3;
    const int LAYER_YAW_WEIGHT = 12;

    if (stage == FRAME_NET_UPDATE_END)
    {
        if (!fakelag::get().condition && key_binds::get().get_key_bind_state(20))
        {
            fake_server_update = false;

            if (g_ctx.local()->m_flSimulationTime() != fake_simulation_time)
            {
                fake_server_update = true;
                fake_simulation_time = g_ctx.local()->m_flSimulationTime();
            }

            reset_anim_layer(LAYER_FAKE_WEIGHT, WEIGHT_CYCLE_RESET);
            reset_anim_layer(LAYER_FAKE_CYCLE, WEIGHT_CYCLE_RESET);
            reset_anim_layer(LAYER_YAW_WEIGHT, WEIGHT_CYCLE_RESET);

            update_fake_animations();
        }
    }
    else if (stage == FRAME_RENDER_START)
    {
        auto animstate =* g_ctx.local()->get_animation_state();

        if (!g_ctx.local()->get_animation_state())
            return;

        real_server_update = false;

        if (g_ctx.local()->m_flSimulationTime() != real_simulation_time)
        {
            real_server_update = true;
            real_simulation_time = g_ctx.local()->m_flSimulationTime();
        }

        reset_anim_layer(LAYER_FAKE_WEIGHT, WEIGHT_CYCLE_RESET);
        reset_anim_layer(LAYER_FAKE_CYCLE, WEIGHT_CYCLE_RESET);
        reset_anim_layer(LAYER_YAW_WEIGHT, WEIGHT_CYCLE_RESET);

        update_local_animations(animstate);

        if (fakelag::get().condition && key_binds::get().get_key_bind_state(20))
        {
            fake_server_update = false;

            if (g_ctx.local()->m_flSimulationTime() != fake_simulation_time)
            {
                fake_server_update = true;
                fake_simulation_time = g_ctx.local()->m_flSimulationTime();
            }

            update_fake_animations();
        }
    }
}

void local_animations::reset_anim_layer(int layer, float weight)
{
    auto& anim_layer = g_ctx.local()->get_animlayers()[layer];
    anim_layer.m_flWeight = weight;
    anim_layer.m_flCycle = weight;
}

void local_animations::update_prediction_animations()
{
    bool alloc = !local_data.prediction_animstate;
    bool change = !alloc && handle != &g_ctx.local()->GetRefEHandle();
    bool reset = !alloc && !change && g_ctx.local()->m_flSpawnTime() != spawntime;
    if (change) {
        m_memalloc()->Free(local_data.prediction_animstate);
    }

    if (reset) {
        util::reset_state(local_data.prediction_animstate);
        spawntime = g_ctx.local()->m_flSpawnTime();
    }

    if (alloc || change) {
        local_data.prediction_animstate = (c_baseplayeranimationstate*)m_memalloc()->Alloc(sizeof(c_baseplayeranimationstate));
        if (local_data.prediction_animstate) {
            util::create_state(local_data.prediction_animstate, g_ctx.local());
        }
        handle = (CBaseHandle*)&g_ctx.local()->GetRefEHandle();
        spawntime = g_ctx.local()->m_flSpawnTime();
    }

    if (!alloc && !change && !reset) {
        float pose_parameter[24];
        std::memcpy(pose_parameter, &g_ctx.local()->m_flPoseParameter(), 24 * sizeof(float));

        AnimationLayer layers[13];
        std::memcpy(layers, g_ctx.local()->get_animlayers(), g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));

        local_data.prediction_animstate->m_pBaseEntity = g_ctx.local();
        util::update_state(local_data.prediction_animstate, ZERO);

        g_ctx.local()->setup_bones_fixed(g_ctx.globals.prediction_matrix, BONE_USED_BY_HITBOX);

        std::memcpy(&g_ctx.local()->m_flPoseParameter(), pose_parameter, 24 * sizeof(float));
        std::memcpy(g_ctx.local()->get_animlayers(), layers, g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
    }
}

void local_animations::update_fake_animations()
{
    //сами пишите, мне лень
}

void local_animations::update_local_animations(c_baseplayeranimationstate& animstate)
{
    if (tickcount != m_globals()->m_tickcount)
    {
        tickcount = m_globals()->m_tickcount;
        update_animlayers();
        update_animstate(animstate);
        update_abs_angles();
        save_pose_parameter();
    }
    else
    {
        animstate.m_iLastClientSideAnimationUpdateFramecount = m_globals()->m_framecount;
    }

    update_goal_feet_yaw(animstate);
    update_abs_angles_in_entity(animstate);
    restore_pose_parameter();
}

void local_animations::update_animlayers()
{
    memcpy(layers, g_ctx.local()->get_animlayers(), g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
}

void local_animations::update_animstate(c_baseplayeranimationstate& animstate)
{
    if (local_data.animstate)
    {
        animstate.m_fDuckAmount = local_data.animstate->m_fDuckAmount;
    }

    animstate.m_iLastClientSideAnimationUpdateFramecount = 0;
    util::update_state(&animstate, local_animations::get().local_data.fake_angles);
}

void local_animations::update_abs_angles()
{
    if (real_server_update)
    {
        abs_angles = local_animations::get().local_data.real_angles.y;
    }
    else
    {
        abs_angles = antiaim::get().condition(g_ctx.get_command()) ? abs_angles : local_animations::get().local_data.real_angles.y;
    }
}

void local_animations::save_pose_parameter()
{
    memcpy(pose_parameter, &g_ctx.local()->m_flPoseParameter(), 24 * sizeof(float));
}

void local_animations::update_goal_feet_yaw(c_baseplayeranimationstate& animstate)
{
    animstate.m_flGoalFeetYaw = abs_angles;
}

void local_animations::update_abs_angles_in_entity(c_baseplayeranimationstate& animstate)
{
    g_ctx.local()->set_abs_angles(Vector(0.0f, abs_angles, 0.0f));
    memcpy(g_ctx.local()->get_animlayers(), layers, g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
}

void local_animations::restore_pose_parameter()
{
    memcpy(&g_ctx.local()->m_flPoseParameter(), pose_parameter, 24 * sizeof(float));
}
 
ЧВК EB_LAN
Эксперт
Статус
Оффлайн
Регистрация
26 Янв 2021
Сообщения
1,567
Реакции[?]
522
Поинты[?]
185K
Лень делать под десинк ,пишите сами

C++:
#include "local_animations.h"

void local_animations::run(ClientFrameStage_t stage)
{
    const float WEIGHT_CYCLE_RESET = 0.0f;
    const int LAYER_FAKE_WEIGHT = 3;
    const int LAYER_FAKE_CYCLE = 3;
    const int LAYER_YAW_WEIGHT = 12;

    if (stage == FRAME_NET_UPDATE_END)
    {
        if (!fakelag::get().condition && key_binds::get().get_key_bind_state(20))
        {
            fake_server_update = false;

            if (g_ctx.local()->m_flSimulationTime() != fake_simulation_time)
            {
                fake_server_update = true;
                fake_simulation_time = g_ctx.local()->m_flSimulationTime();
            }

            reset_anim_layer(LAYER_FAKE_WEIGHT, WEIGHT_CYCLE_RESET);
            reset_anim_layer(LAYER_FAKE_CYCLE, WEIGHT_CYCLE_RESET);
            reset_anim_layer(LAYER_YAW_WEIGHT, WEIGHT_CYCLE_RESET);

            update_fake_animations();
        }
    }
    else if (stage == FRAME_RENDER_START)
    {
        auto animstate =* g_ctx.local()->get_animation_state();

        if (!g_ctx.local()->get_animation_state())
            return;

        real_server_update = false;

        if (g_ctx.local()->m_flSimulationTime() != real_simulation_time)
        {
            real_server_update = true;
            real_simulation_time = g_ctx.local()->m_flSimulationTime();
        }

        reset_anim_layer(LAYER_FAKE_WEIGHT, WEIGHT_CYCLE_RESET);
        reset_anim_layer(LAYER_FAKE_CYCLE, WEIGHT_CYCLE_RESET);
        reset_anim_layer(LAYER_YAW_WEIGHT, WEIGHT_CYCLE_RESET);

        update_local_animations(animstate);

        if (fakelag::get().condition && key_binds::get().get_key_bind_state(20))
        {
            fake_server_update = false;

            if (g_ctx.local()->m_flSimulationTime() != fake_simulation_time)
            {
                fake_server_update = true;
                fake_simulation_time = g_ctx.local()->m_flSimulationTime();
            }

            update_fake_animations();
        }
    }
}

void local_animations::reset_anim_layer(int layer, float weight)
{
    auto& anim_layer = g_ctx.local()->get_animlayers()[layer];
    anim_layer.m_flWeight = weight;
    anim_layer.m_flCycle = weight;
}

void local_animations::update_prediction_animations()
{
    bool alloc = !local_data.prediction_animstate;
    bool change = !alloc && handle != &g_ctx.local()->GetRefEHandle();
    bool reset = !alloc && !change && g_ctx.local()->m_flSpawnTime() != spawntime;
    if (change) {
        m_memalloc()->Free(local_data.prediction_animstate);
    }

    if (reset) {
        util::reset_state(local_data.prediction_animstate);
        spawntime = g_ctx.local()->m_flSpawnTime();
    }

    if (alloc || change) {
        local_data.prediction_animstate = (c_baseplayeranimationstate*)m_memalloc()->Alloc(sizeof(c_baseplayeranimationstate));
        if (local_data.prediction_animstate) {
            util::create_state(local_data.prediction_animstate, g_ctx.local());
        }
        handle = (CBaseHandle*)&g_ctx.local()->GetRefEHandle();
        spawntime = g_ctx.local()->m_flSpawnTime();
    }

    if (!alloc && !change && !reset) {
        float pose_parameter[24];
        std::memcpy(pose_parameter, &g_ctx.local()->m_flPoseParameter(), 24 * sizeof(float));

        AnimationLayer layers[13];
        std::memcpy(layers, g_ctx.local()->get_animlayers(), g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));

        local_data.prediction_animstate->m_pBaseEntity = g_ctx.local();
        util::update_state(local_data.prediction_animstate, ZERO);

        g_ctx.local()->setup_bones_fixed(g_ctx.globals.prediction_matrix, BONE_USED_BY_HITBOX);

        std::memcpy(&g_ctx.local()->m_flPoseParameter(), pose_parameter, 24 * sizeof(float));
        std::memcpy(g_ctx.local()->get_animlayers(), layers, g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
    }
}

void local_animations::update_fake_animations()
{
    //сами пишите, мне лень
}

void local_animations::update_local_animations(c_baseplayeranimationstate& animstate)
{
    if (tickcount != m_globals()->m_tickcount)
    {
        tickcount = m_globals()->m_tickcount;
        update_animlayers();
        update_animstate(animstate);
        update_abs_angles();
        save_pose_parameter();
    }
    else
    {
        animstate.m_iLastClientSideAnimationUpdateFramecount = m_globals()->m_framecount;
    }

    update_goal_feet_yaw(animstate);
    update_abs_angles_in_entity(animstate);
    restore_pose_parameter();
}

void local_animations::update_animlayers()
{
    memcpy(layers, g_ctx.local()->get_animlayers(), g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
}

void local_animations::update_animstate(c_baseplayeranimationstate& animstate)
{
    if (local_data.animstate)
    {
        animstate.m_fDuckAmount = local_data.animstate->m_fDuckAmount;
    }

    animstate.m_iLastClientSideAnimationUpdateFramecount = 0;
    util::update_state(&animstate, local_animations::get().local_data.fake_angles);
}

void local_animations::update_abs_angles()
{
    if (real_server_update)
    {
        abs_angles = local_animations::get().local_data.real_angles.y;
    }
    else
    {
        abs_angles = antiaim::get().condition(g_ctx.get_command()) ? abs_angles : local_animations::get().local_data.real_angles.y;
    }
}

void local_animations::save_pose_parameter()
{
    memcpy(pose_parameter, &g_ctx.local()->m_flPoseParameter(), 24 * sizeof(float));
}

void local_animations::update_goal_feet_yaw(c_baseplayeranimationstate& animstate)
{
    animstate.m_flGoalFeetYaw = abs_angles;
}

void local_animations::update_abs_angles_in_entity(c_baseplayeranimationstate& animstate)
{
    g_ctx.local()->set_abs_angles(Vector(0.0f, abs_angles, 0.0f));
    memcpy(g_ctx.local()->get_animlayers(), layers, g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
}

void local_animations::restore_pose_parameter()
{
    memcpy(&g_ctx.local()->m_flPoseParameter(), pose_parameter, 24 * sizeof(float));
}
скинь остальным хомякам .h файл а то они явно будут просить его до талого
 
Забаненный
Статус
Оффлайн
Регистрация
14 Июл 2020
Сообщения
50
Реакции[?]
7
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
скинь остальным хомякам .h файл а то они явно будут просить его до талого
 
Начинающий
Статус
Оффлайн
Регистрация
17 Июл 2022
Сообщения
51
Реакции[?]
4
Поинты[?]
1K
Начинающий
Статус
Оффлайн
Регистрация
18 Мар 2021
Сообщения
68
Реакции[?]
29
Поинты[?]
1K
скинь остальным хомякам .h файл а то они явно будут просить его до талого
C++:
#include "..\..\includes.hpp"

struct Local_data
{
    c_baseplayeranimationstate* prediction_animstate = nullptr;
    c_baseplayeranimationstate* animstate = nullptr;

    Vector stored_real_angles = ZERO;
    Vector real_angles = ZERO;
    Vector fake_angles = ZERO;
};

class local_animations : public singleton <local_animations>
{
    bool real_server_update = false;
    bool fake_server_update = false;

    float real_simulation_time = 0.0f;
    float fake_simulation_time = 0.0f;

    CBaseHandle* handle = nullptr;

    float spawntime = 0.0f;
    float tickcount = 0.0f;

    float abs_angles = 0.0f;
    float pose_parameter[24];

    AnimationLayer layers[13];

    void update_fake_animations();
    void update_local_animations(c_baseplayeranimationstate& animstate);
public:
    Local_data local_data;

    void run(ClientFrameStage_t stage);
    void reset_anim_layer(int layer, float weight);
    void update_prediction_animations();
    void update_animlayers();
    void update_animstate(c_baseplayeranimationstate& animstate);
    void update_abs_angles();
    void save_pose_parameter();
    void update_goal_feet_yaw(c_baseplayeranimationstate& animstate);
    void update_abs_angles_in_entity(c_baseplayeranimationstate& animstate);
    void restore_pose_parameter();
};
 
Начинающий
Статус
Оффлайн
Регистрация
7 Дек 2022
Сообщения
24
Реакции[?]
5
Поинты[?]
0
C++:
#include "..\..\includes.hpp"

struct Local_data
{
    c_baseplayeranimationstate* prediction_animstate = nullptr;
    c_baseplayeranimationstate* animstate = nullptr;

    Vector stored_real_angles = ZERO;
    Vector real_angles = ZERO;
    Vector fake_angles = ZERO;
};

class local_animations : public singleton <local_animations>
{
    bool real_server_update = false;
    bool fake_server_update = false;

    float real_simulation_time = 0.0f;
    float fake_simulation_time = 0.0f;

    CBaseHandle* handle = nullptr;

    float spawntime = 0.0f;
    float tickcount = 0.0f;

    float abs_angles = 0.0f;
    float pose_parameter[24];

    AnimationLayer layers[13];

    void update_fake_animations();
    void update_local_animations(c_baseplayeranimationstate& animstate);
public:
    Local_data local_data;

    void run(ClientFrameStage_t stage);
    void reset_anim_layer(int layer, float weight);
    void update_prediction_animations();
    void update_animlayers();
    void update_animstate(c_baseplayeranimationstate& animstate);
    void update_abs_angles();
    void save_pose_parameter();
    void update_goal_feet_yaw(c_baseplayeranimationstate& animstate);
    void update_abs_angles_in_entity(c_baseplayeranimationstate& animstate);
    void restore_pose_parameter();
};
Кинь ещё парт с крейт мува на всякий) раз уж на то пошло))
 
like amiri in my mind
Пользователь
Статус
Оффлайн
Регистрация
4 Дек 2022
Сообщения
308
Реакции[?]
54
Поинты[?]
1K
а ты в хуках ниче не делал? а то странно как то
 
Участник
Статус
Оффлайн
Регистрация
27 Фев 2019
Сообщения
1,125
Реакции[?]
395
Поинты[?]
50K
1. Ухудшена читабельность
2. Не вижу отличий в этом говне, в отличии от другого говна, которое раньше постили
3. Куча ненужных комментариев, описывающих лень авторов

10/10 говноедов
 
Начинающий
Статус
Оффлайн
Регистрация
22 Сен 2021
Сообщения
37
Реакции[?]
10
Поинты[?]
3K
Лень делать под десинк ,пишите сами

C++:
#include "local_animations.h"

void local_animations::run(ClientFrameStage_t stage)
{
    const float WEIGHT_CYCLE_RESET = 0.0f;
    const int LAYER_FAKE_WEIGHT = 3;
    const int LAYER_FAKE_CYCLE = 3;
    const int LAYER_YAW_WEIGHT = 12;

    if (stage == FRAME_NET_UPDATE_END)
    {
        if (!fakelag::get().condition && key_binds::get().get_key_bind_state(20))
        {
            fake_server_update = false;

            if (g_ctx.local()->m_flSimulationTime() != fake_simulation_time)
            {
                fake_server_update = true;
                fake_simulation_time = g_ctx.local()->m_flSimulationTime();
            }

            reset_anim_layer(LAYER_FAKE_WEIGHT, WEIGHT_CYCLE_RESET);
            reset_anim_layer(LAYER_FAKE_CYCLE, WEIGHT_CYCLE_RESET);
            reset_anim_layer(LAYER_YAW_WEIGHT, WEIGHT_CYCLE_RESET);

            update_fake_animations();
        }
    }
    else if (stage == FRAME_RENDER_START)
    {
        auto animstate =* g_ctx.local()->get_animation_state();

        if (!g_ctx.local()->get_animation_state())
            return;

        real_server_update = false;

        if (g_ctx.local()->m_flSimulationTime() != real_simulation_time)
        {
            real_server_update = true;
            real_simulation_time = g_ctx.local()->m_flSimulationTime();
        }

        reset_anim_layer(LAYER_FAKE_WEIGHT, WEIGHT_CYCLE_RESET);
        reset_anim_layer(LAYER_FAKE_CYCLE, WEIGHT_CYCLE_RESET);
        reset_anim_layer(LAYER_YAW_WEIGHT, WEIGHT_CYCLE_RESET);

        update_local_animations(animstate);

        if (fakelag::get().condition && key_binds::get().get_key_bind_state(20))
        {
            fake_server_update = false;

            if (g_ctx.local()->m_flSimulationTime() != fake_simulation_time)
            {
                fake_server_update = true;
                fake_simulation_time = g_ctx.local()->m_flSimulationTime();
            }

            update_fake_animations();
        }
    }
}

void local_animations::reset_anim_layer(int layer, float weight)
{
    auto& anim_layer = g_ctx.local()->get_animlayers()[layer];
    anim_layer.m_flWeight = weight;
    anim_layer.m_flCycle = weight;
}

void local_animations::update_prediction_animations()
{
    bool alloc = !local_data.prediction_animstate;
    bool change = !alloc && handle != &g_ctx.local()->GetRefEHandle();
    bool reset = !alloc && !change && g_ctx.local()->m_flSpawnTime() != spawntime;
    if (change) {
        m_memalloc()->Free(local_data.prediction_animstate);
    }

    if (reset) {
        util::reset_state(local_data.prediction_animstate);
        spawntime = g_ctx.local()->m_flSpawnTime();
    }

    if (alloc || change) {
        local_data.prediction_animstate = (c_baseplayeranimationstate*)m_memalloc()->Alloc(sizeof(c_baseplayeranimationstate));
        if (local_data.prediction_animstate) {
            util::create_state(local_data.prediction_animstate, g_ctx.local());
        }
        handle = (CBaseHandle*)&g_ctx.local()->GetRefEHandle();
        spawntime = g_ctx.local()->m_flSpawnTime();
    }

    if (!alloc && !change && !reset) {
        float pose_parameter[24];
        std::memcpy(pose_parameter, &g_ctx.local()->m_flPoseParameter(), 24 * sizeof(float));

        AnimationLayer layers[13];
        std::memcpy(layers, g_ctx.local()->get_animlayers(), g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));

        local_data.prediction_animstate->m_pBaseEntity = g_ctx.local();
        util::update_state(local_data.prediction_animstate, ZERO);

        g_ctx.local()->setup_bones_fixed(g_ctx.globals.prediction_matrix, BONE_USED_BY_HITBOX);

        std::memcpy(&g_ctx.local()->m_flPoseParameter(), pose_parameter, 24 * sizeof(float));
        std::memcpy(g_ctx.local()->get_animlayers(), layers, g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
    }
}

void local_animations::update_fake_animations()
{
    //сами пишите, мне лень
}

void local_animations::update_local_animations(c_baseplayeranimationstate& animstate)
{
    if (tickcount != m_globals()->m_tickcount)
    {
        tickcount = m_globals()->m_tickcount;
        update_animlayers();
        update_animstate(animstate);
        update_abs_angles();
        save_pose_parameter();
    }
    else
    {
        animstate.m_iLastClientSideAnimationUpdateFramecount = m_globals()->m_framecount;
    }

    update_goal_feet_yaw(animstate);
    update_abs_angles_in_entity(animstate);
    restore_pose_parameter();
}

void local_animations::update_animlayers()
{
    memcpy(layers, g_ctx.local()->get_animlayers(), g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
}

void local_animations::update_animstate(c_baseplayeranimationstate& animstate)
{
    if (local_data.animstate)
    {
        animstate.m_fDuckAmount = local_data.animstate->m_fDuckAmount;
    }

    animstate.m_iLastClientSideAnimationUpdateFramecount = 0;
    util::update_state(&animstate, local_animations::get().local_data.fake_angles);
}

void local_animations::update_abs_angles()
{
    if (real_server_update)
    {
        abs_angles = local_animations::get().local_data.real_angles.y;
    }
    else
    {
        abs_angles = antiaim::get().condition(g_ctx.get_command()) ? abs_angles : local_animations::get().local_data.real_angles.y;
    }
}

void local_animations::save_pose_parameter()
{
    memcpy(pose_parameter, &g_ctx.local()->m_flPoseParameter(), 24 * sizeof(float));
}

void local_animations::update_goal_feet_yaw(c_baseplayeranimationstate& animstate)
{
    animstate.m_flGoalFeetYaw = abs_angles;
}

void local_animations::update_abs_angles_in_entity(c_baseplayeranimationstate& animstate)
{
    g_ctx.local()->set_abs_angles(Vector(0.0f, abs_angles, 0.0f));
    memcpy(g_ctx.local()->get_animlayers(), layers, g_ctx.local()->animlayer_count() * sizeof(AnimationLayer));
}

void local_animations::restore_pose_parameter()
{
    memcpy(&g_ctx.local()->m_flPoseParameter(), pose_parameter, 24 * sizeof(float));
}
complete dogshit please quit im tired of seeing same old shit code that isnt good even tho the proper one is public
 
like amiri in my mind
Пользователь
Статус
Оффлайн
Регистрация
4 Дек 2022
Сообщения
308
Реакции[?]
54
Поинты[?]
1K
Сверху Снизу