Gg

Начинающий
Статус
Оффлайн
Регистрация
14 Янв 2022
Сообщения
21
Реакции[?]
1
Поинты[?]
0
Всем привет, что мне нужно пофиксить под кс есле у Animation System у всех в том числе и ботов пич 0 сурс legendware
 
Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Всем привет, что мне нужно пофиксить под кс есле у Animation System у всех в том числе и ботов пич 0 сурс legendware
ахах найс анимфикс хули ну блять мы же не знаем что у тебя напащено в анимфиксе
 
get good get legendware
Участник
Статус
Оффлайн
Регистрация
22 Сен 2020
Сообщения
437
Реакции[?]
201
Поинты[?]
48K
C++:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include "animation_system.h"
#include "..\misc\misc.h"
#include "..\misc\logs.h"

std::deque <adjust_data> player_records[65];

void lagcompensation::fsn(ClientFrameStage_t stage)
{
    if (stage != FRAME_NET_UPDATE_END)
        return;

    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled)
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++)
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (e == g_ctx.local())
            continue;

        if (!valid(i, e))
            continue;

        auto time_delta = abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount);

        if (time_delta > 1.0f / m_globals()->m_intervalpertick)
            continue;

        if (player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime())
        {
            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
                for (auto& record : player_records[i])
                    record.invalid = true;

            player_records[i].emplace_front(adjust_data());
            update_player_animations(e);

            while (player_records[i].size() > 32)
                player_records[i].pop_back();
        }
    }
}

bool lagcompensation::valid(int i, player_t* e)
{
    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled || !e->valid(false))
    {
        if (!e->is_alive())
        {
            is_dormant[i] = false;
            //player_resolver[i].reset();

            //g_ctx.globals.fired_shots[i] = 0;
            //g_ctx.globals.missed_shots[i] = 0;
        }
        else if (e->IsDormant())
            is_dormant[i] = true;

        //player_records[i].clear();
        return false;
    }

    return true;
}




float build_server_abs_yaw(player_t* m_player, float angle, int n)
{
    Vector velocity = m_player->m_vecVelocity();
    auto anim_state = m_player->get_animation_state();
    float m_flEyeYaw = angle;
    float m_flGoalFeetYaw = 0.f;

    float eye_feet_delta = math::AngleDiff(m_flEyeYaw, m_flGoalFeetYaw);

    static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
        Vector delta = a - b;
        float delta_length = delta.Length();

        if (delta_length <= min_delta)
        {
            Vector result;

            if (-min_delta <= delta_length)
                return a;
            else
            {
                float iradius = 1.0f / (delta_length + FLT_EPSILON);
                return b - ((delta * iradius) * min_delta);
            }
        }
        else
        {
            float iradius = 1.0f / (delta_length + FLT_EPSILON);
            return b + ((delta * iradius) * min_delta);
        }
    };

    float spd = velocity.LengthSqr();

    if (spd > std::powf(1.2f * 260.0f, 2.f))
    {
        Vector velocity_normalized = velocity.Normalized();
        velocity = velocity_normalized * (1.2f * 260.0f);
    }

    float m_flChokedTime = anim_state->m_flLastClientSideAnimationUpdateTime;
    float v25 = std::clamp(m_player->m_flDuckAmount() + anim_state->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
    float v26 = anim_state->m_fDuckAmount;
    float v27 = m_flChokedTime * 6.0f;
    float v28;


    if ((v25 - v26) <= v27) {
        if (-v27 <= (v25 - v26))
            v28 = v25;
        else
            v28 = v26 - v27;
    }
    else {
        v28 = v26 + v27;
    }

    float flDuckAmount = std::clamp(v28, 0.0f, 1.0f);

    Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, m_player->m_vecVelocity());
    float speed = std::fminf(animationVelocity.Length(), 260.0f);

    float flMaxMovementSpeed = 260.0f;

    weapon_t* pWeapon = m_player->m_hActiveWeapon();

    if (pWeapon && pWeapon->get_csweapon_info())
        flMaxMovementSpeed = std::fmaxf(pWeapon->get_csweapon_info()->flMaxPlayerSpeedAlt, 0.001f);

    float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
    float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);

    flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);

    float flYawModifier = (((anim_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * flRunningSpeed) + 1.0f;

    if (flDuckAmount > 0.0f)
    {
        float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
        flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
    }

    const float v60 = -58.0f;
    const float v61 = 58.0f;

    /*
    float flMaxBodyYaw = *reinterpret_cast<float*>(&animState->pad10[512]);
    float flMinBodyYaw = *reinterpret_cast<float*>(&animState->pad10[516]);
    */

    float flMinYawModifier = v60 * flYawModifier;
    float flMaxYawModifier = v61 * flYawModifier;

    if (eye_feet_delta <= flMaxYawModifier)
    {
        if (flMinYawModifier > eye_feet_delta)
            m_flGoalFeetYaw = fabs(flMinYawModifier) + m_flEyeYaw;
    }
    else
    {
        m_flGoalFeetYaw = m_flEyeYaw - fabs(flMaxYawModifier);
    }

    math::normalize_yaw(m_flGoalFeetYaw);

    if (speed > 0.1f || fabs(velocity.z) > 100.0f)
    {
        m_flGoalFeetYaw = math::ApproachAngle(
            m_flEyeYaw,
            m_flGoalFeetYaw,
            ((anim_state->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
            * m_flChokedTime);
    }
    else
    {
        m_flGoalFeetYaw = math::ApproachAngle(
            m_player->m_flLowerBodyYawTarget(),
            m_flGoalFeetYaw,
            m_flChokedTime * 100.0f);
    }

    if (n == 1)
        return m_flEyeYaw + flMinYawModifier;
    else if (n == 2)
        return m_flEyeYaw + flMaxYawModifier;
    else if (n == 3)
        return m_flGoalFeetYaw;

}
void lagcompensation::update_player_animations(player_t* e)
{
    auto animstate = e->get_animation_state();

    if (!animstate)
        return;

    player_info_t player_info;

    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
        return;

    auto records = &player_records[e->EntIndex()];

    if (records->empty())
        return;

    adjust_data* previous_record = nullptr;

    if (records->size() >= 2)
        previous_record = &records->at(1);

    auto record = &records->front();

    AnimationLayer animlayers[15];

    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
    auto backup_duck_amount = e->m_flDuckAmount();
    auto backup_flags = e->m_fFlags();
    auto backup_eflags = e->m_iEFlags();

    auto backup_curtime = m_globals()->m_curtime;
    auto backup_frametime = m_globals()->m_frametime;
    auto backup_realtime = m_globals()->m_realtime;
    auto backup_framecount = m_globals()->m_framecount;
    auto backup_tickcount = m_globals()->m_tickcount;
    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;

    m_globals()->m_curtime = e->m_flSimulationTime();
    m_globals()->m_frametime = m_globals()->m_intervalpertick;


    if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(record->flags & FL_ONGROUND))
            {
                velocity = (record->origin - previous_record->origin) / record->simulation_time;

                float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP].m_flWeight;

                if (flWeight > 0.0f)
                {
                    float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
                    float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;

                    if (flPreviousRate == flCurrentRate)
                    {
                        int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
                        int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;

                        if (iPreviousSequence == iCurrentSequence)
                        {
                            float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;

                            if (flSpeedNormalized > 0.0f)
                            {
                                float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();

                                if (flSpeed > 0.0f)
                                {
                                    if (velocity.Length2D() > 0.0f)
                                    {
                                        velocity.x /= velocity.Length2D() / flSpeed;
                                        velocity.y /= velocity.Length2D() / flSpeed;
                                    }
                                }
                            }
                        }
                    }
                }

                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
                velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
            }
            else
                velocity.z = 0.0f;
        }
    }
    else
    {
        //record->shot = record->last_shot_time == record->simulation_time;
    }

    e->m_iEFlags() &= ~0x1800;

    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
        e->m_vecVelocity().Zero();

    e->m_vecAbsVelocity() = e->m_vecVelocity();
    e->m_bClientSideAnimation() = true;

    if (is_dormant[e->EntIndex()])
    {
        is_dormant[e->EntIndex()] = false;

        if (e->m_fFlags() & FL_ONGROUND)
        {
            animstate->m_bOnGround = true;
            animstate->m_bInHitGroundAnimation = false;
        }

        animstate->time_since_in_air() = 0.0f;
        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    }

    auto updated_animations = false;

    c_baseplayeranimationstate state;
    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));

    if (previous_record)
    {
        memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));

        auto ticks_chocked = 1;
        auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);

        if (simulation_ticks > 0 && simulation_ticks < 31)
            ticks_chocked = simulation_ticks;

        if (ticks_chocked > 1)
        {
            auto land_time = 0.0f;
            auto land_in_cycle = false;
            auto is_landed = false;
            auto on_ground = false;

            if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
            {
                land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
                land_in_cycle = land_time >= previous_record->simulation_time;
            }

            auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;

            for (auto i = 0; i < ticks_chocked; ++i)
            {
                auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);

                if (duck_amount_per_tick)
                    e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;

                on_ground = e->m_fFlags() & FL_ONGROUND;

                if (land_in_cycle && !is_landed)
                {
                    if (land_time <= simulated_time)
                    {
                        is_landed = true;
                        on_ground = true;
                    }
                    else
                        on_ground = previous_record->flags & FL_ONGROUND;
                }

                if (on_ground)
                    e->m_fFlags() |= FL_ONGROUND;
                else
                    e->m_fFlags() &= ~FL_ONGROUND;

                auto simulated_ticks = TIME_TO_TICKS(simulated_time);

                m_globals()->m_realtime = simulated_time;
                m_globals()->m_curtime = simulated_time;
                m_globals()->m_framecount = simulated_ticks;
                m_globals()->m_tickcount = simulated_ticks;
                m_globals()->m_interpolation_amount = 0.0f;

                g_ctx.globals.updating_animation = true;
                e->update_clientside_animation();
                g_ctx.globals.updating_animation = false;

                m_globals()->m_realtime = backup_realtime;
                m_globals()->m_curtime = backup_curtime;
                m_globals()->m_framecount = backup_framecount;
                m_globals()->m_tickcount = backup_tickcount;
                m_globals()->m_interpolation_amount = backup_interpolation_amount;

                updated_animations = true;
            }
        }
    }

    if (!updated_animations)
    {
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
    }

    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));

    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
    {
        e->invalidate_physics_recursive(8);

        AnimationLayer backup_layers[15];
        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));

        switch (matrix)
        {
        case MAIN:
            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
            break;
        case NONE:
            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
            break;
        case FIRST:
            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
            break;
        case SECOND:
            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
            break;
        }

        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
    };

    if (g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled)
    {
        player_resolver[e->EntIndex()].initialize_yaw(e);

        /*rebuild setup velocity for more accurate rotations for the resolver and safepoints*/
        float left =  g_ctx.globals.left;
        float right = g_ctx.globals.right;
        float middle = g_ctx.globals.middle;
        // ------ \\

        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));



        // --- first --- \\

        animstate->m_flGoalFeetYaw = middle;
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, NONE);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[0] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\



        // --- second --- \\

        animstate->m_flGoalFeetYaw = math::normalize_yaw(right + e->EntIndex());
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, FIRST);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[2] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[2], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\




        // --- third --- \\

        animstate->m_flGoalFeetYaw = math::normalize_yaw(left + e->EntIndex());
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, SECOND);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[1] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\


        


        player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
        player_resolver[e->EntIndex()].resolve();

        auto eye = e->m_angEyeAngles().y;
        auto idx = e->EntIndex();
        switch (record->side)
        {
        case RESOLVER_ORIGINAL:
            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
            g_ctx.globals.mlog1[idx] = previous_goal_feet_yaw[e->EntIndex()];
            break;
        case RESOLVER_ZERO:
            animstate->m_flGoalFeetYaw = middle;
            g_ctx.globals.mlog1[idx] = middle;
            break;
        case RESOLVER_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(left + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(left);
            break;
        case RESOLVER_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(right + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(right);
            break;
        case RESOLVER_LOW_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(max(-10.0f , left * 0.5) + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(max(-10.0f, left * 0.5));
            break;
        case RESOLVER_LOW_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(min(10.0f, right * 0.5) + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(min(10.0f, right * 0.5));
            break;
        case RESOLVER_ON_SHOT:
            animstate->m_flGoalFeetYaw = middle;
            g_ctx.globals.mlog1[idx] = middle;
            break;
        }


        /*switch (record->side)
        {
        case RESOLVER_ORIGINAL:
            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
            break;
        case RESOLVER_ZERO:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
            break;
        case RESOLVER_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + e->get_max_desync_delta());
            break;
        case RESOLVER_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - e->get_max_desync_delta());
            break;
        case RESOLVER_LOW_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 25);
            break;
        case RESOLVER_LOW_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 25);
            break;
        case RESOLVER_ON_SHOT:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
            break;
        }*/

        //e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();

    }

    g_ctx.globals.updating_animation = true;
    e->update_clientside_animation();
    g_ctx.globals.updating_animation = false;

    setup_matrix(e, animlayers, MAIN);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    setup_matrix(e, animlayers, FIRST);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.first, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    setup_matrix(e, animlayers, SECOND);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.second, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    m_globals()->m_curtime = backup_curtime;
    m_globals()->m_frametime = backup_frametime;

    e->m_flLowerBodyYawTarget() = backup_lower_body_yaw_target;
    e->m_flDuckAmount() = backup_duck_amount;
    e->m_fFlags() = backup_flags;
    e->m_iEFlags() = backup_eflags;

    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(player_resolver[e->EntIndex()].previous_layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
C++:
#pragma once

#include "..\..\includes.hpp"
#include "..\..\sdk\structs.hpp"


enum
{
    MAIN,
    NONE,
    FIRST,
    SECOND
};

enum resolver_type
{
    ORIGINAL,
    BRUTEFORCE,
    LBY,
    LAYERS,
    TRACE,
    DIRECTIONAL,
    ENGINE,
    FREESTAND,
    NON_RESOLVED
};
enum resolver_side
{
    RESOLVER_ORIGINAL,
    RESOLVER_ZERO,
    RESOLVER_FIRST,
    RESOLVER_SECOND,
    RESOLVER_LOW_FIRST,
    RESOLVER_LOW_SECOND,
    RESOLVER_ON_SHOT
};

enum modes
{
    NONE_SIDE,
    AIR,
    SLOW_WALKING,
    SLOW_WALKING_MAX,
    MOVING,
    STANDING,
    FREESTANDING
};

enum get_side_move
{
    MIDDLE,
    LEFT,
    RIGHT,
    NONE_CUR
};
enum curdelta
{
    LOW_DELTA,
    MAX_DELTA
};
enum curstate
{
    NOT_FLIPPED,
    FLIPPED
};

enum animstate_layer_t
{
    ANIMATION_LAYER_AIMMATRIX = 0,
    ANIMATION_LAYER_WEAPON_ACTION,
    ANIMATION_LAYER_WEAPON_ACTION_RECROUCH,
    ANIMATION_LAYER_ADJUST,
    ANIMATION_LAYER_MOVEMENT_JUMP_OR_FALL,
    ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB,
    ANIMATION_LAYER_MOVEMENT_MOVE,
    ANIMATION_LAYER_MOVEMENT_STRAFECHANGE,
    ANIMATION_LAYER_WHOLE_BODY,
    ANIMATION_LAYER_FLASHED,
    ANIMATION_LAYER_FLINCH,
    ANIMATION_LAYER_ALIVELOOP,
    ANIMATION_LAYER_LEAN,
    ANIMATION_LAYER_COUNT,
};

struct matrixes
{
    matrix3x4_t main[MAXSTUDIOBONES];
    matrix3x4_t zero[MAXSTUDIOBONES];
    matrix3x4_t first[MAXSTUDIOBONES];
    matrix3x4_t second[MAXSTUDIOBONES];
};

class adjust_data;

class CResolver
{
    player_t* player = nullptr;
    adjust_data* player_record = nullptr;

    bool side = false;
    bool fake = false;
    bool was_first_bruteforce = false;
    bool was_second_bruteforce = false;

    float lock_side = 0.0f;
    float original_goal_feet_yaw = 0.0f;
    float original_pitch = 0.0f;

public:
    //void initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch);
    void initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch);
    void initialize_yaw(player_t* e);
    void reset();


    //bool is_choking(player_t* entity);
    bool ValidMove();
    void get_side_moving();
    void layer_test();
    void get_side_standing();
    void detect_side();
    void get_side_trace();
    float GetChokedPackets();
    bool DesyncDetect();
    bool update_walk_data();
    void setmode();
    bool MatchShot();
    bool is_slow_walking();
    void AntiFreestand();
    bool IsAdjustingBalances(AnimationLayer* record, AnimationLayer* layer);

    float ResolveShot();

    void final_detection();

    float build_yaw(player_t* player, float angle, int n);

    void resolve();


    AnimationLayer resolver_layers[3][15];
    AnimationLayer previous_layers[15];
    float resolver_goal_feet_yaw[3];

    resolver_side last_side = RESOLVER_ORIGINAL;
    float build_server_abs_yaw();
};


class adjust_data
{
public:
    player_t* player;
    int i;

    AnimationLayer layers[15];
    AnimationLayer side_layers[3][15];
    matrixes matrixes_data;
    get_side_move curSide;
    modes curMode;
    resolver_type type;
    resolver_side side;
    curdelta curdelta;
    curstate curstate;
    bool flipped_s;
    bool invalid;
    bool immune;
    bool dormant;
    bool bot;
    


    int flags;
    int bone_count;

    float simulation_time;
    float duck_amount;
    float lby;
    float left_side;
    float right_side;
    float maxrotation;
    float eyeyaw;

    Vector angles;
    Vector abs_angles;
    Vector velocity;
    Vector origin;
    Vector mins;
    Vector maxs;

    matrix3x4_t leftmatrixes[128] = {};
    matrix3x4_t rightmatrixes[128] = {};

    std::array<float, 24> left_poses = {};
    std::array<float, 24> right_poses = {};

    adjust_data()
    {
        reset();
    }

    void reset()
    {
        player = nullptr;
        i = -1;

        type = ORIGINAL;
        side = RESOLVER_ORIGINAL;

        invalid = false;
        immune = false;
        dormant = false;
        bot = false;

        flags = 0;
        bone_count = 0;

        simulation_time = 0.0f;
        duck_amount = 0.0f;
        lby = 0.0f;

        angles.Zero();
        abs_angles.Zero();
        velocity.Zero();
        origin.Zero();
        mins.Zero();
        maxs.Zero();
    }

    adjust_data(player_t* e, bool store = true)
    {
        type = ORIGINAL;
        side = RESOLVER_ORIGINAL;

        invalid = false;
        store_data(e, store);
    }

    void store_data(player_t* e, bool store = true)
    {
        if (!e->is_alive())
            return;
    
        player = e;
        i = player->EntIndex();

        if (store)
        {
            memcpy(layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
            memcpy(matrixes_data.main, player->m_CachedBoneData().Base(), player->m_CachedBoneData().Count() * sizeof(matrix3x4_t));
        }

        immune = player->m_bGunGameImmunity() || player->m_fFlags() & FL_FROZEN;
        dormant = player->IsDormant();

        bot = false;

        flags = player->m_fFlags();
        bone_count = player->m_CachedBoneData().Count();

        simulation_time = player->m_flSimulationTime();
        duck_amount = player->m_flDuckAmount();
        lby = player->m_flLowerBodyYawTarget();

        angles = player->m_angEyeAngles();
        abs_angles = player->GetAbsAngles();
        velocity = player->m_vecVelocity();
        origin = player->m_vecOrigin();
        mins = player->GetCollideable()->OBBMins();
        maxs = player->GetCollideable()->OBBMaxs();
    }

    void adjust_player()
    {
        if (!valid(false))
            return;

        memcpy(player->get_animlayers(), layers, player->animlayer_count() * sizeof(AnimationLayer));
        memcpy(player->m_CachedBoneData().Base(), matrixes_data.main, player->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

        player->m_fFlags() = flags;
        player->m_CachedBoneData().m_Size = bone_count;

        player->m_flSimulationTime() = simulation_time;
        player->m_flDuckAmount() = duck_amount;
        player->m_flLowerBodyYawTarget() = lby;

        player->m_angEyeAngles() = angles;
        player->set_abs_angles(abs_angles);
        player->m_vecVelocity() = velocity;
        player->m_vecOrigin() = origin;
        player->set_abs_origin(origin);
        player->GetCollideable()->OBBMins() = mins;
        player->GetCollideable()->OBBMaxs() = maxs;
    }

    bool valid(bool extra_checks = true)
    {
        if (!this)
            return false;

        if (i > 0)
            player = (player_t*)m_entitylist()->GetClientEntity(i);

        if (!player)
            return false;

        if (player->m_lifeState() != LIFE_ALIVE)
            return false;

        if (immune)
            return false;

        if (dormant)
            return false;

        if (!extra_checks)
            return true;

        if (invalid)
            return false;

        auto net_channel_info = m_engine()->GetNetChannelInfo();

        if (!net_channel_info)
            return false;

        static auto sv_maxunlag = m_cvar()->FindVar(crypt_str("sv_maxunlag"));

        auto outgoing = net_channel_info->GetLatency(FLOW_OUTGOING);
        auto incoming = net_channel_info->GetLatency(FLOW_INCOMING);

        auto correct = math::clamp(outgoing + incoming + util::get_interpolation(), 0.0f, sv_maxunlag->GetFloat());
        
        auto curtime = g_ctx.local()->is_alive() ? TICKS_TO_TIME(g_ctx.globals.fixed_tickbase) : m_globals()->m_curtime;
        auto delta_time = correct - (curtime - simulation_time);

        if (fabs(delta_time) > 0.2f)
            return false;

        auto extra_choke = 0;

        if (g_ctx.globals.fakeducking)
            extra_choke = 14 - m_clientstate()->iChokedCommands;

        auto server_tickcount = extra_choke + m_globals()->m_tickcount + TIME_TO_TICKS(outgoing + incoming);
        auto dead_time = (int)(TICKS_TO_TIME(server_tickcount) - sv_maxunlag->GetFloat());

        if (simulation_time < (float)dead_time)
            return false;

        return true;
    }
};

class optimized_adjust_data
{
public:
    int i;
    player_t*player;

    float simulation_time;
    float duck_amount;

    vector angles;
    vector origin;

    optimized_adjust_data()
    {
        reset();
    }

    void reset()
    {
        i = 0;
        player = nullptr;

        simulation_time = 0.0f;
        duck_amount = 0.0f;

        angles Zero();
        origin.zero();
    }
};

class lag data
{
    c_baseplayeranimationstate* animstate;
public:
    float side;
    float realtime = animstate->m_flLastClientSideAnimationUpdateTime;
    float resolving_way;
};

extern std::deque <adjust_data> player_records[65];

class lagcompensation : public singleton <lagcompensation>
{
public:
    void fsn(ClientFrameStage_tstage);
    void do_anim_event(player_t* pl, c_baseplayeranimationstate* state, int order, int activity);
    void extrapolation(player_t* player, Vector& origin, Vector& velocity, int& flags, bool on_ground);
    bool valid(int i, player_t*e);
    void update_player_animations(player_t*e);

    CResolver player_resolver[65];

    bool is_dormant[65];
    float previous_goal_feet_yaw[65];
};
C++:
#include "animation_system.h"
#include "..\ragebot\aim.h"
#include "../visuals/player_esp.h"

/*RESOLVER BY LAITH*/
void CResolver::initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch)
{
    player = e;
    player_record = record;

    original_pitch = math::normalize_pitch(pitch);
    original_goal_feet_yaw = math::normalize_yaw(goal_feet_yaw);
}

void CResolver::initialize_yaw(player_t* e)
{
    player = e;

    g_ctx.globals.left = build_yaw(player, player->m_angEyeAngles().y, 1);
    g_ctx.globals.right = build_yaw(player, player->m_angEyeAngles().y, 2);
    g_ctx.globals.middle = build_yaw(player, player->m_angEyeAngles().y, 3);
}

void CResolver::reset()
{
    fake = false;
    was_first_bruteforce = false;
    was_second_bruteforce = false;
    original_goal_feet_yaw = 0.0f;
    original_pitch = 0.0f;
}

bool CResolver::IsAdjustingBalances(AnimationLayer* record, AnimationLayer* layer)
{
    AnimationLayer animationLayer[15];
    for (int i = 0; i; i++)
    {
        const int activity = player->sequence_activity(animationLayer[i].m_nSequence);
        if (activity == 979)
        {
            *layer = animationLayer[i];
            return true;
        }
    }
    return false;
}



bool CResolver::is_slow_walking()
{
    auto entity = player;
    //float large = 0;
    float velocity_2D[64], old_velocity_2D[64];
    if (entity->m_vecVelocity().Length2D() != velocity_2D[entity->EntIndex()] && entity->m_vecVelocity().Length2D() != NULL) {
        old_velocity_2D[entity->EntIndex()] = velocity_2D[entity->EntIndex()];
        velocity_2D[entity->EntIndex()] = entity->m_vecVelocity().Length2D();
    }
    //if (large == 0)return false;
    Vector velocity = entity->m_vecVelocity();
    Vector direction = entity->m_angEyeAngles();

    float speed = velocity.Length();
    direction.y = entity->m_angEyeAngles().y - direction.y;
    //method 1
    if (velocity_2D[entity->EntIndex()] > 1) {
        int tick_counter[64];
        if (velocity_2D[entity->EntIndex()] == old_velocity_2D[entity->EntIndex()])
            tick_counter[entity->EntIndex()] += 1;
        else
            tick_counter[entity->EntIndex()] = 0;

        while (tick_counter[entity->EntIndex()] > (1 / m_globals()->m_intervalpertick) * fabsf(0.1f))//should give use 100ms in ticks if their speed stays the same for that long they are definetely up to something..
            return true;
    }


    return false;
}



void CResolver::get_side_moving()
{
    player_record->type = LAYERS;
    float delta_first = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[0][6].m_flPlaybackRate);
    float delta_second = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[2][6].m_flPlaybackRate);
    float delta_third = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[1][6].m_flPlaybackRate);

    if (delta_first < delta_second || delta_third <= delta_second)
    {
        if (delta_first >= delta_third && delta_second > delta_third)
            player_record->curSide = RIGHT;

        else
            detect_side();

    }
    else
        player_record->curSide = LEFT;


}

void CResolver::get_side_standing()
{
    
    player_record->type = LBY;

    float angle_difference = math::AngleDiff(player->m_angEyeAngles().y, original_goal_feet_yaw);
    player_record->curSide = 2 * angle_difference <= 0.0f ? RIGHT : LEFT;
}

float get_backward_side(player_t* player)
{
    return math::calculate_angle(g_ctx.local()->m_vecOrigin(), player->m_vecOrigin()).y;
}

void CResolver::detect_side()
{
    player_record->type = ENGINE;
    /* externs */
    Vector src3D, dst3D, forward, right, up, src, dst;
    float back_two, right_two, left_two;
    CGameTrace tr;
    CTraceFilter filter;

    /* angle vectors */
    math::angle_vectors(Vector(0, get_backward_side(player), 0), &forward, &right, &up);

    /* filtering */
    filter.pSkip = player;
    src3D = player->get_shoot_position();
    dst3D = src3D + (forward * 384);

    /* back engine tracers */
    m_trace()->TraceRay(Ray_t(src3D, dst3D), MASK_SHOT, &filter, &tr);
    back_two = (tr.endpos - tr.startpos).Length();

    /* right engine tracers */
    m_trace()->TraceRay(Ray_t(src3D + right * 35, dst3D + right * 35), MASK_SHOT, &filter, &tr);
    right_two = (tr.endpos - tr.startpos).Length();

    /* left engine tracers */
    m_trace()->TraceRay(Ray_t(src3D - right * 35, dst3D - right * 35), MASK_SHOT, &filter, &tr);
    left_two = (tr.endpos - tr.startpos).Length();

    /* fix side */
    if (left_two > right_two) {
        player_record->curSide = LEFT;
    }
    else if (right_two > left_two) {
        player_record->curSide = RIGHT;
    }
    else
        get_side_trace();
}

void CResolver::get_side_trace()
{
    auto m_side = false;
    auto trace = false;
    if (m_globals()->m_curtime - lock_side > 2.0f)
    {
        auto first_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first), player, g_ctx.local());
        auto second_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second), player, g_ctx.local());

        if (first_visible != second_visible)
        {
            trace = true;
            m_side = second_visible;
            lock_side = m_globals()->m_curtime;
        }
        else
        {
            auto first_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first));
            auto second_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second));

            if (fabs(first_position - second_position) > 1.0f)
                m_side = first_position > second_position;
        }
    }
    else
        trace = true;

    if (m_side)
    {
        player_record->type = trace ? TRACE : DIRECTIONAL;
        player_record->curSide = RIGHT;
    }
    else
    {
        player_record->type = trace ? TRACE : DIRECTIONAL;
        player_record->curSide = LEFT;
    }
}

float CResolver::GetChokedPackets()
{
    float simtime = player->m_flSimulationTime();
    float oldsimtime = player->m_flOldSimulationTime();
    float simdiff = simtime - oldsimtime;

    auto chokedpackets = TIME_TO_TICKS(max(0, simdiff));

    if (chokedpackets >= 1)
        return chokedpackets;

    return 0;
}

bool CResolver::DesyncDetect()
{
    if (!player->is_alive())
        return false;
    if (player->get_max_desync_delta() < 10)
        return false;
    if (!player->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
        return false;
    if (!player->m_hActiveWeapon().Get()->can_fire(true))
        return false;
    if (player->get_move_type() == MOVETYPE_NOCLIP || player->get_move_type() == MOVETYPE_LADDER)
        return false;

    return true;
}

bool CResolver::update_walk_data()
{
    auto e = player;
    float previous, m_previous;
    previous = m_previous;

    auto anim_layers = player_record->layers;
    bool s_1 = false,
        s_2 = false,
        s_3 = false;

    for (int i = 0; i < e->animlayer_count(); i++)
    {
        anim_layers[i] = e->get_animlayers()[i];
        if (anim_layers[i].m_nSequence == 26 && anim_layers[i].m_flWeight < 0.47f)
            s_1 = true;
        if (anim_layers[i].m_nSequence == 7 && anim_layers[i].m_flWeight > 0.001f)
            s_2 = true;
        if (anim_layers[i].m_nSequence == 2 && anim_layers[i].m_flWeight == 0)
            s_3 = true;
    }
    float  m_fakewalking;
    if (s_1 && s_2)
        if (s_3)
            m_fakewalking = true;
        else
            m_fakewalking = false;
    else
        m_fakewalking = false;

    return m_fakewalking;
}

bool ext = false;
void CResolver::setmode()
{
    auto e = player;

    auto rec_layer = player_record->layers;
    auto layer = resolver_layers;

    float speed = e->m_vecVelocity().Length2D();
    
    
    bool extending = IsAdjustingBalances(rec_layer, layer[15]);
    bool on_ground = e->m_fFlags() & FL_ONGROUND;

    bool slow_walking1 = is_slow_walking();
    bool slow_walking2 = update_walk_data();
    
    
    if (extending)
        ext = true;

    bool ducking = player->get_animation_state()->m_fDuckAmount && e->m_fFlags() & FL_ONGROUND && !player->get_animation_state()->m_bInHitGroundAnimation;

    

    bool stand_anim = false;
    if (player_record->layers[3].m_flWeight == 0.f && player_record->layers[3].m_flCycle == 0.f && player_record->layers[6].m_flWeight == 0.f)
        stand_anim = true;

    bool move_anim = false;
    if (int(player_record->layers[6].m_flWeight * 1000.f) == int(previous_layers[6].m_flWeight * 1000.f))
        move_anim = true;

    auto animstate = player->get_animation_state();
    if (!animstate)
        return;

    auto valid_move = true;
    if (animstate->m_velocity > 0.1f || fabs(animstate->flUpVelocity) > 100.f)
        valid_move = animstate->m_flTimeSinceStartedMoving < 0.22f;

    if (!on_ground)
    {
        player_record->curMode = AIR;
    }

    else if (!valid_move && move_anim || /*micromovement check pog*/ speed >= 3.0f && ducking || speed >= 1.1f && !ducking)
    {
        player_record->curMode = MOVING;
    }

    else if (valid_move && stand_anim || extending || /*micromovement check pog*/ speed < 3.0f && ducking || speed < 1.1f && !ducking)
    {
        player_record->curMode = STANDING;
    }
    else if (speed >= 1.1f && !ducking && (slow_walking1 || slow_walking2))
        player_record->curMode = SLOW_WALKING;
    else
        player_record->curMode = FREESTANDING;
}

bool CResolver::MatchShot()
{
    // do not attempt to do this in nospread mode.

    float shoot_time = -1.f;

    auto weapon = player->m_hActiveWeapon();
    if (weapon) {
        // with logging this time was always one tick behind.
        // so add one tick to the last shoot time.
        shoot_time = weapon->m_fLastShotTime() + m_globals()->m_intervalpertick;
    }

    // this record has a shot on it.
    if (TIME_TO_TICKS(shoot_time) == TIME_TO_TICKS(player->m_flSimulationTime()))
    {
        return true;
    }

    return false;
}

void CResolver::final_detection()
{
    switch (player_record->curMode)
    {
    case MOVING:
        get_side_moving();
        break;
    case STANDING:
        get_side_trace();
        break;
    case FREESTANDING:
        detect_side();
        break;
    case AIR:
        player_record->side = RESOLVER_ORIGINAL;
        player_record->curSide = NONE_CUR;
        break;
    case SLOW_WALKING:
        get_side_moving();
            break;

    }
}

static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
    Vector delta = a - b;
    float delta_length = delta.Length();

    if (delta_length <= min_delta)
    {
        Vector result;

        if (-min_delta <= delta_length)
            return a;
        else
        {
            float iradius = 1.0f / (delta_length + FLT_EPSILON);
            return b - ((delta * iradius) * min_delta);
        }
    }
    else
    {
        float iradius = 1.0f / (delta_length + FLT_EPSILON);
        return b + ((delta * iradius) * min_delta);
    }
};


float CResolver::build_yaw(player_t* player, float angle, int n)
{
    auto animState = player->get_animation_state();
    float m_flFakeGoalFeetYaw = 0.0f;
    // Rebuild setup velocity to receive flMinBodyYaw and flMaxBodyYaw
    Vector velocity = player->m_vecVelocity();
    float spd = velocity.LengthSqr();
    if (spd > std::powf(1.2f * 260.0f, 2.f)) {
        Vector velocity_normalized = velocity.Normalized();
        velocity = velocity_normalized * (1.2f * 260.0f);
    }

    float m_flChokedTime = animState->m_flLastClientSideAnimationUpdateTime;
    float v25 = math::clamp(player->m_flDuckAmount() + animState->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
    float v26 = animState->m_fDuckAmount;
    float v27 = m_flChokedTime * 6.0f;
    float v28;

    // clamp
    if ((v25 - v26) <= v27) {
        if (-v27 <= (v25 - v26))
            v28 = v25;
        else
            v28 = v26 - v27;
    }
    else {
        v28 = v26 + v27;
    }

    float flDuckAmount = math::clamp(v28, 0.0f, 1.0f);

    Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, player->m_vecVelocity());
    float speed = std::fminf(animationVelocity.Length(), 260.0f);

    auto weapon = player->m_hActiveWeapon();

    float flMaxMovementSpeed = 260.0f;
    if (weapon && weapon->get_csweapon_info()) {
        flMaxMovementSpeed = std::fmaxf(weapon->get_csweapon_info()->flMaxPlayerSpeed, 0.001f);
    }

    float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
    float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);

    flRunningSpeed = math::clamp(flRunningSpeed, 0.0f, 1.0f);

    float flYawModifier = (((animState->m_flStopToFullRunningFraction * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
    if (flDuckAmount > 0.0f) {
        float flDuckingSpeed = math::clamp(flDuckingSpeed, 0.0f, 1.0f);
        flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
    }

    auto test = animState->yaw_desync_adjustment();

    float flMinBodyYaw = -58.0f * flYawModifier;
    float flMaxBodyYaw = 58.0f * flYawModifier;

    float flEyeYaw = angle;
    float flEyeDiff = std::remainderf(flEyeYaw - m_flFakeGoalFeetYaw, 360.f);

    if (flEyeDiff <= flMaxBodyYaw) {
        if (flMinBodyYaw > flEyeDiff)
            m_flFakeGoalFeetYaw = fabs(flMinBodyYaw) + flEyeYaw;
    }
    else {
        m_flFakeGoalFeetYaw = flEyeYaw - fabs(flMaxBodyYaw);
    }

    m_flFakeGoalFeetYaw = std::remainderf(m_flFakeGoalFeetYaw, 360.f);

    if (speed > 0.1f || fabs(velocity.z) > 100.0f) {
        m_flFakeGoalFeetYaw = math::ApproachAngle(
            flEyeYaw,
            m_flFakeGoalFeetYaw,
            ((animState->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
            * m_flChokedTime);
    }
    else {
        m_flFakeGoalFeetYaw = math::ApproachAngle(
            player->m_flLowerBodyYawTarget(),
            m_flFakeGoalFeetYaw,
            m_flChokedTime * 100.0f);
    }

    float Left = flMinBodyYaw;
    float Right = flMaxBodyYaw;
    float middle = m_flFakeGoalFeetYaw;

    math::normalize_yaw(m_flFakeGoalFeetYaw);

    if (n == 1)
        return Left;
    else if (n == 2)
        return Right;
    else if (n == 3)
        return m_flFakeGoalFeetYaw;
}

void CResolver::resolve()
{


    bool mside;
    bool slow_walking = is_slow_walking();
    int chokedpackets = GetChokedPackets();

    auto pWeapon = player->m_hActiveWeapon();
    auto simtime = player->m_flSimulationTime();
    auto oldsimtime = player->m_flOldSimulationTime();
    float m_flLastShotTime;
    bool m_shot;
    m_flLastShotTime = pWeapon ? pWeapon->m_fLastShotTime() : 0.f;
    m_shot = m_flLastShotTime > oldsimtime && m_flLastShotTime <= simtime;

    bool should_detect = DesyncDetect();

    if (!should_detect || chokedpackets < 1)
        return;

    setmode();
    if (player->get_move_type() == MOVETYPE_LADDER || player->get_move_type() == MOVETYPE_NOCLIP)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }
    if (m_flLastShotTime <= simtime && m_shot || MatchShot())
    {
        player_record->side = RESOLVER_ON_SHOT;
        player_record->curSide = NONE_CUR;
        return;
    }

            if (g_ctx.globals.missed_shots[player->EntIndex()] == 0)
            {
                if (player_record->curstate != NOT_FLIPPED && player_record->curstate != FLIPPED)
                {
                    final_detection();
                    player_record->curstate = NOT_FLIPPED;
                }
                
                if (player_record->curdelta != MAX_DELTA && player_record->curdelta != LOW_DELTA)
                {
                    final_detection();
                    player_record->curdelta = MAX_DELTA;
                }
                else
                    final_detection();
            }
                
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 1)
            {
                final_detection();
                player_record->curdelta = LOW_DELTA;
                player_record->curstate = NOT_FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 2)
            {
                final_detection();
                player_record->curdelta = MAX_DELTA;
                player_record->curstate = FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 3)
            {
                final_detection();
                player_record->curdelta = LOW_DELTA;
                player_record->curstate = FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] >= 4)
            {
                player_record->curdelta = MAX_DELTA;
                player_record->curstate = NOT_FLIPPED;
                
                g_ctx.globals.missed_shots[player->EntIndex()] = 0;
            }

    if (player_record->curstate == FLIPPED)
    {
        if (player_record->curSide == RIGHT)
            player_record->curSide = LEFT;

        else if (player_record->curSide == LEFT)
            player_record->curSide = RIGHT;
    }

    if (player_record->curSide == RIGHT)
        mside=true;
    else if (player_record->curSide == LEFT)
        mside=false;
    else if (player_record->curSide == MIDDLE)
    {
        player_record->side = RESOLVER_ZERO;
        return;
    }
    else
        return;

    if (player_record->curdelta == LOW_DELTA)
        player_record->side = mside ? RESOLVER_LOW_FIRST : RESOLVER_LOW_SECOND;
    else if (player_record->curdelta == MAX_DELTA)
        player_record->side = mside ? RESOLVER_FIRST : RESOLVER_SECOND;
    else
        return;

    //TODO:- check curdelta for each side seperetaly because people might use low delta on the right and max delta on the left and jitter between them
}
 
(\ /) _ ($ __ $ ) _ (\ /)
Пользователь
Статус
Оффлайн
Регистрация
22 Окт 2021
Сообщения
362
Реакции[?]
92
Поинты[?]
24K
maybe it's not animfix, but pitch resolver.

Код:
float resolver::resolve_pitch()
{
    float liohsdafg = 0.f;
    if (g_cfg.ragebot.pitch_antiaim_correction)
    {
        if (liohsdafg < -179.f) liohsdafg += 360.f;
        else if (liohsdafg > 90.0 || liohsdafg < -90.0) liohsdafg = 89.f;
        else if (liohsdafg > 89.0 && liohsdafg < 91.0) liohsdafg -= 90.f;
        else if (liohsdafg > 179.0 && liohsdafg < 181.0) liohsdafg -= 180;
        else if (liohsdafg > -179.0 && liohsdafg < -181.0) liohsdafg += 180;

        else if (fabs(liohsdafg) == 0) liohsdafg = copysign(89.0f, liohsdafg);
        else liohsdafg = original_pitch;

        return liohsdafg;
    }
    else
        return original_pitch;
}
Just don't forget to add the antiaim_correction checkbox, maybe you already have it.
 
Начинающий
Статус
Оффлайн
Регистрация
29 Мар 2021
Сообщения
18
Реакции[?]
7
Поинты[?]
0
C++:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include "animation_system.h"
#include "..\misc\misc.h"
#include "..\misc\logs.h"

std::deque <adjust_data> player_records[65];

void lagcompensation::fsn(ClientFrameStage_t stage)
{
    if (stage != FRAME_NET_UPDATE_END)
        return;

    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled)
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++)
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (e == g_ctx.local())
            continue;

        if (!valid(i, e))
            continue;

        auto time_delta = abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount);

        if (time_delta > 1.0f / m_globals()->m_intervalpertick)
            continue;

        if (player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime())
        {
            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
                for (auto& record : player_records[i])
                    record.invalid = true;

            player_records[i].emplace_front(adjust_data());
            update_player_animations(e);

            while (player_records[i].size() > 32)
                player_records[i].pop_back();
        }
    }
}

bool lagcompensation::valid(int i, player_t* e)
{
    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled || !e->valid(false))
    {
        if (!e->is_alive())
        {
            is_dormant[i] = false;
            //player_resolver[i].reset();

            //g_ctx.globals.fired_shots[i] = 0;
            //g_ctx.globals.missed_shots[i] = 0;
        }
        else if (e->IsDormant())
            is_dormant[i] = true;

        //player_records[i].clear();
        return false;
    }

    return true;
}




float build_server_abs_yaw(player_t* m_player, float angle, int n)
{
    Vector velocity = m_player->m_vecVelocity();
    auto anim_state = m_player->get_animation_state();
    float m_flEyeYaw = angle;
    float m_flGoalFeetYaw = 0.f;

    float eye_feet_delta = math::AngleDiff(m_flEyeYaw, m_flGoalFeetYaw);

    static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
        Vector delta = a - b;
        float delta_length = delta.Length();

        if (delta_length <= min_delta)
        {
            Vector result;

            if (-min_delta <= delta_length)
                return a;
            else
            {
                float iradius = 1.0f / (delta_length + FLT_EPSILON);
                return b - ((delta * iradius) * min_delta);
            }
        }
        else
        {
            float iradius = 1.0f / (delta_length + FLT_EPSILON);
            return b + ((delta * iradius) * min_delta);
        }
    };

    float spd = velocity.LengthSqr();

    if (spd > std::powf(1.2f * 260.0f, 2.f))
    {
        Vector velocity_normalized = velocity.Normalized();
        velocity = velocity_normalized * (1.2f * 260.0f);
    }

    float m_flChokedTime = anim_state->m_flLastClientSideAnimationUpdateTime;
    float v25 = std::clamp(m_player->m_flDuckAmount() + anim_state->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
    float v26 = anim_state->m_fDuckAmount;
    float v27 = m_flChokedTime * 6.0f;
    float v28;


    if ((v25 - v26) <= v27) {
        if (-v27 <= (v25 - v26))
            v28 = v25;
        else
            v28 = v26 - v27;
    }
    else {
        v28 = v26 + v27;
    }

    float flDuckAmount = std::clamp(v28, 0.0f, 1.0f);

    Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, m_player->m_vecVelocity());
    float speed = std::fminf(animationVelocity.Length(), 260.0f);

    float flMaxMovementSpeed = 260.0f;

    weapon_t* pWeapon = m_player->m_hActiveWeapon();

    if (pWeapon && pWeapon->get_csweapon_info())
        flMaxMovementSpeed = std::fmaxf(pWeapon->get_csweapon_info()->flMaxPlayerSpeedAlt, 0.001f);

    float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
    float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);

    flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);

    float flYawModifier = (((anim_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * flRunningSpeed) + 1.0f;

    if (flDuckAmount > 0.0f)
    {
        float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
        flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
    }

    const float v60 = -58.0f;
    const float v61 = 58.0f;

    /*
    float flMaxBodyYaw = *reinterpret_cast<float*>(&animState->pad10[512]);
    float flMinBodyYaw = *reinterpret_cast<float*>(&animState->pad10[516]);
    */

    float flMinYawModifier = v60 * flYawModifier;
    float flMaxYawModifier = v61 * flYawModifier;

    if (eye_feet_delta <= flMaxYawModifier)
    {
        if (flMinYawModifier > eye_feet_delta)
            m_flGoalFeetYaw = fabs(flMinYawModifier) + m_flEyeYaw;
    }
    else
    {
        m_flGoalFeetYaw = m_flEyeYaw - fabs(flMaxYawModifier);
    }

    math::normalize_yaw(m_flGoalFeetYaw);

    if (speed > 0.1f || fabs(velocity.z) > 100.0f)
    {
        m_flGoalFeetYaw = math::ApproachAngle(
            m_flEyeYaw,
            m_flGoalFeetYaw,
            ((anim_state->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
            * m_flChokedTime);
    }
    else
    {
        m_flGoalFeetYaw = math::ApproachAngle(
            m_player->m_flLowerBodyYawTarget(),
            m_flGoalFeetYaw,
            m_flChokedTime * 100.0f);
    }

    if (n == 1)
        return m_flEyeYaw + flMinYawModifier;
    else if (n == 2)
        return m_flEyeYaw + flMaxYawModifier;
    else if (n == 3)
        return m_flGoalFeetYaw;

}
void lagcompensation::update_player_animations(player_t* e)
{
    auto animstate = e->get_animation_state();

    if (!animstate)
        return;

    player_info_t player_info;

    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
        return;

    auto records = &player_records[e->EntIndex()];

    if (records->empty())
        return;

    adjust_data* previous_record = nullptr;

    if (records->size() >= 2)
        previous_record = &records->at(1);

    auto record = &records->front();

    AnimationLayer animlayers[15];

    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
    auto backup_duck_amount = e->m_flDuckAmount();
    auto backup_flags = e->m_fFlags();
    auto backup_eflags = e->m_iEFlags();

    auto backup_curtime = m_globals()->m_curtime;
    auto backup_frametime = m_globals()->m_frametime;
    auto backup_realtime = m_globals()->m_realtime;
    auto backup_framecount = m_globals()->m_framecount;
    auto backup_tickcount = m_globals()->m_tickcount;
    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;

    m_globals()->m_curtime = e->m_flSimulationTime();
    m_globals()->m_frametime = m_globals()->m_intervalpertick;


    if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(record->flags & FL_ONGROUND))
            {
                velocity = (record->origin - previous_record->origin) / record->simulation_time;

                float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP].m_flWeight;

                if (flWeight > 0.0f)
                {
                    float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
                    float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;

                    if (flPreviousRate == flCurrentRate)
                    {
                        int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
                        int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;

                        if (iPreviousSequence == iCurrentSequence)
                        {
                            float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;

                            if (flSpeedNormalized > 0.0f)
                            {
                                float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();

                                if (flSpeed > 0.0f)
                                {
                                    if (velocity.Length2D() > 0.0f)
                                    {
                                        velocity.x /= velocity.Length2D() / flSpeed;
                                        velocity.y /= velocity.Length2D() / flSpeed;
                                    }
                                }
                            }
                        }
                    }
                }

                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
                velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
            }
            else
                velocity.z = 0.0f;
        }
    }
    else
    {
        //record->shot = record->last_shot_time == record->simulation_time;
    }

    e->m_iEFlags() &= ~0x1800;

    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
        e->m_vecVelocity().Zero();

    e->m_vecAbsVelocity() = e->m_vecVelocity();
    e->m_bClientSideAnimation() = true;

    if (is_dormant[e->EntIndex()])
    {
        is_dormant[e->EntIndex()] = false;

        if (e->m_fFlags() & FL_ONGROUND)
        {
            animstate->m_bOnGround = true;
            animstate->m_bInHitGroundAnimation = false;
        }

        animstate->time_since_in_air() = 0.0f;
        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    }

    auto updated_animations = false;

    c_baseplayeranimationstate state;
    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));

    if (previous_record)
    {
        memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));

        auto ticks_chocked = 1;
        auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);

        if (simulation_ticks > 0 && simulation_ticks < 31)
            ticks_chocked = simulation_ticks;

        if (ticks_chocked > 1)
        {
            auto land_time = 0.0f;
            auto land_in_cycle = false;
            auto is_landed = false;
            auto on_ground = false;

            if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
            {
                land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
                land_in_cycle = land_time >= previous_record->simulation_time;
            }

            auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;

            for (auto i = 0; i < ticks_chocked; ++i)
            {
                auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);

                if (duck_amount_per_tick)
                    e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;

                on_ground = e->m_fFlags() & FL_ONGROUND;

                if (land_in_cycle && !is_landed)
                {
                    if (land_time <= simulated_time)
                    {
                        is_landed = true;
                        on_ground = true;
                    }
                    else
                        on_ground = previous_record->flags & FL_ONGROUND;
                }

                if (on_ground)
                    e->m_fFlags() |= FL_ONGROUND;
                else
                    e->m_fFlags() &= ~FL_ONGROUND;

                auto simulated_ticks = TIME_TO_TICKS(simulated_time);

                m_globals()->m_realtime = simulated_time;
                m_globals()->m_curtime = simulated_time;
                m_globals()->m_framecount = simulated_ticks;
                m_globals()->m_tickcount = simulated_ticks;
                m_globals()->m_interpolation_amount = 0.0f;

                g_ctx.globals.updating_animation = true;
                e->update_clientside_animation();
                g_ctx.globals.updating_animation = false;

                m_globals()->m_realtime = backup_realtime;
                m_globals()->m_curtime = backup_curtime;
                m_globals()->m_framecount = backup_framecount;
                m_globals()->m_tickcount = backup_tickcount;
                m_globals()->m_interpolation_amount = backup_interpolation_amount;

                updated_animations = true;
            }
        }
    }

    if (!updated_animations)
    {
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
    }

    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));

    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
    {
        e->invalidate_physics_recursive(8);

        AnimationLayer backup_layers[15];
        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));

        switch (matrix)
        {
        case MAIN:
            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
            break;
        case NONE:
            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
            break;
        case FIRST:
            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
            break;
        case SECOND:
            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
            break;
        }

        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
    };

    if (g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled)
    {
        player_resolver[e->EntIndex()].initialize_yaw(e);

        /*rebuild setup velocity for more accurate rotations for the resolver and safepoints*/
        float left =  g_ctx.globals.left;
        float right = g_ctx.globals.right;
        float middle = g_ctx.globals.middle;
        // ------ \\

        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));



        // --- first --- \\

        animstate->m_flGoalFeetYaw = middle;
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, NONE);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[0] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\



        // --- second --- \\

        animstate->m_flGoalFeetYaw = math::normalize_yaw(right + e->EntIndex());
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, FIRST);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[2] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[2], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\




        // --- third --- \\

        animstate->m_flGoalFeetYaw = math::normalize_yaw(left + e->EntIndex());
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, SECOND);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[1] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\


       


        player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
        player_resolver[e->EntIndex()].resolve();

        auto eye = e->m_angEyeAngles().y;
        auto idx = e->EntIndex();
        switch (record->side)
        {
        case RESOLVER_ORIGINAL:
            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
            g_ctx.globals.mlog1[idx] = previous_goal_feet_yaw[e->EntIndex()];
            break;
        case RESOLVER_ZERO:
            animstate->m_flGoalFeetYaw = middle;
            g_ctx.globals.mlog1[idx] = middle;
            break;
        case RESOLVER_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(left + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(left);
            break;
        case RESOLVER_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(right + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(right);
            break;
        case RESOLVER_LOW_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(max(-10.0f , left * 0.5) + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(max(-10.0f, left * 0.5));
            break;
        case RESOLVER_LOW_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(min(10.0f, right * 0.5) + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(min(10.0f, right * 0.5));
            break;
        case RESOLVER_ON_SHOT:
            animstate->m_flGoalFeetYaw = middle;
            g_ctx.globals.mlog1[idx] = middle;
            break;
        }


        /*switch (record->side)
        {
        case RESOLVER_ORIGINAL:
            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
            break;
        case RESOLVER_ZERO:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
            break;
        case RESOLVER_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + e->get_max_desync_delta());
            break;
        case RESOLVER_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - e->get_max_desync_delta());
            break;
        case RESOLVER_LOW_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 25);
            break;
        case RESOLVER_LOW_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 25);
            break;
        case RESOLVER_ON_SHOT:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
            break;
        }*/

        //e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();

    }

    g_ctx.globals.updating_animation = true;
    e->update_clientside_animation();
    g_ctx.globals.updating_animation = false;

    setup_matrix(e, animlayers, MAIN);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    setup_matrix(e, animlayers, FIRST);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.first, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    setup_matrix(e, animlayers, SECOND);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.second, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    m_globals()->m_curtime = backup_curtime;
    m_globals()->m_frametime = backup_frametime;

    e->m_flLowerBodyYawTarget() = backup_lower_body_yaw_target;
    e->m_flDuckAmount() = backup_duck_amount;
    e->m_fFlags() = backup_flags;
    e->m_iEFlags() = backup_eflags;

    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(player_resolver[e->EntIndex()].previous_layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
C++:
#pragma once

#include "..\..\includes.hpp"
#include "..\..\sdk\structs.hpp"


enum
{
    MAIN,
    NONE,
    FIRST,
    SECOND
};

enum resolver_type
{
    ORIGINAL,
    BRUTEFORCE,
    LBY,
    LAYERS,
    TRACE,
    DIRECTIONAL,
    ENGINE,
    FREESTAND,
    NON_RESOLVED
};
enum resolver_side
{
    RESOLVER_ORIGINAL,
    RESOLVER_ZERO,
    RESOLVER_FIRST,
    RESOLVER_SECOND,
    RESOLVER_LOW_FIRST,
    RESOLVER_LOW_SECOND,
    RESOLVER_ON_SHOT
};

enum modes
{
    NONE_SIDE,
    AIR,
    SLOW_WALKING,
    SLOW_WALKING_MAX,
    MOVING,
    STANDING,
    FREESTANDING
};

enum get_side_move
{
    MIDDLE,
    LEFT,
    RIGHT,
    NONE_CUR
};
enum curdelta
{
    LOW_DELTA,
    MAX_DELTA
};
enum curstate
{
    NOT_FLIPPED,
    FLIPPED
};

enum animstate_layer_t
{
    ANIMATION_LAYER_AIMMATRIX = 0,
    ANIMATION_LAYER_WEAPON_ACTION,
    ANIMATION_LAYER_WEAPON_ACTION_RECROUCH,
    ANIMATION_LAYER_ADJUST,
    ANIMATION_LAYER_MOVEMENT_JUMP_OR_FALL,
    ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB,
    ANIMATION_LAYER_MOVEMENT_MOVE,
    ANIMATION_LAYER_MOVEMENT_STRAFECHANGE,
    ANIMATION_LAYER_WHOLE_BODY,
    ANIMATION_LAYER_FLASHED,
    ANIMATION_LAYER_FLINCH,
    ANIMATION_LAYER_ALIVELOOP,
    ANIMATION_LAYER_LEAN,
    ANIMATION_LAYER_COUNT,
};

struct matrixes
{
    matrix3x4_t main[MAXSTUDIOBONES];
    matrix3x4_t zero[MAXSTUDIOBONES];
    matrix3x4_t first[MAXSTUDIOBONES];
    matrix3x4_t second[MAXSTUDIOBONES];
};

class adjust_data;

class CResolver
{
    player_t* player = nullptr;
    adjust_data* player_record = nullptr;

    bool side = false;
    bool fake = false;
    bool was_first_bruteforce = false;
    bool was_second_bruteforce = false;

    float lock_side = 0.0f;
    float original_goal_feet_yaw = 0.0f;
    float original_pitch = 0.0f;

public:
    //void initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch);
    void initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch);
    void initialize_yaw(player_t* e);
    void reset();


    //bool is_choking(player_t* entity);
    bool ValidMove();
    void get_side_moving();
    void layer_test();
    void get_side_standing();
    void detect_side();
    void get_side_trace();
    float GetChokedPackets();
    bool DesyncDetect();
    bool update_walk_data();
    void setmode();
    bool MatchShot();
    bool is_slow_walking();
    void AntiFreestand();
    bool IsAdjustingBalances(AnimationLayer* record, AnimationLayer* layer);

    float ResolveShot();

    void final_detection();

    float build_yaw(player_t* player, float angle, int n);

    void resolve();


    AnimationLayer resolver_layers[3][15];
    AnimationLayer previous_layers[15];
    float resolver_goal_feet_yaw[3];

    resolver_side last_side = RESOLVER_ORIGINAL;
    float build_server_abs_yaw();
};


class adjust_data
{
public:
    player_t* player;
    int i;

    AnimationLayer layers[15];
    AnimationLayer side_layers[3][15];
    matrixes matrixes_data;
    get_side_move curSide;
    modes curMode;
    resolver_type type;
    resolver_side side;
    curdelta curdelta;
    curstate curstate;
    bool flipped_s;
    bool invalid;
    bool immune;
    bool dormant;
    bool bot;
   


    int flags;
    int bone_count;

    float simulation_time;
    float duck_amount;
    float lby;
    float left_side;
    float right_side;
    float maxrotation;
    float eyeyaw;

    Vector angles;
    Vector abs_angles;
    Vector velocity;
    Vector origin;
    Vector mins;
    Vector maxs;

    matrix3x4_t leftmatrixes[128] = {};
    matrix3x4_t rightmatrixes[128] = {};

    std::array<float, 24> left_poses = {};
    std::array<float, 24> right_poses = {};

    adjust_data()
    {
        reset();
    }

    void reset()
    {
        player = nullptr;
        i = -1;

        type = ORIGINAL;
        side = RESOLVER_ORIGINAL;

        invalid = false;
        immune = false;
        dormant = false;
        bot = false;

        flags = 0;
        bone_count = 0;

        simulation_time = 0.0f;
        duck_amount = 0.0f;
        lby = 0.0f;

        angles.Zero();
        abs_angles.Zero();
        velocity.Zero();
        origin.Zero();
        mins.Zero();
        maxs.Zero();
    }

    adjust_data(player_t* e, bool store = true)
    {
        type = ORIGINAL;
        side = RESOLVER_ORIGINAL;

        invalid = false;
        store_data(e, store);
    }

    void store_data(player_t* e, bool store = true)
    {
        if (!e->is_alive())
            return;
   
        player = e;
        i = player->EntIndex();

        if (store)
        {
            memcpy(layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
            memcpy(matrixes_data.main, player->m_CachedBoneData().Base(), player->m_CachedBoneData().Count() * sizeof(matrix3x4_t));
        }

        immune = player->m_bGunGameImmunity() || player->m_fFlags() & FL_FROZEN;
        dormant = player->IsDormant();

        bot = false;

        flags = player->m_fFlags();
        bone_count = player->m_CachedBoneData().Count();

        simulation_time = player->m_flSimulationTime();
        duck_amount = player->m_flDuckAmount();
        lby = player->m_flLowerBodyYawTarget();

        angles = player->m_angEyeAngles();
        abs_angles = player->GetAbsAngles();
        velocity = player->m_vecVelocity();
        origin = player->m_vecOrigin();
        mins = player->GetCollideable()->OBBMins();
        maxs = player->GetCollideable()->OBBMaxs();
    }

    void adjust_player()
    {
        if (!valid(false))
            return;

        memcpy(player->get_animlayers(), layers, player->animlayer_count() * sizeof(AnimationLayer));
        memcpy(player->m_CachedBoneData().Base(), matrixes_data.main, player->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

        player->m_fFlags() = flags;
        player->m_CachedBoneData().m_Size = bone_count;

        player->m_flSimulationTime() = simulation_time;
        player->m_flDuckAmount() = duck_amount;
        player->m_flLowerBodyYawTarget() = lby;

        player->m_angEyeAngles() = angles;
        player->set_abs_angles(abs_angles);
        player->m_vecVelocity() = velocity;
        player->m_vecOrigin() = origin;
        player->set_abs_origin(origin);
        player->GetCollideable()->OBBMins() = mins;
        player->GetCollideable()->OBBMaxs() = maxs;
    }

    bool valid(bool extra_checks = true)
    {
        if (!this)
            return false;

        if (i > 0)
            player = (player_t*)m_entitylist()->GetClientEntity(i);

        if (!player)
            return false;

        if (player->m_lifeState() != LIFE_ALIVE)
            return false;

        if (immune)
            return false;

        if (dormant)
            return false;

        if (!extra_checks)
            return true;

        if (invalid)
            return false;

        auto net_channel_info = m_engine()->GetNetChannelInfo();

        if (!net_channel_info)
            return false;

        static auto sv_maxunlag = m_cvar()->FindVar(crypt_str("sv_maxunlag"));

        auto outgoing = net_channel_info->GetLatency(FLOW_OUTGOING);
        auto incoming = net_channel_info->GetLatency(FLOW_INCOMING);

        auto correct = math::clamp(outgoing + incoming + util::get_interpolation(), 0.0f, sv_maxunlag->GetFloat());
       
        auto curtime = g_ctx.local()->is_alive() ? TICKS_TO_TIME(g_ctx.globals.fixed_tickbase) : m_globals()->m_curtime;
        auto delta_time = correct - (curtime - simulation_time);

        if (fabs(delta_time) > 0.2f)
            return false;

        auto extra_choke = 0;

        if (g_ctx.globals.fakeducking)
            extra_choke = 14 - m_clientstate()->iChokedCommands;

        auto server_tickcount = extra_choke + m_globals()->m_tickcount + TIME_TO_TICKS(outgoing + incoming);
        auto dead_time = (int)(TICKS_TO_TIME(server_tickcount) - sv_maxunlag->GetFloat());

        if (simulation_time < (float)dead_time)
            return false;

        return true;
    }
};

class optimized_adjust_data
{
public:
    int i;
    player_t*player;

    float simulation_time;
    float duck_amount;

    vector angles;
    vector origin;

    optimized_adjust_data()
    {
        reset();
    }

    void reset()
    {
        i = 0;
        player = nullptr;

        simulation_time = 0.0f;
        duck_amount = 0.0f;

        angles Zero();
        origin.zero();
    }
};

class lag data
{
    c_baseplayeranimationstate* animstate;
public:
    float side;
    float realtime = animstate->m_flLastClientSideAnimationUpdateTime;
    float resolving_way;
};

extern std::deque <adjust_data> player_records[65];

class lagcompensation : public singleton <lagcompensation>
{
public:
    void fsn(ClientFrameStage_tstage);
    void do_anim_event(player_t* pl, c_baseplayeranimationstate* state, int order, int activity);
    void extrapolation(player_t* player, Vector& origin, Vector& velocity, int& flags, bool on_ground);
    bool valid(int i, player_t*e);
    void update_player_animations(player_t*e);

    CResolver player_resolver[65];

    bool is_dormant[65];
    float previous_goal_feet_yaw[65];
};
C++:
#include "animation_system.h"
#include "..\ragebot\aim.h"
#include "../visuals/player_esp.h"

/*RESOLVER BY LAITH*/
void CResolver::initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch)
{
    player = e;
    player_record = record;

    original_pitch = math::normalize_pitch(pitch);
    original_goal_feet_yaw = math::normalize_yaw(goal_feet_yaw);
}

void CResolver::initialize_yaw(player_t* e)
{
    player = e;

    g_ctx.globals.left = build_yaw(player, player->m_angEyeAngles().y, 1);
    g_ctx.globals.right = build_yaw(player, player->m_angEyeAngles().y, 2);
    g_ctx.globals.middle = build_yaw(player, player->m_angEyeAngles().y, 3);
}

void CResolver::reset()
{
    fake = false;
    was_first_bruteforce = false;
    was_second_bruteforce = false;
    original_goal_feet_yaw = 0.0f;
    original_pitch = 0.0f;
}

bool CResolver::IsAdjustingBalances(AnimationLayer* record, AnimationLayer* layer)
{
    AnimationLayer animationLayer[15];
    for (int i = 0; i; i++)
    {
        const int activity = player->sequence_activity(animationLayer[i].m_nSequence);
        if (activity == 979)
        {
            *layer = animationLayer[i];
            return true;
        }
    }
    return false;
}



bool CResolver::is_slow_walking()
{
    auto entity = player;
    //float large = 0;
    float velocity_2D[64], old_velocity_2D[64];
    if (entity->m_vecVelocity().Length2D() != velocity_2D[entity->EntIndex()] && entity->m_vecVelocity().Length2D() != NULL) {
        old_velocity_2D[entity->EntIndex()] = velocity_2D[entity->EntIndex()];
        velocity_2D[entity->EntIndex()] = entity->m_vecVelocity().Length2D();
    }
    //if (large == 0)return false;
    Vector velocity = entity->m_vecVelocity();
    Vector direction = entity->m_angEyeAngles();

    float speed = velocity.Length();
    direction.y = entity->m_angEyeAngles().y - direction.y;
    //method 1
    if (velocity_2D[entity->EntIndex()] > 1) {
        int tick_counter[64];
        if (velocity_2D[entity->EntIndex()] == old_velocity_2D[entity->EntIndex()])
            tick_counter[entity->EntIndex()] += 1;
        else
            tick_counter[entity->EntIndex()] = 0;

        while (tick_counter[entity->EntIndex()] > (1 / m_globals()->m_intervalpertick) * fabsf(0.1f))//should give use 100ms in ticks if their speed stays the same for that long they are definetely up to something..
            return true;
    }


    return false;
}



void CResolver::get_side_moving()
{
    player_record->type = LAYERS;
    float delta_first = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[0][6].m_flPlaybackRate);
    float delta_second = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[2][6].m_flPlaybackRate);
    float delta_third = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[1][6].m_flPlaybackRate);

    if (delta_first < delta_second || delta_third <= delta_second)
    {
        if (delta_first >= delta_third && delta_second > delta_third)
            player_record->curSide = RIGHT;

        else
            detect_side();

    }
    else
        player_record->curSide = LEFT;


}

void CResolver::get_side_standing()
{
   
    player_record->type = LBY;

    float angle_difference = math::AngleDiff(player->m_angEyeAngles().y, original_goal_feet_yaw);
    player_record->curSide = 2 * angle_difference <= 0.0f ? RIGHT : LEFT;
}

float get_backward_side(player_t* player)
{
    return math::calculate_angle(g_ctx.local()->m_vecOrigin(), player->m_vecOrigin()).y;
}

void CResolver::detect_side()
{
    player_record->type = ENGINE;
    /* externs */
    Vector src3D, dst3D, forward, right, up, src, dst;
    float back_two, right_two, left_two;
    CGameTrace tr;
    CTraceFilter filter;

    /* angle vectors */
    math::angle_vectors(Vector(0, get_backward_side(player), 0), &forward, &right, &up);

    /* filtering */
    filter.pSkip = player;
    src3D = player->get_shoot_position();
    dst3D = src3D + (forward * 384);

    /* back engine tracers */
    m_trace()->TraceRay(Ray_t(src3D, dst3D), MASK_SHOT, &filter, &tr);
    back_two = (tr.endpos - tr.startpos).Length();

    /* right engine tracers */
    m_trace()->TraceRay(Ray_t(src3D + right * 35, dst3D + right * 35), MASK_SHOT, &filter, &tr);
    right_two = (tr.endpos - tr.startpos).Length();

    /* left engine tracers */
    m_trace()->TraceRay(Ray_t(src3D - right * 35, dst3D - right * 35), MASK_SHOT, &filter, &tr);
    left_two = (tr.endpos - tr.startpos).Length();

    /* fix side */
    if (left_two > right_two) {
        player_record->curSide = LEFT;
    }
    else if (right_two > left_two) {
        player_record->curSide = RIGHT;
    }
    else
        get_side_trace();
}

void CResolver::get_side_trace()
{
    auto m_side = false;
    auto trace = false;
    if (m_globals()->m_curtime - lock_side > 2.0f)
    {
        auto first_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first), player, g_ctx.local());
        auto second_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second), player, g_ctx.local());

        if (first_visible != second_visible)
        {
            trace = true;
            m_side = second_visible;
            lock_side = m_globals()->m_curtime;
        }
        else
        {
            auto first_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first));
            auto second_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second));

            if (fabs(first_position - second_position) > 1.0f)
                m_side = first_position > second_position;
        }
    }
    else
        trace = true;

    if (m_side)
    {
        player_record->type = trace ? TRACE : DIRECTIONAL;
        player_record->curSide = RIGHT;
    }
    else
    {
        player_record->type = trace ? TRACE : DIRECTIONAL;
        player_record->curSide = LEFT;
    }
}

float CResolver::GetChokedPackets()
{
    float simtime = player->m_flSimulationTime();
    float oldsimtime = player->m_flOldSimulationTime();
    float simdiff = simtime - oldsimtime;

    auto chokedpackets = TIME_TO_TICKS(max(0, simdiff));

    if (chokedpackets >= 1)
        return chokedpackets;

    return 0;
}

bool CResolver::DesyncDetect()
{
    if (!player->is_alive())
        return false;
    if (player->get_max_desync_delta() < 10)
        return false;
    if (!player->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
        return false;
    if (!player->m_hActiveWeapon().Get()->can_fire(true))
        return false;
    if (player->get_move_type() == MOVETYPE_NOCLIP || player->get_move_type() == MOVETYPE_LADDER)
        return false;

    return true;
}

bool CResolver::update_walk_data()
{
    auto e = player;
    float previous, m_previous;
    previous = m_previous;

    auto anim_layers = player_record->layers;
    bool s_1 = false,
        s_2 = false,
        s_3 = false;

    for (int i = 0; i < e->animlayer_count(); i++)
    {
        anim_layers[i] = e->get_animlayers()[i];
        if (anim_layers[i].m_nSequence == 26 && anim_layers[i].m_flWeight < 0.47f)
            s_1 = true;
        if (anim_layers[i].m_nSequence == 7 && anim_layers[i].m_flWeight > 0.001f)
            s_2 = true;
        if (anim_layers[i].m_nSequence == 2 && anim_layers[i].m_flWeight == 0)
            s_3 = true;
    }
    float  m_fakewalking;
    if (s_1 && s_2)
        if (s_3)
            m_fakewalking = true;
        else
            m_fakewalking = false;
    else
        m_fakewalking = false;

    return m_fakewalking;
}

bool ext = false;
void CResolver::setmode()
{
    auto e = player;

    auto rec_layer = player_record->layers;
    auto layer = resolver_layers;

    float speed = e->m_vecVelocity().Length2D();
   
   
    bool extending = IsAdjustingBalances(rec_layer, layer[15]);
    bool on_ground = e->m_fFlags() & FL_ONGROUND;

    bool slow_walking1 = is_slow_walking();
    bool slow_walking2 = update_walk_data();
   
   
    if (extending)
        ext = true;

    bool ducking = player->get_animation_state()->m_fDuckAmount && e->m_fFlags() & FL_ONGROUND && !player->get_animation_state()->m_bInHitGroundAnimation;

   

    bool stand_anim = false;
    if (player_record->layers[3].m_flWeight == 0.f && player_record->layers[3].m_flCycle == 0.f && player_record->layers[6].m_flWeight == 0.f)
        stand_anim = true;

    bool move_anim = false;
    if (int(player_record->layers[6].m_flWeight * 1000.f) == int(previous_layers[6].m_flWeight * 1000.f))
        move_anim = true;

    auto animstate = player->get_animation_state();
    if (!animstate)
        return;

    auto valid_move = true;
    if (animstate->m_velocity > 0.1f || fabs(animstate->flUpVelocity) > 100.f)
        valid_move = animstate->m_flTimeSinceStartedMoving < 0.22f;

    if (!on_ground)
    {
        player_record->curMode = AIR;
    }

    else if (!valid_move && move_anim || /*micromovement check pog*/ speed >= 3.0f && ducking || speed >= 1.1f && !ducking)
    {
        player_record->curMode = MOVING;
    }

    else if (valid_move && stand_anim || extending || /*micromovement check pog*/ speed < 3.0f && ducking || speed < 1.1f && !ducking)
    {
        player_record->curMode = STANDING;
    }
    else if (speed >= 1.1f && !ducking && (slow_walking1 || slow_walking2))
        player_record->curMode = SLOW_WALKING;
    else
        player_record->curMode = FREESTANDING;
}

bool CResolver::MatchShot()
{
    // do not attempt to do this in nospread mode.

    float shoot_time = -1.f;

    auto weapon = player->m_hActiveWeapon();
    if (weapon) {
        // with logging this time was always one tick behind.
        // so add one tick to the last shoot time.
        shoot_time = weapon->m_fLastShotTime() + m_globals()->m_intervalpertick;
    }

    // this record has a shot on it.
    if (TIME_TO_TICKS(shoot_time) == TIME_TO_TICKS(player->m_flSimulationTime()))
    {
        return true;
    }

    return false;
}

void CResolver::final_detection()
{
    switch (player_record->curMode)
    {
    case MOVING:
        get_side_moving();
        break;
    case STANDING:
        get_side_trace();
        break;
    case FREESTANDING:
        detect_side();
        break;
    case AIR:
        player_record->side = RESOLVER_ORIGINAL;
        player_record->curSide = NONE_CUR;
        break;
    case SLOW_WALKING:
        get_side_moving();
            break;

    }
}

static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
    Vector delta = a - b;
    float delta_length = delta.Length();

    if (delta_length <= min_delta)
    {
        Vector result;

        if (-min_delta <= delta_length)
            return a;
        else
        {
            float iradius = 1.0f / (delta_length + FLT_EPSILON);
            return b - ((delta * iradius) * min_delta);
        }
    }
    else
    {
        float iradius = 1.0f / (delta_length + FLT_EPSILON);
        return b + ((delta * iradius) * min_delta);
    }
};


float CResolver::build_yaw(player_t* player, float angle, int n)
{
    auto animState = player->get_animation_state();
    float m_flFakeGoalFeetYaw = 0.0f;
    // Rebuild setup velocity to receive flMinBodyYaw and flMaxBodyYaw
    Vector velocity = player->m_vecVelocity();
    float spd = velocity.LengthSqr();
    if (spd > std::powf(1.2f * 260.0f, 2.f)) {
        Vector velocity_normalized = velocity.Normalized();
        velocity = velocity_normalized * (1.2f * 260.0f);
    }

    float m_flChokedTime = animState->m_flLastClientSideAnimationUpdateTime;
    float v25 = math::clamp(player->m_flDuckAmount() + animState->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
    float v26 = animState->m_fDuckAmount;
    float v27 = m_flChokedTime * 6.0f;
    float v28;

    // clamp
    if ((v25 - v26) <= v27) {
        if (-v27 <= (v25 - v26))
            v28 = v25;
        else
            v28 = v26 - v27;
    }
    else {
        v28 = v26 + v27;
    }

    float flDuckAmount = math::clamp(v28, 0.0f, 1.0f);

    Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, player->m_vecVelocity());
    float speed = std::fminf(animationVelocity.Length(), 260.0f);

    auto weapon = player->m_hActiveWeapon();

    float flMaxMovementSpeed = 260.0f;
    if (weapon && weapon->get_csweapon_info()) {
        flMaxMovementSpeed = std::fmaxf(weapon->get_csweapon_info()->flMaxPlayerSpeed, 0.001f);
    }

    float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
    float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);

    flRunningSpeed = math::clamp(flRunningSpeed, 0.0f, 1.0f);

    float flYawModifier = (((animState->m_flStopToFullRunningFraction * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
    if (flDuckAmount > 0.0f) {
        float flDuckingSpeed = math::clamp(flDuckingSpeed, 0.0f, 1.0f);
        flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
    }

    auto test = animState->yaw_desync_adjustment();

    float flMinBodyYaw = -58.0f * flYawModifier;
    float flMaxBodyYaw = 58.0f * flYawModifier;

    float flEyeYaw = angle;
    float flEyeDiff = std::remainderf(flEyeYaw - m_flFakeGoalFeetYaw, 360.f);

    if (flEyeDiff <= flMaxBodyYaw) {
        if (flMinBodyYaw > flEyeDiff)
            m_flFakeGoalFeetYaw = fabs(flMinBodyYaw) + flEyeYaw;
    }
    else {
        m_flFakeGoalFeetYaw = flEyeYaw - fabs(flMaxBodyYaw);
    }

    m_flFakeGoalFeetYaw = std::remainderf(m_flFakeGoalFeetYaw, 360.f);

    if (speed > 0.1f || fabs(velocity.z) > 100.0f) {
        m_flFakeGoalFeetYaw = math::ApproachAngle(
            flEyeYaw,
            m_flFakeGoalFeetYaw,
            ((animState->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
            * m_flChokedTime);
    }
    else {
        m_flFakeGoalFeetYaw = math::ApproachAngle(
            player->m_flLowerBodyYawTarget(),
            m_flFakeGoalFeetYaw,
            m_flChokedTime * 100.0f);
    }

    float Left = flMinBodyYaw;
    float Right = flMaxBodyYaw;
    float middle = m_flFakeGoalFeetYaw;

    math::normalize_yaw(m_flFakeGoalFeetYaw);

    if (n == 1)
        return Left;
    else if (n == 2)
        return Right;
    else if (n == 3)
        return m_flFakeGoalFeetYaw;
}

void CResolver::resolve()
{


    bool mside;
    bool slow_walking = is_slow_walking();
    int chokedpackets = GetChokedPackets();

    auto pWeapon = player->m_hActiveWeapon();
    auto simtime = player->m_flSimulationTime();
    auto oldsimtime = player->m_flOldSimulationTime();
    float m_flLastShotTime;
    bool m_shot;
    m_flLastShotTime = pWeapon ? pWeapon->m_fLastShotTime() : 0.f;
    m_shot = m_flLastShotTime > oldsimtime && m_flLastShotTime <= simtime;

    bool should_detect = DesyncDetect();

    if (!should_detect || chokedpackets < 1)
        return;

    setmode();
    if (player->get_move_type() == MOVETYPE_LADDER || player->get_move_type() == MOVETYPE_NOCLIP)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }
    if (m_flLastShotTime <= simtime && m_shot || MatchShot())
    {
        player_record->side = RESOLVER_ON_SHOT;
        player_record->curSide = NONE_CUR;
        return;
    }

            if (g_ctx.globals.missed_shots[player->EntIndex()] == 0)
            {
                if (player_record->curstate != NOT_FLIPPED && player_record->curstate != FLIPPED)
                {
                    final_detection();
                    player_record->curstate = NOT_FLIPPED;
                }
               
                if (player_record->curdelta != MAX_DELTA && player_record->curdelta != LOW_DELTA)
                {
                    final_detection();
                    player_record->curdelta = MAX_DELTA;
                }
                else
                    final_detection();
            }
               
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 1)
            {
                final_detection();
                player_record->curdelta = LOW_DELTA;
                player_record->curstate = NOT_FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 2)
            {
                final_detection();
                player_record->curdelta = MAX_DELTA;
                player_record->curstate = FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 3)
            {
                final_detection();
                player_record->curdelta = LOW_DELTA;
                player_record->curstate = FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] >= 4)
            {
                player_record->curdelta = MAX_DELTA;
                player_record->curstate = NOT_FLIPPED;
               
                g_ctx.globals.missed_shots[player->EntIndex()] = 0;
            }

    if (player_record->curstate == FLIPPED)
    {
        if (player_record->curSide == RIGHT)
            player_record->curSide = LEFT;

        else if (player_record->curSide == LEFT)
            player_record->curSide = RIGHT;
    }

    if (player_record->curSide == RIGHT)
        mside=true;
    else if (player_record->curSide == LEFT)
        mside=false;
    else if (player_record->curSide == MIDDLE)
    {
        player_record->side = RESOLVER_ZERO;
        return;
    }
    else
        return;

    if (player_record->curdelta == LOW_DELTA)
        player_record->side = mside ? RESOLVER_LOW_FIRST : RESOLVER_LOW_SECOND;
    else if (player_record->curdelta == MAX_DELTA)
        player_record->side = mside ? RESOLVER_FIRST : RESOLVER_SECOND;
    else
        return;

    //TODO:- check curdelta for each side seperetaly because people might use low delta on the right and max delta on the left and jitter between them
}
GetMaxPlayerSpeed ?
 
Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include "animation_system.h"
#include "..\misc\misc.h"
#include "..\misc\logs.h"

std::deque <adjust_data> player_records[65];

void lagcompensation::fsn(ClientFrameStage_t stage)
{
    if (stage != FRAME_NET_UPDATE_END)
        return;

    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled)
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++)
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (e == g_ctx.local())
            continue;

        if (!valid(i, e))
            continue;

        auto time_delta = abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount);

        if (time_delta > 1.0f / m_globals()->m_intervalpertick)
            continue;

        if (player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime())
        {
            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
                for (auto& record : player_records[i])
                    record.invalid = true;

            player_records[i].emplace_front(adjust_data());
            update_player_animations(e);

            while (player_records[i].size() > 32)
                player_records[i].pop_back();
        }
    }
}

bool lagcompensation::valid(int i, player_t* e)
{
    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled || !e->valid(false))
    {
        if (!e->is_alive())
        {
            is_dormant[i] = false;
            //player_resolver[i].reset();

            //g_ctx.globals.fired_shots[i] = 0;
            //g_ctx.globals.missed_shots[i] = 0;
        }
        else if (e->IsDormant())
            is_dormant[i] = true;

        //player_records[i].clear();
        return false;
    }

    return true;
}




float build_server_abs_yaw(player_t* m_player, float angle, int n)
{
    Vector velocity = m_player->m_vecVelocity();
    auto anim_state = m_player->get_animation_state();
    float m_flEyeYaw = angle;
    float m_flGoalFeetYaw = 0.f;

    float eye_feet_delta = math::AngleDiff(m_flEyeYaw, m_flGoalFeetYaw);

    static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
        Vector delta = a - b;
        float delta_length = delta.Length();

        if (delta_length <= min_delta)
        {
            Vector result;

            if (-min_delta <= delta_length)
                return a;
            else
            {
                float iradius = 1.0f / (delta_length + FLT_EPSILON);
                return b - ((delta * iradius) * min_delta);
            }
        }
        else
        {
            float iradius = 1.0f / (delta_length + FLT_EPSILON);
            return b + ((delta * iradius) * min_delta);
        }
    };

    float spd = velocity.LengthSqr();

    if (spd > std::powf(1.2f * 260.0f, 2.f))
    {
        Vector velocity_normalized = velocity.Normalized();
        velocity = velocity_normalized * (1.2f * 260.0f);
    }

    float m_flChokedTime = anim_state->m_flLastClientSideAnimationUpdateTime;
    float v25 = std::clamp(m_player->m_flDuckAmount() + anim_state->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
    float v26 = anim_state->m_fDuckAmount;
    float v27 = m_flChokedTime * 6.0f;
    float v28;


    if ((v25 - v26) <= v27) {
        if (-v27 <= (v25 - v26))
            v28 = v25;
        else
            v28 = v26 - v27;
    }
    else {
        v28 = v26 + v27;
    }

    float flDuckAmount = std::clamp(v28, 0.0f, 1.0f);

    Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, m_player->m_vecVelocity());
    float speed = std::fminf(animationVelocity.Length(), 260.0f);

    float flMaxMovementSpeed = 260.0f;

    weapon_t* pWeapon = m_player->m_hActiveWeapon();

    if (pWeapon && pWeapon->get_csweapon_info())
        flMaxMovementSpeed = std::fmaxf(pWeapon->get_csweapon_info()->flMaxPlayerSpeedAlt, 0.001f);

    float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
    float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);

    flRunningSpeed = std::clamp(flRunningSpeed, 0.0f, 1.0f);

    float flYawModifier = (((anim_state->m_flStopToFullRunningFraction * -0.30000001) - 0.19999999) * flRunningSpeed) + 1.0f;

    if (flDuckAmount > 0.0f)
    {
        float flDuckingSpeed = std::clamp(flDuckingSpeed, 0.0f, 1.0f);
        flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
    }

    const float v60 = -58.0f;
    const float v61 = 58.0f;

    /*
    float flMaxBodyYaw = *reinterpret_cast<float*>(&animState->pad10[512]);
    float flMinBodyYaw = *reinterpret_cast<float*>(&animState->pad10[516]);
    */

    float flMinYawModifier = v60 * flYawModifier;
    float flMaxYawModifier = v61 * flYawModifier;

    if (eye_feet_delta <= flMaxYawModifier)
    {
        if (flMinYawModifier > eye_feet_delta)
            m_flGoalFeetYaw = fabs(flMinYawModifier) + m_flEyeYaw;
    }
    else
    {
        m_flGoalFeetYaw = m_flEyeYaw - fabs(flMaxYawModifier);
    }

    math::normalize_yaw(m_flGoalFeetYaw);

    if (speed > 0.1f || fabs(velocity.z) > 100.0f)
    {
        m_flGoalFeetYaw = math::ApproachAngle(
            m_flEyeYaw,
            m_flGoalFeetYaw,
            ((anim_state->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
            * m_flChokedTime);
    }
    else
    {
        m_flGoalFeetYaw = math::ApproachAngle(
            m_player->m_flLowerBodyYawTarget(),
            m_flGoalFeetYaw,
            m_flChokedTime * 100.0f);
    }

    if (n == 1)
        return m_flEyeYaw + flMinYawModifier;
    else if (n == 2)
        return m_flEyeYaw + flMaxYawModifier;
    else if (n == 3)
        return m_flGoalFeetYaw;

}
void lagcompensation::update_player_animations(player_t* e)
{
    auto animstate = e->get_animation_state();

    if (!animstate)
        return;

    player_info_t player_info;

    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
        return;

    auto records = &player_records[e->EntIndex()];

    if (records->empty())
        return;

    adjust_data* previous_record = nullptr;

    if (records->size() >= 2)
        previous_record = &records->at(1);

    auto record = &records->front();

    AnimationLayer animlayers[15];

    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
    auto backup_duck_amount = e->m_flDuckAmount();
    auto backup_flags = e->m_fFlags();
    auto backup_eflags = e->m_iEFlags();

    auto backup_curtime = m_globals()->m_curtime;
    auto backup_frametime = m_globals()->m_frametime;
    auto backup_realtime = m_globals()->m_realtime;
    auto backup_framecount = m_globals()->m_framecount;
    auto backup_tickcount = m_globals()->m_tickcount;
    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;

    m_globals()->m_curtime = e->m_flSimulationTime();
    m_globals()->m_frametime = m_globals()->m_intervalpertick;


    if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(record->flags & FL_ONGROUND))
            {
                velocity = (record->origin - previous_record->origin) / record->simulation_time;

                float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP].m_flWeight;

                if (flWeight > 0.0f)
                {
                    float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
                    float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;

                    if (flPreviousRate == flCurrentRate)
                    {
                        int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
                        int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;

                        if (iPreviousSequence == iCurrentSequence)
                        {
                            float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;

                            if (flSpeedNormalized > 0.0f)
                            {
                                float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();

                                if (flSpeed > 0.0f)
                                {
                                    if (velocity.Length2D() > 0.0f)
                                    {
                                        velocity.x /= velocity.Length2D() / flSpeed;
                                        velocity.y /= velocity.Length2D() / flSpeed;
                                    }
                                }
                            }
                        }
                    }
                }

                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
                velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
            }
            else
                velocity.z = 0.0f;
        }
    }
    else
    {
        //record->shot = record->last_shot_time == record->simulation_time;
    }

    e->m_iEFlags() &= ~0x1800;

    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
        e->m_vecVelocity().Zero();

    e->m_vecAbsVelocity() = e->m_vecVelocity();
    e->m_bClientSideAnimation() = true;

    if (is_dormant[e->EntIndex()])
    {
        is_dormant[e->EntIndex()] = false;

        if (e->m_fFlags() & FL_ONGROUND)
        {
            animstate->m_bOnGround = true;
            animstate->m_bInHitGroundAnimation = false;
        }

        animstate->time_since_in_air() = 0.0f;
        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    }

    auto updated_animations = false;

    c_baseplayeranimationstate state;
    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));

    if (previous_record)
    {
        memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));

        auto ticks_chocked = 1;
        auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);

        if (simulation_ticks > 0 && simulation_ticks < 31)
            ticks_chocked = simulation_ticks;

        if (ticks_chocked > 1)
        {
            auto land_time = 0.0f;
            auto land_in_cycle = false;
            auto is_landed = false;
            auto on_ground = false;

            if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
            {
                land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
                land_in_cycle = land_time >= previous_record->simulation_time;
            }

            auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;

            for (auto i = 0; i < ticks_chocked; ++i)
            {
                auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);

                if (duck_amount_per_tick)
                    e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;

                on_ground = e->m_fFlags() & FL_ONGROUND;

                if (land_in_cycle && !is_landed)
                {
                    if (land_time <= simulated_time)
                    {
                        is_landed = true;
                        on_ground = true;
                    }
                    else
                        on_ground = previous_record->flags & FL_ONGROUND;
                }

                if (on_ground)
                    e->m_fFlags() |= FL_ONGROUND;
                else
                    e->m_fFlags() &= ~FL_ONGROUND;

                auto simulated_ticks = TIME_TO_TICKS(simulated_time);

                m_globals()->m_realtime = simulated_time;
                m_globals()->m_curtime = simulated_time;
                m_globals()->m_framecount = simulated_ticks;
                m_globals()->m_tickcount = simulated_ticks;
                m_globals()->m_interpolation_amount = 0.0f;

                g_ctx.globals.updating_animation = true;
                e->update_clientside_animation();
                g_ctx.globals.updating_animation = false;

                m_globals()->m_realtime = backup_realtime;
                m_globals()->m_curtime = backup_curtime;
                m_globals()->m_framecount = backup_framecount;
                m_globals()->m_tickcount = backup_tickcount;
                m_globals()->m_interpolation_amount = backup_interpolation_amount;

                updated_animations = true;
            }
        }
    }

    if (!updated_animations)
    {
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
    }

    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));

    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
    {
        e->invalidate_physics_recursive(8);

        AnimationLayer backup_layers[15];
        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));

        switch (matrix)
        {
        case MAIN:
            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
            break;
        case NONE:
            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
            break;
        case FIRST:
            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
            break;
        case SECOND:
            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
            break;
        }

        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
    };

    if (g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled)
    {
        player_resolver[e->EntIndex()].initialize_yaw(e);

        /*rebuild setup velocity for more accurate rotations for the resolver and safepoints*/
        float left =  g_ctx.globals.left;
        float right = g_ctx.globals.right;
        float middle = g_ctx.globals.middle;
        // ------ \\

        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));



        // --- first --- \\

        animstate->m_flGoalFeetYaw = middle;
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, NONE);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[0] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\



        // --- second --- \\

        animstate->m_flGoalFeetYaw = math::normalize_yaw(right + e->EntIndex());
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, FIRST);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[2] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[2], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\




        // --- third --- \\

        animstate->m_flGoalFeetYaw = math::normalize_yaw(left + e->EntIndex());
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
        setup_matrix(e, animlayers, SECOND);
        player_resolver[e->EntIndex()].resolver_goal_feet_yaw[1] = animstate->m_flGoalFeetYaw;
        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
        memcpy(player_resolver[e->EntIndex()].resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
        // --- \\


       


        player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
        player_resolver[e->EntIndex()].resolve();

        auto eye = e->m_angEyeAngles().y;
        auto idx = e->EntIndex();
        switch (record->side)
        {
        case RESOLVER_ORIGINAL:
            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
            g_ctx.globals.mlog1[idx] = previous_goal_feet_yaw[e->EntIndex()];
            break;
        case RESOLVER_ZERO:
            animstate->m_flGoalFeetYaw = middle;
            g_ctx.globals.mlog1[idx] = middle;
            break;
        case RESOLVER_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(left + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(left);
            break;
        case RESOLVER_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(right + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(right);
            break;
        case RESOLVER_LOW_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(max(-10.0f , left * 0.5) + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(max(-10.0f, left * 0.5));
            break;
        case RESOLVER_LOW_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(min(10.0f, right * 0.5) + eye);
            g_ctx.globals.mlog1[idx] = math::normalize_yaw(min(10.0f, right * 0.5));
            break;
        case RESOLVER_ON_SHOT:
            animstate->m_flGoalFeetYaw = middle;
            g_ctx.globals.mlog1[idx] = middle;
            break;
        }


        /*switch (record->side)
        {
        case RESOLVER_ORIGINAL:
            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
            break;
        case RESOLVER_ZERO:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
            break;
        case RESOLVER_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + e->get_max_desync_delta());
            break;
        case RESOLVER_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - e->get_max_desync_delta());
            break;
        case RESOLVER_LOW_FIRST:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 25);
            break;
        case RESOLVER_LOW_SECOND:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 25);
            break;
        case RESOLVER_ON_SHOT:
            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
            break;
        }*/

        //e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();

    }

    g_ctx.globals.updating_animation = true;
    e->update_clientside_animation();
    g_ctx.globals.updating_animation = false;

    setup_matrix(e, animlayers, MAIN);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    setup_matrix(e, animlayers, FIRST);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.first, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    setup_matrix(e, animlayers, SECOND);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.second, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    m_globals()->m_curtime = backup_curtime;
    m_globals()->m_frametime = backup_frametime;

    e->m_flLowerBodyYawTarget() = backup_lower_body_yaw_target;
    e->m_flDuckAmount() = backup_duck_amount;
    e->m_fFlags() = backup_flags;
    e->m_iEFlags() = backup_eflags;

    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(player_resolver[e->EntIndex()].previous_layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
C++:
#pragma once

#include "..\..\includes.hpp"
#include "..\..\sdk\structs.hpp"


enum
{
    MAIN,
    NONE,
    FIRST,
    SECOND
};

enum resolver_type
{
    ORIGINAL,
    BRUTEFORCE,
    LBY,
    LAYERS,
    TRACE,
    DIRECTIONAL,
    ENGINE,
    FREESTAND,
    NON_RESOLVED
};
enum resolver_side
{
    RESOLVER_ORIGINAL,
    RESOLVER_ZERO,
    RESOLVER_FIRST,
    RESOLVER_SECOND,
    RESOLVER_LOW_FIRST,
    RESOLVER_LOW_SECOND,
    RESOLVER_ON_SHOT
};

enum modes
{
    NONE_SIDE,
    AIR,
    SLOW_WALKING,
    SLOW_WALKING_MAX,
    MOVING,
    STANDING,
    FREESTANDING
};

enum get_side_move
{
    MIDDLE,
    LEFT,
    RIGHT,
    NONE_CUR
};
enum curdelta
{
    LOW_DELTA,
    MAX_DELTA
};
enum curstate
{
    NOT_FLIPPED,
    FLIPPED
};

enum animstate_layer_t
{
    ANIMATION_LAYER_AIMMATRIX = 0,
    ANIMATION_LAYER_WEAPON_ACTION,
    ANIMATION_LAYER_WEAPON_ACTION_RECROUCH,
    ANIMATION_LAYER_ADJUST,
    ANIMATION_LAYER_MOVEMENT_JUMP_OR_FALL,
    ANIMATION_LAYER_MOVEMENT_LAND_OR_CLIMB,
    ANIMATION_LAYER_MOVEMENT_MOVE,
    ANIMATION_LAYER_MOVEMENT_STRAFECHANGE,
    ANIMATION_LAYER_WHOLE_BODY,
    ANIMATION_LAYER_FLASHED,
    ANIMATION_LAYER_FLINCH,
    ANIMATION_LAYER_ALIVELOOP,
    ANIMATION_LAYER_LEAN,
    ANIMATION_LAYER_COUNT,
};

struct matrixes
{
    matrix3x4_t main[MAXSTUDIOBONES];
    matrix3x4_t zero[MAXSTUDIOBONES];
    matrix3x4_t first[MAXSTUDIOBONES];
    matrix3x4_t second[MAXSTUDIOBONES];
};

class adjust_data;

class CResolver
{
    player_t* player = nullptr;
    adjust_data* player_record = nullptr;

    bool side = false;
    bool fake = false;
    bool was_first_bruteforce = false;
    bool was_second_bruteforce = false;

    float lock_side = 0.0f;
    float original_goal_feet_yaw = 0.0f;
    float original_pitch = 0.0f;

public:
    //void initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch);
    void initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch);
    void initialize_yaw(player_t* e);
    void reset();


    //bool is_choking(player_t* entity);
    bool ValidMove();
    void get_side_moving();
    void layer_test();
    void get_side_standing();
    void detect_side();
    void get_side_trace();
    float GetChokedPackets();
    bool DesyncDetect();
    bool update_walk_data();
    void setmode();
    bool MatchShot();
    bool is_slow_walking();
    void AntiFreestand();
    bool IsAdjustingBalances(AnimationLayer* record, AnimationLayer* layer);

    float ResolveShot();

    void final_detection();

    float build_yaw(player_t* player, float angle, int n);

    void resolve();


    AnimationLayer resolver_layers[3][15];
    AnimationLayer previous_layers[15];
    float resolver_goal_feet_yaw[3];

    resolver_side last_side = RESOLVER_ORIGINAL;
    float build_server_abs_yaw();
};


class adjust_data
{
public:
    player_t* player;
    int i;

    AnimationLayer layers[15];
    AnimationLayer side_layers[3][15];
    matrixes matrixes_data;
    get_side_move curSide;
    modes curMode;
    resolver_type type;
    resolver_side side;
    curdelta curdelta;
    curstate curstate;
    bool flipped_s;
    bool invalid;
    bool immune;
    bool dormant;
    bool bot;
   


    int flags;
    int bone_count;

    float simulation_time;
    float duck_amount;
    float lby;
    float left_side;
    float right_side;
    float maxrotation;
    float eyeyaw;

    Vector angles;
    Vector abs_angles;
    Vector velocity;
    Vector origin;
    Vector mins;
    Vector maxs;

    matrix3x4_t leftmatrixes[128] = {};
    matrix3x4_t rightmatrixes[128] = {};

    std::array<float, 24> left_poses = {};
    std::array<float, 24> right_poses = {};

    adjust_data()
    {
        reset();
    }

    void reset()
    {
        player = nullptr;
        i = -1;

        type = ORIGINAL;
        side = RESOLVER_ORIGINAL;

        invalid = false;
        immune = false;
        dormant = false;
        bot = false;

        flags = 0;
        bone_count = 0;

        simulation_time = 0.0f;
        duck_amount = 0.0f;
        lby = 0.0f;

        angles.Zero();
        abs_angles.Zero();
        velocity.Zero();
        origin.Zero();
        mins.Zero();
        maxs.Zero();
    }

    adjust_data(player_t* e, bool store = true)
    {
        type = ORIGINAL;
        side = RESOLVER_ORIGINAL;

        invalid = false;
        store_data(e, store);
    }

    void store_data(player_t* e, bool store = true)
    {
        if (!e->is_alive())
            return;
   
        player = e;
        i = player->EntIndex();

        if (store)
        {
            memcpy(layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
            memcpy(matrixes_data.main, player->m_CachedBoneData().Base(), player->m_CachedBoneData().Count() * sizeof(matrix3x4_t));
        }

        immune = player->m_bGunGameImmunity() || player->m_fFlags() & FL_FROZEN;
        dormant = player->IsDormant();

        bot = false;

        flags = player->m_fFlags();
        bone_count = player->m_CachedBoneData().Count();

        simulation_time = player->m_flSimulationTime();
        duck_amount = player->m_flDuckAmount();
        lby = player->m_flLowerBodyYawTarget();

        angles = player->m_angEyeAngles();
        abs_angles = player->GetAbsAngles();
        velocity = player->m_vecVelocity();
        origin = player->m_vecOrigin();
        mins = player->GetCollideable()->OBBMins();
        maxs = player->GetCollideable()->OBBMaxs();
    }

    void adjust_player()
    {
        if (!valid(false))
            return;

        memcpy(player->get_animlayers(), layers, player->animlayer_count() * sizeof(AnimationLayer));
        memcpy(player->m_CachedBoneData().Base(), matrixes_data.main, player->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

        player->m_fFlags() = flags;
        player->m_CachedBoneData().m_Size = bone_count;

        player->m_flSimulationTime() = simulation_time;
        player->m_flDuckAmount() = duck_amount;
        player->m_flLowerBodyYawTarget() = lby;

        player->m_angEyeAngles() = angles;
        player->set_abs_angles(abs_angles);
        player->m_vecVelocity() = velocity;
        player->m_vecOrigin() = origin;
        player->set_abs_origin(origin);
        player->GetCollideable()->OBBMins() = mins;
        player->GetCollideable()->OBBMaxs() = maxs;
    }

    bool valid(bool extra_checks = true)
    {
        if (!this)
            return false;

        if (i > 0)
            player = (player_t*)m_entitylist()->GetClientEntity(i);

        if (!player)
            return false;

        if (player->m_lifeState() != LIFE_ALIVE)
            return false;

        if (immune)
            return false;

        if (dormant)
            return false;

        if (!extra_checks)
            return true;

        if (invalid)
            return false;

        auto net_channel_info = m_engine()->GetNetChannelInfo();

        if (!net_channel_info)
            return false;

        static auto sv_maxunlag = m_cvar()->FindVar(crypt_str("sv_maxunlag"));

        auto outgoing = net_channel_info->GetLatency(FLOW_OUTGOING);
        auto incoming = net_channel_info->GetLatency(FLOW_INCOMING);

        auto correct = math::clamp(outgoing + incoming + util::get_interpolation(), 0.0f, sv_maxunlag->GetFloat());
       
        auto curtime = g_ctx.local()->is_alive() ? TICKS_TO_TIME(g_ctx.globals.fixed_tickbase) : m_globals()->m_curtime;
        auto delta_time = correct - (curtime - simulation_time);

        if (fabs(delta_time) > 0.2f)
            return false;

        auto extra_choke = 0;

        if (g_ctx.globals.fakeducking)
            extra_choke = 14 - m_clientstate()->iChokedCommands;

        auto server_tickcount = extra_choke + m_globals()->m_tickcount + TIME_TO_TICKS(outgoing + incoming);
        auto dead_time = (int)(TICKS_TO_TIME(server_tickcount) - sv_maxunlag->GetFloat());

        if (simulation_time < (float)dead_time)
            return false;

        return true;
    }
};

class optimized_adjust_data
{
public:
    int i;
    player_t*player;

    float simulation_time;
    float duck_amount;

    vector angles;
    vector origin;

    optimized_adjust_data()
    {
        reset();
    }

    void reset()
    {
        i = 0;
        player = nullptr;

        simulation_time = 0.0f;
        duck_amount = 0.0f;

        angles Zero();
        origin.zero();
    }
};

class lag data
{
    c_baseplayeranimationstate* animstate;
public:
    float side;
    float realtime = animstate->m_flLastClientSideAnimationUpdateTime;
    float resolving_way;
};

extern std::deque <adjust_data> player_records[65];

class lagcompensation : public singleton <lagcompensation>
{
public:
    void fsn(ClientFrameStage_tstage);
    void do_anim_event(player_t* pl, c_baseplayeranimationstate* state, int order, int activity);
    void extrapolation(player_t* player, Vector& origin, Vector& velocity, int& flags, bool on_ground);
    bool valid(int i, player_t*e);
    void update_player_animations(player_t*e);

    CResolver player_resolver[65];

    bool is_dormant[65];
    float previous_goal_feet_yaw[65];
};
C++:
#include "animation_system.h"
#include "..\ragebot\aim.h"
#include "../visuals/player_esp.h"

/*RESOLVER BY LAITH*/
void CResolver::initialize(player_t* e, adjust_data* record, const float& goal_feet_yaw, const float& pitch)
{
    player = e;
    player_record = record;

    original_pitch = math::normalize_pitch(pitch);
    original_goal_feet_yaw = math::normalize_yaw(goal_feet_yaw);
}

void CResolver::initialize_yaw(player_t* e)
{
    player = e;

    g_ctx.globals.left = build_yaw(player, player->m_angEyeAngles().y, 1);
    g_ctx.globals.right = build_yaw(player, player->m_angEyeAngles().y, 2);
    g_ctx.globals.middle = build_yaw(player, player->m_angEyeAngles().y, 3);
}

void CResolver::reset()
{
    fake = false;
    was_first_bruteforce = false;
    was_second_bruteforce = false;
    original_goal_feet_yaw = 0.0f;
    original_pitch = 0.0f;
}

bool CResolver::IsAdjustingBalances(AnimationLayer* record, AnimationLayer* layer)
{
    AnimationLayer animationLayer[15];
    for (int i = 0; i; i++)
    {
        const int activity = player->sequence_activity(animationLayer[i].m_nSequence);
        if (activity == 979)
        {
            *layer = animationLayer[i];
            return true;
        }
    }
    return false;
}



bool CResolver::is_slow_walking()
{
    auto entity = player;
    //float large = 0;
    float velocity_2D[64], old_velocity_2D[64];
    if (entity->m_vecVelocity().Length2D() != velocity_2D[entity->EntIndex()] && entity->m_vecVelocity().Length2D() != NULL) {
        old_velocity_2D[entity->EntIndex()] = velocity_2D[entity->EntIndex()];
        velocity_2D[entity->EntIndex()] = entity->m_vecVelocity().Length2D();
    }
    //if (large == 0)return false;
    Vector velocity = entity->m_vecVelocity();
    Vector direction = entity->m_angEyeAngles();

    float speed = velocity.Length();
    direction.y = entity->m_angEyeAngles().y - direction.y;
    //method 1
    if (velocity_2D[entity->EntIndex()] > 1) {
        int tick_counter[64];
        if (velocity_2D[entity->EntIndex()] == old_velocity_2D[entity->EntIndex()])
            tick_counter[entity->EntIndex()] += 1;
        else
            tick_counter[entity->EntIndex()] = 0;

        while (tick_counter[entity->EntIndex()] > (1 / m_globals()->m_intervalpertick) * fabsf(0.1f))//should give use 100ms in ticks if their speed stays the same for that long they are definetely up to something..
            return true;
    }


    return false;
}



void CResolver::get_side_moving()
{
    player_record->type = LAYERS;
    float delta_first = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[0][6].m_flPlaybackRate);
    float delta_second = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[2][6].m_flPlaybackRate);
    float delta_third = abs(player_record->layers[6].m_flPlaybackRate - resolver_layers[1][6].m_flPlaybackRate);

    if (delta_first < delta_second || delta_third <= delta_second)
    {
        if (delta_first >= delta_third && delta_second > delta_third)
            player_record->curSide = RIGHT;

        else
            detect_side();

    }
    else
        player_record->curSide = LEFT;


}

void CResolver::get_side_standing()
{
   
    player_record->type = LBY;

    float angle_difference = math::AngleDiff(player->m_angEyeAngles().y, original_goal_feet_yaw);
    player_record->curSide = 2 * angle_difference <= 0.0f ? RIGHT : LEFT;
}

float get_backward_side(player_t* player)
{
    return math::calculate_angle(g_ctx.local()->m_vecOrigin(), player->m_vecOrigin()).y;
}

void CResolver::detect_side()
{
    player_record->type = ENGINE;
    /* externs */
    Vector src3D, dst3D, forward, right, up, src, dst;
    float back_two, right_two, left_two;
    CGameTrace tr;
    CTraceFilter filter;

    /* angle vectors */
    math::angle_vectors(Vector(0, get_backward_side(player), 0), &forward, &right, &up);

    /* filtering */
    filter.pSkip = player;
    src3D = player->get_shoot_position();
    dst3D = src3D + (forward * 384);

    /* back engine tracers */
    m_trace()->TraceRay(Ray_t(src3D, dst3D), MASK_SHOT, &filter, &tr);
    back_two = (tr.endpos - tr.startpos).Length();

    /* right engine tracers */
    m_trace()->TraceRay(Ray_t(src3D + right * 35, dst3D + right * 35), MASK_SHOT, &filter, &tr);
    right_two = (tr.endpos - tr.startpos).Length();

    /* left engine tracers */
    m_trace()->TraceRay(Ray_t(src3D - right * 35, dst3D - right * 35), MASK_SHOT, &filter, &tr);
    left_two = (tr.endpos - tr.startpos).Length();

    /* fix side */
    if (left_two > right_two) {
        player_record->curSide = LEFT;
    }
    else if (right_two > left_two) {
        player_record->curSide = RIGHT;
    }
    else
        get_side_trace();
}

void CResolver::get_side_trace()
{
    auto m_side = false;
    auto trace = false;
    if (m_globals()->m_curtime - lock_side > 2.0f)
    {
        auto first_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first), player, g_ctx.local());
        auto second_visible = util::visible(g_ctx.globals.eye_pos, player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second), player, g_ctx.local());

        if (first_visible != second_visible)
        {
            trace = true;
            m_side = second_visible;
            lock_side = m_globals()->m_curtime;
        }
        else
        {
            auto first_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.first));
            auto second_position = g_ctx.globals.eye_pos.DistTo(player->hitbox_position_matrix(HITBOX_HEAD, player_record->matrixes_data.second));

            if (fabs(first_position - second_position) > 1.0f)
                m_side = first_position > second_position;
        }
    }
    else
        trace = true;

    if (m_side)
    {
        player_record->type = trace ? TRACE : DIRECTIONAL;
        player_record->curSide = RIGHT;
    }
    else
    {
        player_record->type = trace ? TRACE : DIRECTIONAL;
        player_record->curSide = LEFT;
    }
}

float CResolver::GetChokedPackets()
{
    float simtime = player->m_flSimulationTime();
    float oldsimtime = player->m_flOldSimulationTime();
    float simdiff = simtime - oldsimtime;

    auto chokedpackets = TIME_TO_TICKS(max(0, simdiff));

    if (chokedpackets >= 1)
        return chokedpackets;

    return 0;
}

bool CResolver::DesyncDetect()
{
    if (!player->is_alive())
        return false;
    if (player->get_max_desync_delta() < 10)
        return false;
    if (!player->m_iTeamNum() == g_ctx.local()->m_iTeamNum())
        return false;
    if (!player->m_hActiveWeapon().Get()->can_fire(true))
        return false;
    if (player->get_move_type() == MOVETYPE_NOCLIP || player->get_move_type() == MOVETYPE_LADDER)
        return false;

    return true;
}

bool CResolver::update_walk_data()
{
    auto e = player;
    float previous, m_previous;
    previous = m_previous;

    auto anim_layers = player_record->layers;
    bool s_1 = false,
        s_2 = false,
        s_3 = false;

    for (int i = 0; i < e->animlayer_count(); i++)
    {
        anim_layers[i] = e->get_animlayers()[i];
        if (anim_layers[i].m_nSequence == 26 && anim_layers[i].m_flWeight < 0.47f)
            s_1 = true;
        if (anim_layers[i].m_nSequence == 7 && anim_layers[i].m_flWeight > 0.001f)
            s_2 = true;
        if (anim_layers[i].m_nSequence == 2 && anim_layers[i].m_flWeight == 0)
            s_3 = true;
    }
    float  m_fakewalking;
    if (s_1 && s_2)
        if (s_3)
            m_fakewalking = true;
        else
            m_fakewalking = false;
    else
        m_fakewalking = false;

    return m_fakewalking;
}

bool ext = false;
void CResolver::setmode()
{
    auto e = player;

    auto rec_layer = player_record->layers;
    auto layer = resolver_layers;

    float speed = e->m_vecVelocity().Length2D();
   
   
    bool extending = IsAdjustingBalances(rec_layer, layer[15]);
    bool on_ground = e->m_fFlags() & FL_ONGROUND;

    bool slow_walking1 = is_slow_walking();
    bool slow_walking2 = update_walk_data();
   
   
    if (extending)
        ext = true;

    bool ducking = player->get_animation_state()->m_fDuckAmount && e->m_fFlags() & FL_ONGROUND && !player->get_animation_state()->m_bInHitGroundAnimation;

   

    bool stand_anim = false;
    if (player_record->layers[3].m_flWeight == 0.f && player_record->layers[3].m_flCycle == 0.f && player_record->layers[6].m_flWeight == 0.f)
        stand_anim = true;

    bool move_anim = false;
    if (int(player_record->layers[6].m_flWeight * 1000.f) == int(previous_layers[6].m_flWeight * 1000.f))
        move_anim = true;

    auto animstate = player->get_animation_state();
    if (!animstate)
        return;

    auto valid_move = true;
    if (animstate->m_velocity > 0.1f || fabs(animstate->flUpVelocity) > 100.f)
        valid_move = animstate->m_flTimeSinceStartedMoving < 0.22f;

    if (!on_ground)
    {
        player_record->curMode = AIR;
    }

    else if (!valid_move && move_anim || /*micromovement check pog*/ speed >= 3.0f && ducking || speed >= 1.1f && !ducking)
    {
        player_record->curMode = MOVING;
    }

    else if (valid_move && stand_anim || extending || /*micromovement check pog*/ speed < 3.0f && ducking || speed < 1.1f && !ducking)
    {
        player_record->curMode = STANDING;
    }
    else if (speed >= 1.1f && !ducking && (slow_walking1 || slow_walking2))
        player_record->curMode = SLOW_WALKING;
    else
        player_record->curMode = FREESTANDING;
}

bool CResolver::MatchShot()
{
    // do not attempt to do this in nospread mode.

    float shoot_time = -1.f;

    auto weapon = player->m_hActiveWeapon();
    if (weapon) {
        // with logging this time was always one tick behind.
        // so add one tick to the last shoot time.
        shoot_time = weapon->m_fLastShotTime() + m_globals()->m_intervalpertick;
    }

    // this record has a shot on it.
    if (TIME_TO_TICKS(shoot_time) == TIME_TO_TICKS(player->m_flSimulationTime()))
    {
        return true;
    }

    return false;
}

void CResolver::final_detection()
{
    switch (player_record->curMode)
    {
    case MOVING:
        get_side_moving();
        break;
    case STANDING:
        get_side_trace();
        break;
    case FREESTANDING:
        detect_side();
        break;
    case AIR:
        player_record->side = RESOLVER_ORIGINAL;
        player_record->curSide = NONE_CUR;
        break;
    case SLOW_WALKING:
        get_side_moving();
            break;

    }
}

static auto GetSmoothedVelocity = [](float min_delta, Vector a, Vector b) {
    Vector delta = a - b;
    float delta_length = delta.Length();

    if (delta_length <= min_delta)
    {
        Vector result;

        if (-min_delta <= delta_length)
            return a;
        else
        {
            float iradius = 1.0f / (delta_length + FLT_EPSILON);
            return b - ((delta * iradius) * min_delta);
        }
    }
    else
    {
        float iradius = 1.0f / (delta_length + FLT_EPSILON);
        return b + ((delta * iradius) * min_delta);
    }
};


float CResolver::build_yaw(player_t* player, float angle, int n)
{
    auto animState = player->get_animation_state();
    float m_flFakeGoalFeetYaw = 0.0f;
    // Rebuild setup velocity to receive flMinBodyYaw and flMaxBodyYaw
    Vector velocity = player->m_vecVelocity();
    float spd = velocity.LengthSqr();
    if (spd > std::powf(1.2f * 260.0f, 2.f)) {
        Vector velocity_normalized = velocity.Normalized();
        velocity = velocity_normalized * (1.2f * 260.0f);
    }

    float m_flChokedTime = animState->m_flLastClientSideAnimationUpdateTime;
    float v25 = math::clamp(player->m_flDuckAmount() + animState->m_fLandingDuckAdditiveSomething, 0.0f, 1.0f);
    float v26 = animState->m_fDuckAmount;
    float v27 = m_flChokedTime * 6.0f;
    float v28;

    // clamp
    if ((v25 - v26) <= v27) {
        if (-v27 <= (v25 - v26))
            v28 = v25;
        else
            v28 = v26 - v27;
    }
    else {
        v28 = v26 + v27;
    }

    float flDuckAmount = math::clamp(v28, 0.0f, 1.0f);

    Vector animationVelocity = GetSmoothedVelocity(m_flChokedTime * 2000.0f, velocity, player->m_vecVelocity());
    float speed = std::fminf(animationVelocity.Length(), 260.0f);

    auto weapon = player->m_hActiveWeapon();

    float flMaxMovementSpeed = 260.0f;
    if (weapon && weapon->get_csweapon_info()) {
        flMaxMovementSpeed = std::fmaxf(weapon->get_csweapon_info()->flMaxPlayerSpeed, 0.001f);
    }

    float flRunningSpeed = speed / (flMaxMovementSpeed * 0.520f);
    float flDuckingSpeed = speed / (flMaxMovementSpeed * 0.340f);

    flRunningSpeed = math::clamp(flRunningSpeed, 0.0f, 1.0f);

    float flYawModifier = (((animState->m_flStopToFullRunningFraction * -0.3f) - 0.2f) * flRunningSpeed) + 1.0f;
    if (flDuckAmount > 0.0f) {
        float flDuckingSpeed = math::clamp(flDuckingSpeed, 0.0f, 1.0f);
        flYawModifier += (flDuckAmount * flDuckingSpeed) * (0.5f - flYawModifier);
    }

    auto test = animState->yaw_desync_adjustment();

    float flMinBodyYaw = -58.0f * flYawModifier;
    float flMaxBodyYaw = 58.0f * flYawModifier;

    float flEyeYaw = angle;
    float flEyeDiff = std::remainderf(flEyeYaw - m_flFakeGoalFeetYaw, 360.f);

    if (flEyeDiff <= flMaxBodyYaw) {
        if (flMinBodyYaw > flEyeDiff)
            m_flFakeGoalFeetYaw = fabs(flMinBodyYaw) + flEyeYaw;
    }
    else {
        m_flFakeGoalFeetYaw = flEyeYaw - fabs(flMaxBodyYaw);
    }

    m_flFakeGoalFeetYaw = std::remainderf(m_flFakeGoalFeetYaw, 360.f);

    if (speed > 0.1f || fabs(velocity.z) > 100.0f) {
        m_flFakeGoalFeetYaw = math::ApproachAngle(
            flEyeYaw,
            m_flFakeGoalFeetYaw,
            ((animState->m_flStopToFullRunningFraction * 20.0f) + 30.0f)
            * m_flChokedTime);
    }
    else {
        m_flFakeGoalFeetYaw = math::ApproachAngle(
            player->m_flLowerBodyYawTarget(),
            m_flFakeGoalFeetYaw,
            m_flChokedTime * 100.0f);
    }

    float Left = flMinBodyYaw;
    float Right = flMaxBodyYaw;
    float middle = m_flFakeGoalFeetYaw;

    math::normalize_yaw(m_flFakeGoalFeetYaw);

    if (n == 1)
        return Left;
    else if (n == 2)
        return Right;
    else if (n == 3)
        return m_flFakeGoalFeetYaw;
}

void CResolver::resolve()
{


    bool mside;
    bool slow_walking = is_slow_walking();
    int chokedpackets = GetChokedPackets();

    auto pWeapon = player->m_hActiveWeapon();
    auto simtime = player->m_flSimulationTime();
    auto oldsimtime = player->m_flOldSimulationTime();
    float m_flLastShotTime;
    bool m_shot;
    m_flLastShotTime = pWeapon ? pWeapon->m_fLastShotTime() : 0.f;
    m_shot = m_flLastShotTime > oldsimtime && m_flLastShotTime <= simtime;

    bool should_detect = DesyncDetect();

    if (!should_detect || chokedpackets < 1)
        return;

    setmode();
    if (player->get_move_type() == MOVETYPE_LADDER || player->get_move_type() == MOVETYPE_NOCLIP)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }
    if (m_flLastShotTime <= simtime && m_shot || MatchShot())
    {
        player_record->side = RESOLVER_ON_SHOT;
        player_record->curSide = NONE_CUR;
        return;
    }

            if (g_ctx.globals.missed_shots[player->EntIndex()] == 0)
            {
                if (player_record->curstate != NOT_FLIPPED && player_record->curstate != FLIPPED)
                {
                    final_detection();
                    player_record->curstate = NOT_FLIPPED;
                }
               
                if (player_record->curdelta != MAX_DELTA && player_record->curdelta != LOW_DELTA)
                {
                    final_detection();
                    player_record->curdelta = MAX_DELTA;
                }
                else
                    final_detection();
            }
               
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 1)
            {
                final_detection();
                player_record->curdelta = LOW_DELTA;
                player_record->curstate = NOT_FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 2)
            {
                final_detection();
                player_record->curdelta = MAX_DELTA;
                player_record->curstate = FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] == 3)
            {
                final_detection();
                player_record->curdelta = LOW_DELTA;
                player_record->curstate = FLIPPED;
            }
            else if (g_ctx.globals.missed_shots[player->EntIndex()] >= 4)
            {
                player_record->curdelta = MAX_DELTA;
                player_record->curstate = NOT_FLIPPED;
               
                g_ctx.globals.missed_shots[player->EntIndex()] = 0;
            }

    if (player_record->curstate == FLIPPED)
    {
        if (player_record->curSide == RIGHT)
            player_record->curSide = LEFT;

        else if (player_record->curSide == LEFT)
            player_record->curSide = RIGHT;
    }

    if (player_record->curSide == RIGHT)
        mside=true;
    else if (player_record->curSide == LEFT)
        mside=false;
    else if (player_record->curSide == MIDDLE)
    {
        player_record->side = RESOLVER_ZERO;
        return;
    }
    else
        return;

    if (player_record->curdelta == LOW_DELTA)
        player_record->side = mside ? RESOLVER_LOW_FIRST : RESOLVER_LOW_SECOND;
    else if (player_record->curdelta == MAX_DELTA)
        player_record->side = mside ? RESOLVER_FIRST : RESOLVER_SECOND;
    else
        return;

    //TODO:- check curdelta for each side seperetaly because people might use low delta on the right and max delta on the left and jitter between them
}
shit.
Дефолт лв без пасты итд
ну нам то похуй помогать тебе или нет
я просил тебя код кинуть
мне похуй дефолт лв без пасты и тд.........
 
Начинающий
Статус
Оффлайн
Регистрация
14 Янв 2022
Сообщения
21
Реакции[?]
1
Поинты[?]
0
shit.

ну нам то похуй помогать тебе или нет
я просил тебя код кинуть
мне похуй дефолт лв без пасты и тд.........
Код:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include "animation_system.h"
#include "..\misc\misc.h"
#include "..\misc\logs.h"

std::deque <adjust_data> player_records[65];

//void lagcompensation::fsn(ClientFrameStage_t stage)
//{
//    if (stage != FRAME_NET_UPDATE_END)
//        return;
//
//    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled)
//        return;
//
//    for (auto i = 1; i < m_globals()->m_maxclients; i++) //-V807
//    {
//        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));
//
//        if (e == g_ctx.local())
//            continue;
//
//        if (!valid(i, e))
//            continue;
//
//        auto time_delta = abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount);
//
//        if (time_delta > 1.0f / m_globals()->m_intervalpertick)
//            continue;
//
//        auto update = player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime(); //-V550
//
//        //if (update && !player_records[i].empty())
//        //{
//        //    auto server_tick = m_clientstate()->m_iServerTick - i % m_globals()->m_timestamprandomizewindow;
//        //    auto current_tick = server_tick - server_tick % m_globals()->m_timestampnetworkingbase;
//        //
//        //    if (TIME_TO_TICKS(e->m_flOldSimulationTime()) < current_tick && TIME_TO_TICKS(e->m_flSimulationTime()) == current_tick)
//        //    {
//        //        auto layer = &e->get_animlayers()[11];
//        //        auto previous_layer = &player_records[i].front().layers[11];
//        //
//        //        if (layer->m_flCycle == previous_layer->m_flCycle) //-V550
//        //        {
//        //            e->m_flSimulationTime() = e->m_flOldSimulationTime();
//        //            update = false;
//        //        }
//        //    }
//        //}
//
//        if (update) //-V550
//        {
//            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
//                for (auto& record : player_records[i])
//                    record.invalid = true;
//
//            player_records[i].emplace_front(adjust_data());
//            update_player_animations(e);
//
//            while (player_records[i].size() > 32)
//                player_records[i].pop_back();
//        }
//    }
//}

void lagcompensation::fsn(ClientFrameStage_t stage)
{
    if (stage != FRAME_NET_UPDATE_END)
        return;

    if (!g_cfg.ragebot.enable/* && !g_cfg.legitbot.enabled*/) //LEGITBOT DELETE
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++)
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (e == g_ctx.local())
            continue;

        if (!valid(i, e))
            continue;

        if (abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount) > 1.0f / m_globals()->m_intervalpertick)
            continue;

        if (player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime())
        {
            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
                for (auto& record : player_records[i])
                    record.invalid = true;

            player_records[i].emplace_front(adjust_data());
            update_player_animations(e);

            while (player_records[i].size() > 32)
                player_records[i].pop_back();
        }
    }
}

bool lagcompensation::valid(int i, player_t* e)
{
    if (!g_cfg.ragebot.enable /*&& !g_cfg.legitbot.enabled */|| !e->valid(false)) //LEGITBOT DELETE
    {
        if (!e->is_alive())
        {
            is_dormant[i] = false;
            player_resolver[i].reset();

            g_ctx.globals.fired_shots[i] = 0;
            g_ctx.globals.missed_shots[i] = 0;
        }
        else if (e->IsDormant())
            is_dormant[i] = true;

        player_records[i].clear();
        return false;
    }

    return true;
}

//void lagcompensation::update_player_animations(player_t* e)
//{
//    auto animstate = e->get_animation_state();
//
//    if (!animstate)
//        return;
//
//    player_info_t player_info;
//
//    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
//        return;
//
//    auto records = &player_records[e->EntIndex()]; //-V826
//
//    if (records->empty())
//        return;
//
//    adjust_data* previous_record = nullptr;
//
//    if (records->size() >= 2)
//        previous_record = &records->at(1);
//
//    auto record = &records->front();
//
//    AnimationLayer animlayers[15];
//
//    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
//    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));
//
//    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
//    auto backup_duck_amount = e->m_flDuckAmount();
//    auto backup_flags = e->m_fFlags();
//    auto backup_eflags = e->m_iEFlags();
//
//    auto backup_curtime = m_globals()->m_curtime; //-V807
//    auto backup_frametime = m_globals()->m_frametime;
//    auto backup_realtime = m_globals()->m_realtime;
//    auto backup_framecount = m_globals()->m_framecount;
//    auto backup_tickcount = m_globals()->m_tickcount;
//    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;
//
//    m_globals()->m_curtime = e->m_flSimulationTime();
//    m_globals()->m_frametime = m_globals()->m_intervalpertick;
//
//    if (previous_record)
//    {
//        auto velocity = e->m_vecVelocity();
//        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;
//
//        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
//        auto origin_delta = e->m_vecOrigin() - previous_record->origin;
//
//        auto animation_speed = 0.0f;
//
//        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
//        {
//            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);
//
//            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
//            {
//                auto weapon = e->m_hActiveWeapon().Get();
//
//                if (weapon)
//                {
//                    auto max_speed = 260.0f;
//                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();
//
//                    if (weapon_info)
//                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;
//
//                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);
//
//                    if (modifier > 0.0f && modifier < 1.0f)
//                        animation_speed = max_speed * (modifier + 0.55f);
//                }
//            }
//
//            if (animation_speed > 0.0f)
//            {
//                animation_speed /= e->m_vecVelocity().Length2D();
//
//                e->m_vecVelocity().x *= animation_speed;
//                e->m_vecVelocity().y *= animation_speed;
//            }
//
//            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
//            {
//                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);
//
//                if (!previous_velocity.IsZero() && !was_in_air)
//                {
//                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
//                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));
//
//                    auto average_direction = current_direction - previous_direction;
//                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));
//
//                    auto direction_cos = cos(average_direction);
//                    auto dirrection_sin = sin(average_direction);
//
//                    auto velocity_speed = e->m_vecVelocity().Length2D();
//
//                    e->m_vecVelocity().x = direction_cos * velocity_speed;
//                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
//                }
//            }
//
//            if (!(e->m_fFlags() & FL_ONGROUND))
//            {
//                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
//
//                auto fixed_timing = math::clamp(time_difference, m_globals()->m_intervalpertick, 1.0f);
//                e->m_vecVelocity().z -= sv_gravity->GetFloat() * fixed_timing * 0.5f;
//            }
//            else
//                e->m_vecVelocity().z = 0.0f;
//        }
//    }
//
//    e->m_iEFlags() &= ~0x1800;
//
//    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
//        e->m_vecVelocity().Zero();
//
//    e->m_vecAbsVelocity() = e->m_vecVelocity();
//    e->m_bClientSideAnimation() = true;
//
//    if (is_dormant[e->EntIndex()])
//    {
//        is_dormant[e->EntIndex()] = false;
//
//        if (e->m_fFlags() & FL_ONGROUND)
//        {
//            animstate->m_bOnGround = true;
//            animstate->m_bInHitGroundAnimation = false;
//        }
//
//        animstate->time_since_in_air() = 0.0f;
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
//    }
//
//    auto updated_animations = false;
//
//    c_baseplayeranimationstate state;
//    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));
//
//    if (previous_record)
//    {
//        memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));
//
//        auto ticks_chocked = 1;
//        auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);
//
//        if (simulation_ticks > 0 && simulation_ticks < 31)
//            ticks_chocked = simulation_ticks;
//
//        if (ticks_chocked > 1)
//        {
//            auto land_time = 0.0f;
//            auto land_in_cycle = false;
//            auto is_landed = false;
//            auto on_ground = false;
//
//            if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
//            {
//                land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
//                land_in_cycle = land_time >= previous_record->simulation_time;
//            }
//
//            auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;
//
//            for (auto i = 0; i < ticks_chocked; ++i)
//            {
//                //auto lby_delta = fabs(math::normalize_yaw(e->m_flLowerBodyYawTarget() - previous_record->lby));
//                //
//                //if (lby_delta > 0.0f && e->m_vecVelocity().Length() < 5.0f)
//                //{
//                //    auto delta = ticks_chocked - i;
//                //    auto use_new_lby = true;
//                //
//                //    if (lby_delta < 1.0f)
//                //        use_new_lby = !delta; //-V547
//                //    else
//                //        use_new_lby = delta < 2;
//                //
//                //    e->m_flLowerBodyYawTarget() = use_new_lby ? backup_lower_body_yaw_target : previous_record->lby;
//                //}
//
//                auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);
//
//                if (duck_amount_per_tick) //-V550
//                    e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;
//
//                on_ground = e->m_fFlags() & FL_ONGROUND;
//
//                if (land_in_cycle && !is_landed)
//                {
//                    if (land_time <= simulated_time)
//                    {
//                        is_landed = true;
//                        on_ground = true;
//                    }
//                    else
//                        on_ground = previous_record->flags & FL_ONGROUND;
//                }
//
//                if (on_ground)
//                    e->m_fFlags() |= FL_ONGROUND;
//                else
//                    e->m_fFlags() &= ~FL_ONGROUND;
//
//                auto simulated_ticks = TIME_TO_TICKS(simulated_time);
//
//                m_globals()->m_realtime = simulated_time;
//                m_globals()->m_curtime = simulated_time;
//                m_globals()->m_framecount = simulated_ticks;
//                m_globals()->m_tickcount = simulated_ticks;
//                m_globals()->m_interpolation_amount = 0.0f;
//
//                g_ctx.globals.updating_animation = true;
//                e->update_clientside_animation();
//                g_ctx.globals.updating_animation = false;
//
//                m_globals()->m_realtime = backup_realtime;
//                m_globals()->m_curtime = backup_curtime;
//                m_globals()->m_framecount = backup_framecount;
//                m_globals()->m_tickcount = backup_tickcount;
//                m_globals()->m_interpolation_amount = backup_interpolation_amount;
//
//                updated_animations = true;
//            }
//        }
//    }
//
//    if (!updated_animations)
//    {
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//    }
//
//    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
//    {
//        e->invalidate_physics_recursive(8);
//
//        AnimationLayer backup_layers[15];
//        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
//
//        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));
//
//        switch (matrix)
//        {
//        case MAIN:
//            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
//            break;
//        case NONE:
//            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
//            break;
//        case FIRST:
//            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
//            break;
//        case SECOND:
//            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
//            break;
//        }
//
//        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
//    };
//
//#if RELEASE
//    if (!player_info.fakeplayer && g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled) //-V807
//#else
//    if (g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled)
//#endif
//    {
//        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()]; //-V807
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y); //-V807
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, NONE);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, FIRST);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, SECOND);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
//        player_resolver[e->EntIndex()].resolve_yaw();
//
//        //NEW RES
//        player_resolver[e->EntIndex()].ResolveAngles(e);
//        //player_resolver[e->EntIndex()].skeetresik(e);
//        //NEW RES
//
//        if (g_cfg.player_list.low_delta[e->EntIndex()])
//        {
//            switch (record->side)
//            {
//            case RESOLVER_FIRST:
//                record->side = RESOLVER_LOW_FIRST;
//                break;
//            case RESOLVER_SECOND:
//                record->side = RESOLVER_LOW_SECOND;
//                break;
//            case RESOLVER_LOW_FIRST:
//                record->side = RESOLVER_FIRST;
//                break;
//            case RESOLVER_LOW_SECOND:
//                record->side = RESOLVER_SECOND;
//                break;
//            }
//        }
//
//        switch (record->side)
//        {
//        case RESOLVER_ORIGINAL:
//            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
//            break;
//        case RESOLVER_ZERO:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
//            break;
//        case RESOLVER_FIRST:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
//            break;
//        case RESOLVER_SECOND:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
//            break;
//        case RESOLVER_LOW_FIRST:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 30.0f);
//            break;
//        case RESOLVER_LOW_SECOND:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 30.0f);
//            break;
//        }
//
//        e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();
//    }
//
//    g_ctx.globals.updating_animation = true;
//    e->update_clientside_animation();
//    g_ctx.globals.updating_animation = false;
//
//    setup_matrix(e, animlayers, MAIN);
//    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));
//
//    m_globals()->m_curtime = backup_curtime;
//    m_globals()->m_frametime = backup_frametime;
//
//    e->m_flLowerBodyYawTarget() = backup_lower_body_yaw_target;
//    e->m_flDuckAmount() = backup_duck_amount;
//    e->m_fFlags() = backup_flags;
//    e->m_iEFlags() = backup_eflags;
//
//    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
//    record->store_data(e, false);
//
//    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
//        record->invalid = true;
//}

void lagcompensation::update_player_animations(player_t* e)
{
    auto animstate = e->get_animation_state();

    if (!animstate)
        return;

    player_info_t player_info;

    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
        return;

    auto records = &player_records[e->EntIndex()]; //-V826

    if (records->empty())
        return;

    //if (g_cfg.misc.forceangle)
    //{
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flGoalFeetYaw + g_cfg.misc.forceanglevalue);
    //}

    adjust_data* previous_record = nullptr;

    if (records->size() >= 2)
        previous_record = &records->at(1);

    auto record = &records->front();

    AnimationLayer animlayers[13];

    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
    auto backup_duck_amount = e->m_flDuckAmount();
    auto backup_flags = e->m_fFlags();
    auto backup_eflags = e->m_iEFlags();

    auto backup_curtime = m_globals()->m_curtime; //-V807
    auto backup_frametime = m_globals()->m_frametime;
    auto backup_realtime = m_globals()->m_realtime;
    auto backup_framecount = m_globals()->m_framecount;
    auto backup_tickcount = m_globals()->m_tickcount;
    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;

    m_globals()->m_curtime = e->m_flSimulationTime();
    m_globals()->m_frametime = m_globals()->m_intervalpertick;

    /*if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(e->m_fFlags() & FL_ONGROUND))
            {
                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));

                auto fixed_timing = math::clamp(time_difference, m_globals()->m_intervalpertick, 1.0f);
                e->m_vecVelocity().z -= sv_gravity->GetFloat() * fixed_timing * 0.5f;
            }
            else
                e->m_vecVelocity().z = 0.0f;
        }
    }*/

    e->m_iEFlags() &= ~0x1800;

    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
        e->m_vecVelocity().Zero();

    e->m_vecAbsVelocity() = e->m_vecVelocity();
    e->m_bClientSideAnimation() = true;

    if (is_dormant[e->EntIndex()])
    {
        is_dormant[e->EntIndex()] = false;

        if (e->m_fFlags() & FL_ONGROUND)
        {
            animstate->m_bOnGround = true;
            animstate->m_bInHitGroundAnimation = false;
        }

        animstate->time_since_in_air() = 0.0f;
        animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flEyeYaw);
    }

    auto updated_animations = false;

    c_baseplayeranimationstate state;
    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));

    //if (previous_record)
    //{
    //    memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));
    //
    //    auto ticks_chocked = 1;
    //    auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);
    //
    //    if (ticks_chocked > 1)
    //    {
    //        auto land_time = 0.0f;
    //        auto land_in_cycle = false;
    //        auto is_landed = false;
    //        auto on_ground = false;
    //
    //        if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
    //        {
    //            land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
    //            land_in_cycle = land_time >= previous_record->simulation_time;
    //        }
    //
    //        auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;
    //
    //        for (auto i = 0; i < ticks_chocked; ++i)
    //        {
    //            auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);
    //
    //            if (duck_amount_per_tick)
    //                e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;
    //
    //            on_ground = e->m_fFlags() & FL_ONGROUND;
    //
    //            if (land_in_cycle && !is_landed)
    //            {
    //                if (land_time <= simulated_time)
    //                {
    //                    is_landed = true;
    //                    on_ground = true;
    //                }
    //                else
    //                    on_ground = previous_record->flags & FL_ONGROUND;
    //            }
    //
    //            if (on_ground)
    //                e->m_fFlags() |= FL_ONGROUND;
    //            else
    //                e->m_fFlags() &= ~FL_ONGROUND;
    //
    //            auto simulated_ticks = TIME_TO_TICKS(simulated_time);
    //
    //            m_globals()->m_realtime = simulated_time;
    //            m_globals()->m_curtime = simulated_time;
    //            m_globals()->m_framecount = simulated_ticks;
    //            m_globals()->m_tickcount = simulated_ticks;
    //            m_globals()->m_interpolation_amount = 0.0f;
    //
    //            g_ctx.globals.updating_animation = true;
    //            e->update_clientside_animation();
    //            g_ctx.globals.updating_animation = false;
    //
    //            m_globals()->m_realtime = backup_realtime;
    //            m_globals()->m_curtime = backup_curtime;
    //            m_globals()->m_framecount = backup_framecount;
    //            m_globals()->m_tickcount = backup_tickcount;
    //            m_globals()->m_interpolation_amount = backup_interpolation_amount;
    //
    //            updated_animations = true;
    //        }
    //    }
    //}

    if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(record->flags & FL_ONGROUND))
            {
                velocity = (record->origin - previous_record->origin) / record->simulation_time;

                float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP].m_flWeight;

                if (flWeight > 0.0f)
                {
                    float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
                    float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;

                    if (flPreviousRate == flCurrentRate)
                    {
                        int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
                        int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;

                        if (iPreviousSequence == iCurrentSequence)
                        {
                            float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;

                            if (flSpeedNormalized > 0.0f)
                            {
                                float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();

                                if (flSpeed > 0.0f)
                                {
                                    if (velocity.Length2D() > 0.0f)
                                    {
                                        velocity.x /= velocity.Length2D() / flSpeed;
                                        velocity.y /= velocity.Length2D() / flSpeed;
                                    }
                                }
                            }
                        }
                    }
                }

                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
                velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
            }
            else
                velocity.z = 0.0f;
        }
    }

    if (!updated_animations)
    {
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
    }

    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));

    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
    {
        e->invalidate_physics_recursive(8);

        AnimationLayer backup_layers[13];
        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));

        switch (matrix)
        {
        case MAIN:
            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
            break;
        case NONE:
            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
            break;
        case FIRST:
            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
            break;
        case SECOND:
            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
            break;
        }

        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
    };

    //if (!player_info.fakeplayer && g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled) //-V807  //LEGITBOT DELETE
    //{
    //    /* set prev gfy */
    //    animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //
    //    /* setup matrix for zero desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, NONE);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].gfy_default = animstate->m_flGoalFeetYaw;
    //
    //    /* setup matrix for positive desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, FIRST);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[2], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].positive_side = animstate->m_flGoalFeetYaw;
    //
    //    /* setup matrix for negative desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, SECOND);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].negative_side = animstate->m_flGoalFeetYaw;
    //
    //    // set resolver values
    //    player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
    //    // resolve
    //    player_resolver[e->EntIndex()].resolve_yaw();
    //
    //    switch (record->side)
    //    {
    //    case RESOLVER_ORIGINAL:
    //        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
    //        break;
    //    case RESOLVER_ZERO:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    //        break;
    //    case RESOLVER_FIRST:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.f);
    //        break;
    //    case RESOLVER_SECOND:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.f);
    //        break;
    //    case RESOLVER_LOW_FIRST:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + e->get_max_desync_delta() / 2.2f);
    //        break;
    //    case RESOLVER_LOW_SECOND:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - e->get_max_desync_delta() / 2.2f);
    //        break;
    //    }
    //
    //    e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();
    //}

    g_ctx.globals.updating_animation = true;
    e->update_clientside_animation();
    g_ctx.globals.updating_animation = false;

    setup_matrix(e, animlayers, MAIN);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    m_globals()->m_curtime = backup_curtime;
    m_globals()->m_frametime = backup_frametime;

    e->m_flDuckAmount() = backup_duck_amount;
    e->m_fFlags() = backup_flags;
    e->m_iEFlags() = backup_eflags;

    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(player_resolver[e->EntIndex()].previous_layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
shit.

ну нам то похуй помогать тебе или нет
я просил тебя код кинуть
мне похуй дефолт лв без пасты и тд.........
Скинуть как челы выглядят вме кроме меня?
 
Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include "animation_system.h"
#include "..\misc\misc.h"
#include "..\misc\logs.h"

std::deque <adjust_data> player_records[65];

//void lagcompensation::fsn(ClientFrameStage_t stage)
//{
//    if (stage != FRAME_NET_UPDATE_END)
//        return;
//
//    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled)
//        return;
//
//    for (auto i = 1; i < m_globals()->m_maxclients; i++) //-V807
//    {
//        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));
//
//        if (e == g_ctx.local())
//            continue;
//
//        if (!valid(i, e))
//            continue;
//
//        auto time_delta = abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount);
//
//        if (time_delta > 1.0f / m_globals()->m_intervalpertick)
//            continue;
//
//        auto update = player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime(); //-V550
//
//        //if (update && !player_records[i].empty())
//        //{
//        //    auto server_tick = m_clientstate()->m_iServerTick - i % m_globals()->m_timestamprandomizewindow;
//        //    auto current_tick = server_tick - server_tick % m_globals()->m_timestampnetworkingbase;
//        //
//        //    if (TIME_TO_TICKS(e->m_flOldSimulationTime()) < current_tick && TIME_TO_TICKS(e->m_flSimulationTime()) == current_tick)
//        //    {
//        //        auto layer = &e->get_animlayers()[11];
//        //        auto previous_layer = &player_records[i].front().layers[11];
//        //
//        //        if (layer->m_flCycle == previous_layer->m_flCycle) //-V550
//        //        {
//        //            e->m_flSimulationTime() = e->m_flOldSimulationTime();
//        //            update = false;
//        //        }
//        //    }
//        //}
//
//        if (update) //-V550
//        {
//            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
//                for (auto& record : player_records[i])
//                    record.invalid = true;
//
//            player_records[i].emplace_front(adjust_data());
//            update_player_animations(e);
//
//            while (player_records[i].size() > 32)
//                player_records[i].pop_back();
//        }
//    }
//}

void lagcompensation::fsn(ClientFrameStage_t stage)
{
    if (stage != FRAME_NET_UPDATE_END)
        return;

    if (!g_cfg.ragebot.enable/* && !g_cfg.legitbot.enabled*/) //LEGITBOT DELETE
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++)
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (e == g_ctx.local())
            continue;

        if (!valid(i, e))
            continue;

        if (abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount) > 1.0f / m_globals()->m_intervalpertick)
            continue;

        if (player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime())
        {
            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
                for (auto& record : player_records[i])
                    record.invalid = true;

            player_records[i].emplace_front(adjust_data());
            update_player_animations(e);

            while (player_records[i].size() > 32)
                player_records[i].pop_back();
        }
    }
}

bool lagcompensation::valid(int i, player_t* e)
{
    if (!g_cfg.ragebot.enable /*&& !g_cfg.legitbot.enabled */|| !e->valid(false)) //LEGITBOT DELETE
    {
        if (!e->is_alive())
        {
            is_dormant[i] = false;
            player_resolver[i].reset();

            g_ctx.globals.fired_shots[i] = 0;
            g_ctx.globals.missed_shots[i] = 0;
        }
        else if (e->IsDormant())
            is_dormant[i] = true;

        player_records[i].clear();
        return false;
    }

    return true;
}

//void lagcompensation::update_player_animations(player_t* e)
//{
//    auto animstate = e->get_animation_state();
//
//    if (!animstate)
//        return;
//
//    player_info_t player_info;
//
//    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
//        return;
//
//    auto records = &player_records[e->EntIndex()]; //-V826
//
//    if (records->empty())
//        return;
//
//    adjust_data* previous_record = nullptr;
//
//    if (records->size() >= 2)
//        previous_record = &records->at(1);
//
//    auto record = &records->front();
//
//    AnimationLayer animlayers[15];
//
//    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
//    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));
//
//    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
//    auto backup_duck_amount = e->m_flDuckAmount();
//    auto backup_flags = e->m_fFlags();
//    auto backup_eflags = e->m_iEFlags();
//
//    auto backup_curtime = m_globals()->m_curtime; //-V807
//    auto backup_frametime = m_globals()->m_frametime;
//    auto backup_realtime = m_globals()->m_realtime;
//    auto backup_framecount = m_globals()->m_framecount;
//    auto backup_tickcount = m_globals()->m_tickcount;
//    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;
//
//    m_globals()->m_curtime = e->m_flSimulationTime();
//    m_globals()->m_frametime = m_globals()->m_intervalpertick;
//
//    if (previous_record)
//    {
//        auto velocity = e->m_vecVelocity();
//        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;
//
//        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
//        auto origin_delta = e->m_vecOrigin() - previous_record->origin;
//
//        auto animation_speed = 0.0f;
//
//        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
//        {
//            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);
//
//            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
//            {
//                auto weapon = e->m_hActiveWeapon().Get();
//
//                if (weapon)
//                {
//                    auto max_speed = 260.0f;
//                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();
//
//                    if (weapon_info)
//                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;
//
//                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);
//
//                    if (modifier > 0.0f && modifier < 1.0f)
//                        animation_speed = max_speed * (modifier + 0.55f);
//                }
//            }
//
//            if (animation_speed > 0.0f)
//            {
//                animation_speed /= e->m_vecVelocity().Length2D();
//
//                e->m_vecVelocity().x *= animation_speed;
//                e->m_vecVelocity().y *= animation_speed;
//            }
//
//            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
//            {
//                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);
//
//                if (!previous_velocity.IsZero() && !was_in_air)
//                {
//                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
//                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));
//
//                    auto average_direction = current_direction - previous_direction;
//                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));
//
//                    auto direction_cos = cos(average_direction);
//                    auto dirrection_sin = sin(average_direction);
//
//                    auto velocity_speed = e->m_vecVelocity().Length2D();
//
//                    e->m_vecVelocity().x = direction_cos * velocity_speed;
//                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
//                }
//            }
//
//            if (!(e->m_fFlags() & FL_ONGROUND))
//            {
//                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
//
//                auto fixed_timing = math::clamp(time_difference, m_globals()->m_intervalpertick, 1.0f);
//                e->m_vecVelocity().z -= sv_gravity->GetFloat() * fixed_timing * 0.5f;
//            }
//            else
//                e->m_vecVelocity().z = 0.0f;
//        }
//    }
//
//    e->m_iEFlags() &= ~0x1800;
//
//    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
//        e->m_vecVelocity().Zero();
//
//    e->m_vecAbsVelocity() = e->m_vecVelocity();
//    e->m_bClientSideAnimation() = true;
//
//    if (is_dormant[e->EntIndex()])
//    {
//        is_dormant[e->EntIndex()] = false;
//
//        if (e->m_fFlags() & FL_ONGROUND)
//        {
//            animstate->m_bOnGround = true;
//            animstate->m_bInHitGroundAnimation = false;
//        }
//
//        animstate->time_since_in_air() = 0.0f;
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
//    }
//
//    auto updated_animations = false;
//
//    c_baseplayeranimationstate state;
//    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));
//
//    if (previous_record)
//    {
//        memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));
//
//        auto ticks_chocked = 1;
//        auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);
//
//        if (simulation_ticks > 0 && simulation_ticks < 31)
//            ticks_chocked = simulation_ticks;
//
//        if (ticks_chocked > 1)
//        {
//            auto land_time = 0.0f;
//            auto land_in_cycle = false;
//            auto is_landed = false;
//            auto on_ground = false;
//
//            if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
//            {
//                land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
//                land_in_cycle = land_time >= previous_record->simulation_time;
//            }
//
//            auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;
//
//            for (auto i = 0; i < ticks_chocked; ++i)
//            {
//                //auto lby_delta = fabs(math::normalize_yaw(e->m_flLowerBodyYawTarget() - previous_record->lby));
//                //
//                //if (lby_delta > 0.0f && e->m_vecVelocity().Length() < 5.0f)
//                //{
//                //    auto delta = ticks_chocked - i;
//                //    auto use_new_lby = true;
//                //
//                //    if (lby_delta < 1.0f)
//                //        use_new_lby = !delta; //-V547
//                //    else
//                //        use_new_lby = delta < 2;
//                //
//                //    e->m_flLowerBodyYawTarget() = use_new_lby ? backup_lower_body_yaw_target : previous_record->lby;
//                //}
//
//                auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);
//
//                if (duck_amount_per_tick) //-V550
//                    e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;
//
//                on_ground = e->m_fFlags() & FL_ONGROUND;
//
//                if (land_in_cycle && !is_landed)
//                {
//                    if (land_time <= simulated_time)
//                    {
//                        is_landed = true;
//                        on_ground = true;
//                    }
//                    else
//                        on_ground = previous_record->flags & FL_ONGROUND;
//                }
//
//                if (on_ground)
//                    e->m_fFlags() |= FL_ONGROUND;
//                else
//                    e->m_fFlags() &= ~FL_ONGROUND;
//
//                auto simulated_ticks = TIME_TO_TICKS(simulated_time);
//
//                m_globals()->m_realtime = simulated_time;
//                m_globals()->m_curtime = simulated_time;
//                m_globals()->m_framecount = simulated_ticks;
//                m_globals()->m_tickcount = simulated_ticks;
//                m_globals()->m_interpolation_amount = 0.0f;
//
//                g_ctx.globals.updating_animation = true;
//                e->update_clientside_animation();
//                g_ctx.globals.updating_animation = false;
//
//                m_globals()->m_realtime = backup_realtime;
//                m_globals()->m_curtime = backup_curtime;
//                m_globals()->m_framecount = backup_framecount;
//                m_globals()->m_tickcount = backup_tickcount;
//                m_globals()->m_interpolation_amount = backup_interpolation_amount;
//
//                updated_animations = true;
//            }
//        }
//    }
//
//    if (!updated_animations)
//    {
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//    }
//
//    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
//    {
//        e->invalidate_physics_recursive(8);
//
//        AnimationLayer backup_layers[15];
//        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
//
//        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));
//
//        switch (matrix)
//        {
//        case MAIN:
//            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
//            break;
//        case NONE:
//            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
//            break;
//        case FIRST:
//            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
//            break;
//        case SECOND:
//            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
//            break;
//        }
//
//        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
//    };
//
//#if RELEASE
//    if (!player_info.fakeplayer && g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled) //-V807
//#else
//    if (g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled)
//#endif
//    {
//        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()]; //-V807
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y); //-V807
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, NONE);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, FIRST);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, SECOND);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
//        player_resolver[e->EntIndex()].resolve_yaw();
//
//        //NEW RES
//        player_resolver[e->EntIndex()].ResolveAngles(e);
//        //player_resolver[e->EntIndex()].skeetresik(e);
//        //NEW RES
//
//        if (g_cfg.player_list.low_delta[e->EntIndex()])
//        {
//            switch (record->side)
//            {
//            case RESOLVER_FIRST:
//                record->side = RESOLVER_LOW_FIRST;
//                break;
//            case RESOLVER_SECOND:
//                record->side = RESOLVER_LOW_SECOND;
//                break;
//            case RESOLVER_LOW_FIRST:
//                record->side = RESOLVER_FIRST;
//                break;
//            case RESOLVER_LOW_SECOND:
//                record->side = RESOLVER_SECOND;
//                break;
//            }
//        }
//
//        switch (record->side)
//        {
//        case RESOLVER_ORIGINAL:
//            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
//            break;
//        case RESOLVER_ZERO:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
//            break;
//        case RESOLVER_FIRST:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
//            break;
//        case RESOLVER_SECOND:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
//            break;
//        case RESOLVER_LOW_FIRST:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 30.0f);
//            break;
//        case RESOLVER_LOW_SECOND:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 30.0f);
//            break;
//        }
//
//        e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();
//    }
//
//    g_ctx.globals.updating_animation = true;
//    e->update_clientside_animation();
//    g_ctx.globals.updating_animation = false;
//
//    setup_matrix(e, animlayers, MAIN);
//    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));
//
//    m_globals()->m_curtime = backup_curtime;
//    m_globals()->m_frametime = backup_frametime;
//
//    e->m_flLowerBodyYawTarget() = backup_lower_body_yaw_target;
//    e->m_flDuckAmount() = backup_duck_amount;
//    e->m_fFlags() = backup_flags;
//    e->m_iEFlags() = backup_eflags;
//
//    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
//    record->store_data(e, false);
//
//    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
//        record->invalid = true;
//}

void lagcompensation::update_player_animations(player_t* e)
{
    auto animstate = e->get_animation_state();

    if (!animstate)
        return;

    player_info_t player_info;

    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
        return;

    auto records = &player_records[e->EntIndex()]; //-V826

    if (records->empty())
        return;

    //if (g_cfg.misc.forceangle)
    //{
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flGoalFeetYaw + g_cfg.misc.forceanglevalue);
    //}

    adjust_data* previous_record = nullptr;

    if (records->size() >= 2)
        previous_record = &records->at(1);

    auto record = &records->front();

    AnimationLayer animlayers[13];

    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
    auto backup_duck_amount = e->m_flDuckAmount();
    auto backup_flags = e->m_fFlags();
    auto backup_eflags = e->m_iEFlags();

    auto backup_curtime = m_globals()->m_curtime; //-V807
    auto backup_frametime = m_globals()->m_frametime;
    auto backup_realtime = m_globals()->m_realtime;
    auto backup_framecount = m_globals()->m_framecount;
    auto backup_tickcount = m_globals()->m_tickcount;
    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;

    m_globals()->m_curtime = e->m_flSimulationTime();
    m_globals()->m_frametime = m_globals()->m_intervalpertick;

    /*if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(e->m_fFlags() & FL_ONGROUND))
            {
                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));

                auto fixed_timing = math::clamp(time_difference, m_globals()->m_intervalpertick, 1.0f);
                e->m_vecVelocity().z -= sv_gravity->GetFloat() * fixed_timing * 0.5f;
            }
            else
                e->m_vecVelocity().z = 0.0f;
        }
    }*/

    e->m_iEFlags() &= ~0x1800;

    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
        e->m_vecVelocity().Zero();

    e->m_vecAbsVelocity() = e->m_vecVelocity();
    e->m_bClientSideAnimation() = true;

    if (is_dormant[e->EntIndex()])
    {
        is_dormant[e->EntIndex()] = false;

        if (e->m_fFlags() & FL_ONGROUND)
        {
            animstate->m_bOnGround = true;
            animstate->m_bInHitGroundAnimation = false;
        }

        animstate->time_since_in_air() = 0.0f;
        animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flEyeYaw);
    }

    auto updated_animations = false;

    c_baseplayeranimationstate state;
    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));

    //if (previous_record)
    //{
    //    memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));
    //
    //    auto ticks_chocked = 1;
    //    auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);
    //
    //    if (ticks_chocked > 1)
    //    {
    //        auto land_time = 0.0f;
    //        auto land_in_cycle = false;
    //        auto is_landed = false;
    //        auto on_ground = false;
    //
    //        if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
    //        {
    //            land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
    //            land_in_cycle = land_time >= previous_record->simulation_time;
    //        }
    //
    //        auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;
    //
    //        for (auto i = 0; i < ticks_chocked; ++i)
    //        {
    //            auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);
    //
    //            if (duck_amount_per_tick)
    //                e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;
    //
    //            on_ground = e->m_fFlags() & FL_ONGROUND;
    //
    //            if (land_in_cycle && !is_landed)
    //            {
    //                if (land_time <= simulated_time)
    //                {
    //                    is_landed = true;
    //                    on_ground = true;
    //                }
    //                else
    //                    on_ground = previous_record->flags & FL_ONGROUND;
    //            }
    //
    //            if (on_ground)
    //                e->m_fFlags() |= FL_ONGROUND;
    //            else
    //                e->m_fFlags() &= ~FL_ONGROUND;
    //
    //            auto simulated_ticks = TIME_TO_TICKS(simulated_time);
    //
    //            m_globals()->m_realtime = simulated_time;
    //            m_globals()->m_curtime = simulated_time;
    //            m_globals()->m_framecount = simulated_ticks;
    //            m_globals()->m_tickcount = simulated_ticks;
    //            m_globals()->m_interpolation_amount = 0.0f;
    //
    //            g_ctx.globals.updating_animation = true;
    //            e->update_clientside_animation();
    //            g_ctx.globals.updating_animation = false;
    //
    //            m_globals()->m_realtime = backup_realtime;
    //            m_globals()->m_curtime = backup_curtime;
    //            m_globals()->m_framecount = backup_framecount;
    //            m_globals()->m_tickcount = backup_tickcount;
    //            m_globals()->m_interpolation_amount = backup_interpolation_amount;
    //
    //            updated_animations = true;
    //        }
    //    }
    //}

    if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(record->flags & FL_ONGROUND))
            {
                velocity = (record->origin - previous_record->origin) / record->simulation_time;

                float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP].m_flWeight;

                if (flWeight > 0.0f)
                {
                    float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
                    float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;

                    if (flPreviousRate == flCurrentRate)
                    {
                        int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
                        int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;

                        if (iPreviousSequence == iCurrentSequence)
                        {
                            float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;

                            if (flSpeedNormalized > 0.0f)
                            {
                                float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();

                                if (flSpeed > 0.0f)
                                {
                                    if (velocity.Length2D() > 0.0f)
                                    {
                                        velocity.x /= velocity.Length2D() / flSpeed;
                                        velocity.y /= velocity.Length2D() / flSpeed;
                                    }
                                }
                            }
                        }
                    }
                }

                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
                velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
            }
            else
                velocity.z = 0.0f;
        }
    }

    if (!updated_animations)
    {
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
    }

    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));

    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
    {
        e->invalidate_physics_recursive(8);

        AnimationLayer backup_layers[13];
        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));

        switch (matrix)
        {
        case MAIN:
            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
            break;
        case NONE:
            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
            break;
        case FIRST:
            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
            break;
        case SECOND:
            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
            break;
        }

        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
    };

    //if (!player_info.fakeplayer && g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled) //-V807  //LEGITBOT DELETE
    //{
    //    /* set prev gfy */
    //    animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //
    //    /* setup matrix for zero desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, NONE);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].gfy_default = animstate->m_flGoalFeetYaw;
    //
    //    /* setup matrix for positive desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, FIRST);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[2], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].positive_side = animstate->m_flGoalFeetYaw;
    //
    //    /* setup matrix for negative desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, SECOND);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].negative_side = animstate->m_flGoalFeetYaw;
    //
    //    // set resolver values
    //    player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
    //    // resolve
    //    player_resolver[e->EntIndex()].resolve_yaw();
    //
    //    switch (record->side)
    //    {
    //    case RESOLVER_ORIGINAL:
    //        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
    //        break;
    //    case RESOLVER_ZERO:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    //        break;
    //    case RESOLVER_FIRST:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.f);
    //        break;
    //    case RESOLVER_SECOND:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.f);
    //        break;
    //    case RESOLVER_LOW_FIRST:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + e->get_max_desync_delta() / 2.2f);
    //        break;
    //    case RESOLVER_LOW_SECOND:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - e->get_max_desync_delta() / 2.2f);
    //        break;
    //    }
    //
    //    e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();
    //}

    g_ctx.globals.updating_animation = true;
    e->update_clientside_animation();
    g_ctx.globals.updating_animation = false;

    setup_matrix(e, animlayers, MAIN);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    m_globals()->m_curtime = backup_curtime;
    m_globals()->m_frametime = backup_frametime;

    e->m_flDuckAmount() = backup_duck_amount;
    e->m_fFlags() = backup_flags;
    e->m_iEFlags() = backup_eflags;

    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(player_resolver[e->EntIndex()].previous_layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
Скинуть как челы выглядят вме кроме меня?
тя не смущает то что у тебя сетап трех матриц закоменчен
еще какая то паста из сурса Porches которая не будет работать как нужно..
 
Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Начинающий
Статус
Оффлайн
Регистрация
14 Янв 2022
Сообщения
21
Реакции[?]
1
Поинты[?]
0
тя не смущает то что у тебя сетап трех матриц закоменчен
еще какая то паста из сурса Porches которая не будет работать как нужно..
А можешь точнее смказать просто что мне сделать я новичек
 
Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
maybe it's not animfix, but pitch resolver.

Код:
float resolver::resolve_pitch()
{
    float liohsdafg = 0.f;
    if (g_cfg.ragebot.pitch_antiaim_correction)
    {
        if (liohsdafg < -179.f) liohsdafg += 360.f;
        else if (liohsdafg > 90.0 || liohsdafg < -90.0) liohsdafg = 89.f;
        else if (liohsdafg > 89.0 && liohsdafg < 91.0) liohsdafg -= 90.f;
        else if (liohsdafg > 179.0 && liohsdafg < 181.0) liohsdafg -= 180;
        else if (liohsdafg > -179.0 && liohsdafg < -181.0) liohsdafg += 180;

        else if (fabs(liohsdafg) == 0) liohsdafg = copysign(89.0f, liohsdafg);
        else liohsdafg = original_pitch;

        return liohsdafg;
    }
    else
        return original_pitch;
}
Just don't forget to add the antiaim_correction checkbox, maybe you already have it.
с таким питч ресольвером надо улететь в бектрек на тиков 16
А можешь точнее смказать просто что мне сделать я новичек
короче возьми деф лв анимфикс
вырежи мем с 11 лером ( в fsn функе )
и удали гетто лбу ребилд с ванпасты
 
Начинающий
Статус
Оффлайн
Регистрация
14 Янв 2022
Сообщения
21
Реакции[?]
1
Поинты[?]
0
с таким питч ресольвером надо улететь в бектрек на тиков 16

короче возьми деф лв анимфикс
вырежи мем с 11 лером ( в fsn функе )
и удали гетто лбу ребилд с ванпасты
Можешь скинуть сылку на лв сурсик
 
Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2022
Сообщения
19
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Начинающий
Статус
Оффлайн
Регистрация
9 Ноя 2020
Сообщения
153
Реакции[?]
7
Поинты[?]
0
Забаненный
Статус
Оффлайн
Регистрация
16 Янв 2022
Сообщения
68
Реакции[?]
9
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
// This is an independent project of an individual developer. Dear PVS-Studio, please check it.
// PVS-Studio Static Code Analyzer for C, C++, C#, and Java: http://www.viva64.com

#include "animation_system.h"
#include "..\misc\misc.h"
#include "..\misc\logs.h"

std::deque <adjust_data> player_records[65];

//void lagcompensation::fsn(ClientFrameStage_t stage)
//{
//    if (stage != FRAME_NET_UPDATE_END)
//        return;
//
//    if (!g_cfg.ragebot.enable && !g_cfg.legitbot.enabled)
//        return;
//
//    for (auto i = 1; i < m_globals()->m_maxclients; i++) //-V807
//    {
//        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));
//
//        if (e == g_ctx.local())
//            continue;
//
//        if (!valid(i, e))
//            continue;
//
//        auto time_delta = abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount);
//
//        if (time_delta > 1.0f / m_globals()->m_intervalpertick)
//            continue;
//
//        auto update = player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime(); //-V550
//
//        //if (update && !player_records[i].empty())
//        //{
//        //    auto server_tick = m_clientstate()->m_iServerTick - i % m_globals()->m_timestamprandomizewindow;
//        //    auto current_tick = server_tick - server_tick % m_globals()->m_timestampnetworkingbase;
//        //
//        //    if (TIME_TO_TICKS(e->m_flOldSimulationTime()) < current_tick && TIME_TO_TICKS(e->m_flSimulationTime()) == current_tick)
//        //    {
//        //        auto layer = &e->get_animlayers()[11];
//        //        auto previous_layer = &player_records[i].front().layers[11];
//        //
//        //        if (layer->m_flCycle == previous_layer->m_flCycle) //-V550
//        //        {
//        //            e->m_flSimulationTime() = e->m_flOldSimulationTime();
//        //            update = false;
//        //        }
//        //    }
//        //}
//
//        if (update) //-V550
//        {
//            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
//                for (auto& record : player_records[i])
//                    record.invalid = true;
//
//            player_records[i].emplace_front(adjust_data());
//            update_player_animations(e);
//
//            while (player_records[i].size() > 32)
//                player_records[i].pop_back();
//        }
//    }
//}

void lagcompensation::fsn(ClientFrameStage_t stage)
{
    if (stage != FRAME_NET_UPDATE_END)
        return;

    if (!g_cfg.ragebot.enable/* && !g_cfg.legitbot.enabled*/) //LEGITBOT DELETE
        return;

    for (auto i = 1; i < m_globals()->m_maxclients; i++)
    {
        auto e = static_cast<player_t*>(m_entitylist()->GetClientEntity(i));

        if (e == g_ctx.local())
            continue;

        if (!valid(i, e))
            continue;

        if (abs(TIME_TO_TICKS(e->m_flSimulationTime()) - m_globals()->m_tickcount) > 1.0f / m_globals()->m_intervalpertick)
            continue;

        if (player_records[i].empty() || e->m_flSimulationTime() != e->m_flOldSimulationTime())
        {
            if (!player_records[i].empty() && (e->m_vecOrigin() - player_records[i].front().origin).LengthSqr() > 4096.0f)
                for (auto& record : player_records[i])
                    record.invalid = true;

            player_records[i].emplace_front(adjust_data());
            update_player_animations(e);

            while (player_records[i].size() > 32)
                player_records[i].pop_back();
        }
    }
}

bool lagcompensation::valid(int i, player_t* e)
{
    if (!g_cfg.ragebot.enable /*&& !g_cfg.legitbot.enabled */|| !e->valid(false)) //LEGITBOT DELETE
    {
        if (!e->is_alive())
        {
            is_dormant[i] = false;
            player_resolver[i].reset();

            g_ctx.globals.fired_shots[i] = 0;
            g_ctx.globals.missed_shots[i] = 0;
        }
        else if (e->IsDormant())
            is_dormant[i] = true;

        player_records[i].clear();
        return false;
    }

    return true;
}

//void lagcompensation::update_player_animations(player_t* e)
//{
//    auto animstate = e->get_animation_state();
//
//    if (!animstate)
//        return;
//
//    player_info_t player_info;
//
//    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
//        return;
//
//    auto records = &player_records[e->EntIndex()]; //-V826
//
//    if (records->empty())
//        return;
//
//    adjust_data* previous_record = nullptr;
//
//    if (records->size() >= 2)
//        previous_record = &records->at(1);
//
//    auto record = &records->front();
//
//    AnimationLayer animlayers[15];
//
//    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
//    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));
//
//    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
//    auto backup_duck_amount = e->m_flDuckAmount();
//    auto backup_flags = e->m_fFlags();
//    auto backup_eflags = e->m_iEFlags();
//
//    auto backup_curtime = m_globals()->m_curtime; //-V807
//    auto backup_frametime = m_globals()->m_frametime;
//    auto backup_realtime = m_globals()->m_realtime;
//    auto backup_framecount = m_globals()->m_framecount;
//    auto backup_tickcount = m_globals()->m_tickcount;
//    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;
//
//    m_globals()->m_curtime = e->m_flSimulationTime();
//    m_globals()->m_frametime = m_globals()->m_intervalpertick;
//
//    if (previous_record)
//    {
//        auto velocity = e->m_vecVelocity();
//        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;
//
//        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
//        auto origin_delta = e->m_vecOrigin() - previous_record->origin;
//
//        auto animation_speed = 0.0f;
//
//        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
//        {
//            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);
//
//            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
//            {
//                auto weapon = e->m_hActiveWeapon().Get();
//
//                if (weapon)
//                {
//                    auto max_speed = 260.0f;
//                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();
//
//                    if (weapon_info)
//                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;
//
//                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);
//
//                    if (modifier > 0.0f && modifier < 1.0f)
//                        animation_speed = max_speed * (modifier + 0.55f);
//                }
//            }
//
//            if (animation_speed > 0.0f)
//            {
//                animation_speed /= e->m_vecVelocity().Length2D();
//
//                e->m_vecVelocity().x *= animation_speed;
//                e->m_vecVelocity().y *= animation_speed;
//            }
//
//            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
//            {
//                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);
//
//                if (!previous_velocity.IsZero() && !was_in_air)
//                {
//                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
//                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));
//
//                    auto average_direction = current_direction - previous_direction;
//                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));
//
//                    auto direction_cos = cos(average_direction);
//                    auto dirrection_sin = sin(average_direction);
//
//                    auto velocity_speed = e->m_vecVelocity().Length2D();
//
//                    e->m_vecVelocity().x = direction_cos * velocity_speed;
//                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
//                }
//            }
//
//            if (!(e->m_fFlags() & FL_ONGROUND))
//            {
//                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
//
//                auto fixed_timing = math::clamp(time_difference, m_globals()->m_intervalpertick, 1.0f);
//                e->m_vecVelocity().z -= sv_gravity->GetFloat() * fixed_timing * 0.5f;
//            }
//            else
//                e->m_vecVelocity().z = 0.0f;
//        }
//    }
//
//    e->m_iEFlags() &= ~0x1800;
//
//    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
//        e->m_vecVelocity().Zero();
//
//    e->m_vecAbsVelocity() = e->m_vecVelocity();
//    e->m_bClientSideAnimation() = true;
//
//    if (is_dormant[e->EntIndex()])
//    {
//        is_dormant[e->EntIndex()] = false;
//
//        if (e->m_fFlags() & FL_ONGROUND)
//        {
//            animstate->m_bOnGround = true;
//            animstate->m_bInHitGroundAnimation = false;
//        }
//
//        animstate->time_since_in_air() = 0.0f;
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
//    }
//
//    auto updated_animations = false;
//
//    c_baseplayeranimationstate state;
//    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));
//
//    if (previous_record)
//    {
//        memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));
//
//        auto ticks_chocked = 1;
//        auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);
//
//        if (simulation_ticks > 0 && simulation_ticks < 31)
//            ticks_chocked = simulation_ticks;
//
//        if (ticks_chocked > 1)
//        {
//            auto land_time = 0.0f;
//            auto land_in_cycle = false;
//            auto is_landed = false;
//            auto on_ground = false;
//
//            if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
//            {
//                land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
//                land_in_cycle = land_time >= previous_record->simulation_time;
//            }
//
//            auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;
//
//            for (auto i = 0; i < ticks_chocked; ++i)
//            {
//                //auto lby_delta = fabs(math::normalize_yaw(e->m_flLowerBodyYawTarget() - previous_record->lby));
//                //
//                //if (lby_delta > 0.0f && e->m_vecVelocity().Length() < 5.0f)
//                //{
//                //    auto delta = ticks_chocked - i;
//                //    auto use_new_lby = true;
//                //
//                //    if (lby_delta < 1.0f)
//                //        use_new_lby = !delta; //-V547
//                //    else
//                //        use_new_lby = delta < 2;
//                //
//                //    e->m_flLowerBodyYawTarget() = use_new_lby ? backup_lower_body_yaw_target : previous_record->lby;
//                //}
//
//                auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);
//
//                if (duck_amount_per_tick) //-V550
//                    e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;
//
//                on_ground = e->m_fFlags() & FL_ONGROUND;
//
//                if (land_in_cycle && !is_landed)
//                {
//                    if (land_time <= simulated_time)
//                    {
//                        is_landed = true;
//                        on_ground = true;
//                    }
//                    else
//                        on_ground = previous_record->flags & FL_ONGROUND;
//                }
//
//                if (on_ground)
//                    e->m_fFlags() |= FL_ONGROUND;
//                else
//                    e->m_fFlags() &= ~FL_ONGROUND;
//
//                auto simulated_ticks = TIME_TO_TICKS(simulated_time);
//
//                m_globals()->m_realtime = simulated_time;
//                m_globals()->m_curtime = simulated_time;
//                m_globals()->m_framecount = simulated_ticks;
//                m_globals()->m_tickcount = simulated_ticks;
//                m_globals()->m_interpolation_amount = 0.0f;
//
//                g_ctx.globals.updating_animation = true;
//                e->update_clientside_animation();
//                g_ctx.globals.updating_animation = false;
//
//                m_globals()->m_realtime = backup_realtime;
//                m_globals()->m_curtime = backup_curtime;
//                m_globals()->m_framecount = backup_framecount;
//                m_globals()->m_tickcount = backup_tickcount;
//                m_globals()->m_interpolation_amount = backup_interpolation_amount;
//
//                updated_animations = true;
//            }
//        }
//    }
//
//    if (!updated_animations)
//    {
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//    }
//
//    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
//    {
//        e->invalidate_physics_recursive(8);
//
//        AnimationLayer backup_layers[15];
//        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
//
//        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));
//
//        switch (matrix)
//        {
//        case MAIN:
//            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
//            break;
//        case NONE:
//            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
//            break;
//        case FIRST:
//            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
//            break;
//        case SECOND:
//            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
//            break;
//        }
//
//        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
//    };
//
//#if RELEASE
//    if (!player_info.fakeplayer && g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled) //-V807
//#else
//    if (g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled)
//#endif
//    {
//        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()]; //-V807
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y); //-V807
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, NONE);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, FIRST);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
//
//        g_ctx.globals.updating_animation = true;
//        e->update_clientside_animation();
//        g_ctx.globals.updating_animation = false;
//
//        setup_matrix(e, animlayers, SECOND);
//        memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
//
//        player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
//        player_resolver[e->EntIndex()].resolve_yaw();
//
//        //NEW RES
//        player_resolver[e->EntIndex()].ResolveAngles(e);
//        //player_resolver[e->EntIndex()].skeetresik(e);
//        //NEW RES
//
//        if (g_cfg.player_list.low_delta[e->EntIndex()])
//        {
//            switch (record->side)
//            {
//            case RESOLVER_FIRST:
//                record->side = RESOLVER_LOW_FIRST;
//                break;
//            case RESOLVER_SECOND:
//                record->side = RESOLVER_LOW_SECOND;
//                break;
//            case RESOLVER_LOW_FIRST:
//                record->side = RESOLVER_FIRST;
//                break;
//            case RESOLVER_LOW_SECOND:
//                record->side = RESOLVER_SECOND;
//                break;
//            }
//        }
//
//        switch (record->side)
//        {
//        case RESOLVER_ORIGINAL:
//            animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
//            break;
//        case RESOLVER_ZERO:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
//            break;
//        case RESOLVER_FIRST:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
//            break;
//        case RESOLVER_SECOND:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
//            break;
//        case RESOLVER_LOW_FIRST:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 30.0f);
//            break;
//        case RESOLVER_LOW_SECOND:
//            animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 30.0f);
//            break;
//        }
//
//        e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();
//    }
//
//    g_ctx.globals.updating_animation = true;
//    e->update_clientside_animation();
//    g_ctx.globals.updating_animation = false;
//
//    setup_matrix(e, animlayers, MAIN);
//    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));
//
//    m_globals()->m_curtime = backup_curtime;
//    m_globals()->m_frametime = backup_frametime;
//
//    e->m_flLowerBodyYawTarget() = backup_lower_body_yaw_target;
//    e->m_flDuckAmount() = backup_duck_amount;
//    e->m_fFlags() = backup_flags;
//    e->m_iEFlags() = backup_eflags;
//
//    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
//    record->store_data(e, false);
//
//    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
//        record->invalid = true;
//}

void lagcompensation::update_player_animations(player_t* e)
{
    auto animstate = e->get_animation_state();

    if (!animstate)
        return;

    player_info_t player_info;

    if (!m_engine()->GetPlayerInfo(e->EntIndex(), &player_info))
        return;

    auto records = &player_records[e->EntIndex()]; //-V826

    if (records->empty())
        return;

    //if (g_cfg.misc.forceangle)
    //{
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flGoalFeetYaw + g_cfg.misc.forceanglevalue);
    //}

    adjust_data* previous_record = nullptr;

    if (records->size() >= 2)
        previous_record = &records->at(1);

    auto record = &records->front();

    AnimationLayer animlayers[13];

    memcpy(animlayers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(record->layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    auto backup_lower_body_yaw_target = e->m_flLowerBodyYawTarget();
    auto backup_duck_amount = e->m_flDuckAmount();
    auto backup_flags = e->m_fFlags();
    auto backup_eflags = e->m_iEFlags();

    auto backup_curtime = m_globals()->m_curtime; //-V807
    auto backup_frametime = m_globals()->m_frametime;
    auto backup_realtime = m_globals()->m_realtime;
    auto backup_framecount = m_globals()->m_framecount;
    auto backup_tickcount = m_globals()->m_tickcount;
    auto backup_interpolation_amount = m_globals()->m_interpolation_amount;

    m_globals()->m_curtime = e->m_flSimulationTime();
    m_globals()->m_frametime = m_globals()->m_intervalpertick;

    /*if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(e->m_fFlags() & FL_ONGROUND))
            {
                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));

                auto fixed_timing = math::clamp(time_difference, m_globals()->m_intervalpertick, 1.0f);
                e->m_vecVelocity().z -= sv_gravity->GetFloat() * fixed_timing * 0.5f;
            }
            else
                e->m_vecVelocity().z = 0.0f;
        }
    }*/

    e->m_iEFlags() &= ~0x1800;

    if (e->m_fFlags() & FL_ONGROUND && e->m_vecVelocity().Length() > 0.0f && animlayers[6].m_flWeight <= 0.0f)
        e->m_vecVelocity().Zero();

    e->m_vecAbsVelocity() = e->m_vecVelocity();
    e->m_bClientSideAnimation() = true;

    if (is_dormant[e->EntIndex()])
    {
        is_dormant[e->EntIndex()] = false;

        if (e->m_fFlags() & FL_ONGROUND)
        {
            animstate->m_bOnGround = true;
            animstate->m_bInHitGroundAnimation = false;
        }

        animstate->time_since_in_air() = 0.0f;
        animstate->m_flGoalFeetYaw = math::normalize_yaw(animstate->m_flEyeYaw);
    }

    auto updated_animations = false;

    c_baseplayeranimationstate state;
    memcpy(&state, animstate, sizeof(c_baseplayeranimationstate));

    //if (previous_record)
    //{
    //    memcpy(e->get_animlayers(), previous_record->layers, e->animlayer_count() * sizeof(AnimationLayer));
    //
    //    auto ticks_chocked = 1;
    //    auto simulation_ticks = TIME_TO_TICKS(e->m_flSimulationTime() - previous_record->simulation_time);
    //
    //    if (ticks_chocked > 1)
    //    {
    //        auto land_time = 0.0f;
    //        auto land_in_cycle = false;
    //        auto is_landed = false;
    //        auto on_ground = false;
    //
    //        if (animlayers[4].m_flCycle < 0.5f && (!(e->m_fFlags() & FL_ONGROUND) || !(previous_record->flags & FL_ONGROUND)))
    //        {
    //            land_time = e->m_flSimulationTime() - animlayers[4].m_flPlaybackRate * animlayers[4].m_flCycle;
    //            land_in_cycle = land_time >= previous_record->simulation_time;
    //        }
    //
    //        auto duck_amount_per_tick = (e->m_flDuckAmount() - previous_record->duck_amount) / ticks_chocked;
    //
    //        for (auto i = 0; i < ticks_chocked; ++i)
    //        {
    //            auto simulated_time = previous_record->simulation_time + TICKS_TO_TIME(i);
    //
    //            if (duck_amount_per_tick)
    //                e->m_flDuckAmount() = previous_record->duck_amount + duck_amount_per_tick * (float)i;
    //
    //            on_ground = e->m_fFlags() & FL_ONGROUND;
    //
    //            if (land_in_cycle && !is_landed)
    //            {
    //                if (land_time <= simulated_time)
    //                {
    //                    is_landed = true;
    //                    on_ground = true;
    //                }
    //                else
    //                    on_ground = previous_record->flags & FL_ONGROUND;
    //            }
    //
    //            if (on_ground)
    //                e->m_fFlags() |= FL_ONGROUND;
    //            else
    //                e->m_fFlags() &= ~FL_ONGROUND;
    //
    //            auto simulated_ticks = TIME_TO_TICKS(simulated_time);
    //
    //            m_globals()->m_realtime = simulated_time;
    //            m_globals()->m_curtime = simulated_time;
    //            m_globals()->m_framecount = simulated_ticks;
    //            m_globals()->m_tickcount = simulated_ticks;
    //            m_globals()->m_interpolation_amount = 0.0f;
    //
    //            g_ctx.globals.updating_animation = true;
    //            e->update_clientside_animation();
    //            g_ctx.globals.updating_animation = false;
    //
    //            m_globals()->m_realtime = backup_realtime;
    //            m_globals()->m_curtime = backup_curtime;
    //            m_globals()->m_framecount = backup_framecount;
    //            m_globals()->m_tickcount = backup_tickcount;
    //            m_globals()->m_interpolation_amount = backup_interpolation_amount;
    //
    //            updated_animations = true;
    //        }
    //    }
    //}

    if (previous_record)
    {
        auto velocity = e->m_vecVelocity();
        auto was_in_air = e->m_fFlags() & FL_ONGROUND && previous_record->flags & FL_ONGROUND;

        auto time_difference = max(m_globals()->m_intervalpertick, e->m_flSimulationTime() - previous_record->simulation_time);
        auto origin_delta = e->m_vecOrigin() - previous_record->origin;

        auto animation_speed = 0.0f;

        if (!origin_delta.IsZero() && TIME_TO_TICKS(time_difference) > 0)
        {
            e->m_vecVelocity() = origin_delta * (1.0f / time_difference);

            if (e->m_fFlags() & FL_ONGROUND && animlayers[11].m_flWeight > 0.0f && animlayers[11].m_flWeight < 1.0f && animlayers[11].m_flCycle > previous_record->layers[11].m_flCycle)
            {
                auto weapon = e->m_hActiveWeapon().Get();

                if (weapon)
                {
                    auto max_speed = 260.0f;
                    auto weapon_info = e->m_hActiveWeapon().Get()->get_csweapon_info();

                    if (weapon_info)
                        max_speed = e->m_bIsScoped() ? weapon_info->flMaxPlayerSpeedAlt : weapon_info->flMaxPlayerSpeed;

                    auto modifier = 0.35f * (1.0f - animlayers[11].m_flWeight);

                    if (modifier > 0.0f && modifier < 1.0f)
                        animation_speed = max_speed * (modifier + 0.55f);
                }
            }

            if (animation_speed > 0.0f)
            {
                animation_speed /= e->m_vecVelocity().Length2D();

                e->m_vecVelocity().x *= animation_speed;
                e->m_vecVelocity().y *= animation_speed;
            }

            if (records->size() >= 3 && time_difference > m_globals()->m_intervalpertick)
            {
                auto previous_velocity = (previous_record->origin - records->at(2).origin) * (1.0f / time_difference);

                if (!previous_velocity.IsZero() && !was_in_air)
                {
                    auto current_direction = math::normalize_yaw(RAD2DEG(atan2(e->m_vecVelocity().y, e->m_vecVelocity().x)));
                    auto previous_direction = math::normalize_yaw(RAD2DEG(atan2(previous_velocity.y, previous_velocity.x)));

                    auto average_direction = current_direction - previous_direction;
                    average_direction = DEG2RAD(math::normalize_yaw(current_direction + average_direction * 0.5f));

                    auto direction_cos = cos(average_direction);
                    auto dirrection_sin = sin(average_direction);

                    auto velocity_speed = e->m_vecVelocity().Length2D();

                    e->m_vecVelocity().x = direction_cos * velocity_speed;
                    e->m_vecVelocity().y = dirrection_sin * velocity_speed;
                }
            }

            if (!(record->flags & FL_ONGROUND))
            {
                velocity = (record->origin - previous_record->origin) / record->simulation_time;

                float_t flWeight = 1.0f - record->layers[ANIMATION_LAYER_ALIVELOOP].m_flWeight;

                if (flWeight > 0.0f)
                {
                    float_t flPreviousRate = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;
                    float_t flCurrentRate = record->layers[ANIMATION_LAYER_ALIVELOOP].m_flPlaybackRate;

                    if (flPreviousRate == flCurrentRate)
                    {
                        int32_t iPreviousSequence = previous_record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;
                        int32_t iCurrentSequence = record->layers[ANIMATION_LAYER_ALIVELOOP].m_nSequence;

                        if (iPreviousSequence == iCurrentSequence)
                        {
                            float_t flSpeedNormalized = (flWeight / 2.8571432f) + 0.55f;

                            if (flSpeedNormalized > 0.0f)
                            {
                                float_t flSpeed = flSpeedNormalized * e->GetMaxPlayerSpeed();

                                if (flSpeed > 0.0f)
                                {
                                    if (velocity.Length2D() > 0.0f)
                                    {
                                        velocity.x /= velocity.Length2D() / flSpeed;
                                        velocity.y /= velocity.Length2D() / flSpeed;
                                    }
                                }
                            }
                        }
                    }
                }

                static auto sv_gravity = m_cvar()->FindVar(crypt_str("sv_gravity"));
                velocity.z -= sv_gravity->GetFloat() * 0.5f * TICKS_TO_TIME(record->simulation_time);
            }
            else
                velocity.z = 0.0f;
        }
    }

    if (!updated_animations)
    {
        g_ctx.globals.updating_animation = true;
        e->update_clientside_animation();
        g_ctx.globals.updating_animation = false;
    }

    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));

    auto setup_matrix = [&](player_t* e, AnimationLayer* layers, const int& matrix) -> void
    {
        e->invalidate_physics_recursive(8);

        AnimationLayer backup_layers[13];
        memcpy(backup_layers, e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        memcpy(e->get_animlayers(), layers, e->animlayer_count() * sizeof(AnimationLayer));

        switch (matrix)
        {
        case MAIN:
            e->setup_bones_fixed(record->matrixes_data.main, BONE_USED_BY_ANYTHING);
            break;
        case NONE:
            e->setup_bones_fixed(record->matrixes_data.zero, BONE_USED_BY_HITBOX);
            break;
        case FIRST:
            e->setup_bones_fixed(record->matrixes_data.first, BONE_USED_BY_HITBOX);
            break;
        case SECOND:
            e->setup_bones_fixed(record->matrixes_data.second, BONE_USED_BY_HITBOX);
            break;
        }

        memcpy(e->get_animlayers(), backup_layers, e->animlayer_count() * sizeof(AnimationLayer));
    };

    //if (!player_info.fakeplayer && g_ctx.local()->is_alive() && e->m_iTeamNum() != g_ctx.local()->m_iTeamNum() && !g_cfg.legitbot.enabled) //-V807  //LEGITBOT DELETE
    //{
    //    /* set prev gfy */
    //    animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    previous_goal_feet_yaw[e->EntIndex()] = animstate->m_flGoalFeetYaw;
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //
    //    /* setup matrix for zero desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, NONE);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].gfy_default = animstate->m_flGoalFeetYaw;
    //
    //    /* setup matrix for positive desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.0f);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, FIRST);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[2], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].positive_side = animstate->m_flGoalFeetYaw;
    //
    //    /* setup matrix for negative desync */
    //    animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.0f);
    //
    //    g_ctx.globals.updating_animation = true;
    //    e->update_clientside_animation();
    //    g_ctx.globals.updating_animation = false;
    //
    //    setup_matrix(e, animlayers, SECOND);
    //    memcpy(player_resolver[e->EntIndex()].resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));
    //    memcpy(animstate, &state, sizeof(c_baseplayeranimationstate));
    //    player_resolver[e->EntIndex()].negative_side = animstate->m_flGoalFeetYaw;
    //
    //    // set resolver values
    //    player_resolver[e->EntIndex()].initialize(e, record, previous_goal_feet_yaw[e->EntIndex()], e->m_angEyeAngles().x);
    //    // resolve
    //    player_resolver[e->EntIndex()].resolve_yaw();
    //
    //    switch (record->side)
    //    {
    //    case RESOLVER_ORIGINAL:
    //        animstate->m_flGoalFeetYaw = previous_goal_feet_yaw[e->EntIndex()];
    //        break;
    //    case RESOLVER_ZERO:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y);
    //        break;
    //    case RESOLVER_FIRST:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + 60.f);
    //        break;
    //    case RESOLVER_SECOND:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - 60.f);
    //        break;
    //    case RESOLVER_LOW_FIRST:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y + e->get_max_desync_delta() / 2.2f);
    //        break;
    //    case RESOLVER_LOW_SECOND:
    //        animstate->m_flGoalFeetYaw = math::normalize_yaw(e->m_angEyeAngles().y - e->get_max_desync_delta() / 2.2f);
    //        break;
    //    }
    //
    //    e->m_angEyeAngles().x = player_resolver[e->EntIndex()].resolve_pitch();
    //}

    g_ctx.globals.updating_animation = true;
    e->update_clientside_animation();
    g_ctx.globals.updating_animation = false;

    setup_matrix(e, animlayers, MAIN);
    memcpy(e->m_CachedBoneData().Base(), record->matrixes_data.main, e->m_CachedBoneData().Count() * sizeof(matrix3x4_t));

    m_globals()->m_curtime = backup_curtime;
    m_globals()->m_frametime = backup_frametime;

    e->m_flDuckAmount() = backup_duck_amount;
    e->m_fFlags() = backup_flags;
    e->m_iEFlags() = backup_eflags;

    memcpy(e->get_animlayers(), animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    memcpy(player_resolver[e->EntIndex()].previous_layers, animlayers, e->animlayer_count() * sizeof(AnimationLayer));

    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
Скинуть как челы выглядят вме кроме меня?
ты че наделал вообще с кодом.. ты же говорил деф лв..
 
Сверху Снизу