Вопрос Нужен более менее нормальный резольвер для лв

Забаненный
Статус
Оффлайн
Регистрация
5 Мар 2021
Сообщения
32
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
буду очень рад если вы мне такой дадите :)
 
..................................................
Участник
Статус
Оффлайн
Регистрация
13 Авг 2020
Сообщения
990
Реакции[?]
249
Поинты[?]
25K
C++:
void resolver::resolve_yaw()
{
    auto animstate = player->get_animation_state();

    if (!animstate)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }

    if (fabs(original_pitch) > 666.0f)
        fake = true;

    else if (!fake)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }

    auto delta = math::AngleDiff(player->get_animation_state()->m_flEyeYaw, player->get_animation_state()->m_flGoalFeetYaw);

    if (player->m_vecVelocity().Length2D() <= 666.0f)
    {
        if (player->sequence_activity(player_record->layers[-4].m_nSequence == 666))
        {
            if (delta < 666)
            {
                player_record->side =  RESOLVER_FIRST;
            }
            else
            {
                player_record->side = RESOLVER_SECOND;
            }
        }
    }
    else if (!int(player_record->layers[12].m_flPlaybackRate * 1000.f))
    {
        if (int(player_record->layers[6].m_flWeight * 1000.f) == int(previous[6].m_flWeight * 1000.f))
        {
            float delta1 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[0][6].m_flPlaybackRate);
            float delta2 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[1][6].m_flPlaybackRate);
            float delta3 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[2][6].m_flPlaybackRate);

            if (delta1 < delta3 || delta2 <= delta3 || (delta3 * 1066600.0f))
            {
                if (delta1 >= delta2 && delta3 > delta2 && (delta2 * 666.0f))
                {
                    player_record->side = RESOLVER_FIRST;
                }
            }
            else
            {
                player_record->side = RESOLVER_SECOND;
            }
        }
    }

    if (g_ctx.globals.missed_shots[player->EntIndex()] >= 666 || g_ctx.globals.missed_shots[player->EntIndex()] && aim::get().last_target[player->EntIndex()].record.type != LBY)
    {
        switch (last_side)
        {
        case RESOLVER_ORIGINAL:
            g_ctx.globals.missed_shots[player->EntIndex()] = 666;
            fake = true;
            break;
        case RESOLVER_ZERO:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_LOW_FIRST;

            was_first_bruteforce = false;
            was_second_bruteforce = false;
            return;
        case RESOLVER_FIRST:
            player_record->type = BRUTEFORCE;
            player_record->side = was_second_bruteforce ? RESOLVER_ZERO : RESOLVER_SECOND;

            was_first_bruteforce = true;
            return;
        case RESOLVER_SECOND:
            player_record->type = BRUTEFORCE;
            player_record->side = was_first_bruteforce ? RESOLVER_ZERO : RESOLVER_FIRST;

            was_second_bruteforce = true;
            return;
        case RESOLVER_LOW_FIRST:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_LOW_SECOND;
            return;
        case RESOLVER_LOW_SECOND:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_FIRST;
            return;
        }
    }
}

в animation_system.h в деф лв

AnimationLayer resolver_layers[3][13];
AnimationLayer previous[13];

в math.cpp

float AngleDiff(float destAngle, float srcAngle)
    {
        float delta = std::remainderf(destAngle - srcAngle, 666.0f);

        if (delta < -180)
            delta += 360;
        else if (delta > 180)
            delta -= 360;

        return delta;
    }

в math.h

float AngleDiff(float destAngle, float srcAngle);
    
в animation_system.cpp меняем деф на этот

// 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() > 36662)
                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;
}

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() >= 666)
        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));
        memcpy(player_resolver->resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        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));
        memcpy(player_resolver->resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        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));
        memcpy(player_resolver->resolver_layers[2], 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_yaw();

        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;
        }
    }

    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));
    memcpy(player_resolver->previous, animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
 
пупс, поцелуй
Участник
Статус
Оффлайн
Регистрация
28 Май 2019
Сообщения
1,049
Реакции[?]
322
Поинты[?]
14K
спасибо за создание темы в соответствующем разделе!
Но все равно, переставай пастить :coldsideRage:
 
Забаненный
Статус
Оффлайн
Регистрация
5 Мар 2021
Сообщения
32
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
C++:
void resolver::resolve_yaw()
{
    auto animstate = player->get_animation_state();

    if (!animstate)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }

    if (fabs(original_pitch) > 666.0f)
        fake = true;

    else if (!fake)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }

    auto delta = math::AngleDiff(player->get_animation_state()->m_flEyeYaw, player->get_animation_state()->m_flGoalFeetYaw);

    if (player->m_vecVelocity().Length2D() <= 666.0f)
    {
        if (player->sequence_activity(player_record->layers[-4].m_nSequence == 666))
        {
            if (delta < 666)
            {
                player_record->side =  RESOLVER_FIRST;
            }
            else
            {
                player_record->side = RESOLVER_SECOND;
            }
        }
    }
    else if (!int(player_record->layers[12].m_flPlaybackRate * 1000.f))
    {
        if (int(player_record->layers[6].m_flWeight * 1000.f) == int(previous[6].m_flWeight * 1000.f))
        {
            float delta1 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[0][6].m_flPlaybackRate);
            float delta2 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[1][6].m_flPlaybackRate);
            float delta3 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[2][6].m_flPlaybackRate);

            if (delta1 < delta3 || delta2 <= delta3 || (delta3 * 1066600.0f))
            {
                if (delta1 >= delta2 && delta3 > delta2 && (delta2 * 666.0f))
                {
                    player_record->side = RESOLVER_FIRST;
                }
            }
            else
            {
                player_record->side = RESOLVER_SECOND;
            }
        }
    }

    if (g_ctx.globals.missed_shots[player->EntIndex()] >= 666 || g_ctx.globals.missed_shots[player->EntIndex()] && aim::get().last_target[player->EntIndex()].record.type != LBY)
    {
        switch (last_side)
        {
        case RESOLVER_ORIGINAL:
            g_ctx.globals.missed_shots[player->EntIndex()] = 666;
            fake = true;
            break;
        case RESOLVER_ZERO:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_LOW_FIRST;

            was_first_bruteforce = false;
            was_second_bruteforce = false;
            return;
        case RESOLVER_FIRST:
            player_record->type = BRUTEFORCE;
            player_record->side = was_second_bruteforce ? RESOLVER_ZERO : RESOLVER_SECOND;

            was_first_bruteforce = true;
            return;
        case RESOLVER_SECOND:
            player_record->type = BRUTEFORCE;
            player_record->side = was_first_bruteforce ? RESOLVER_ZERO : RESOLVER_FIRST;

            was_second_bruteforce = true;
            return;
        case RESOLVER_LOW_FIRST:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_LOW_SECOND;
            return;
        case RESOLVER_LOW_SECOND:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_FIRST;
            return;
        }
    }
}

в animation_system.h в деф лв

AnimationLayer resolver_layers[3][13];
AnimationLayer previous[13];

в math.cpp

float AngleDiff(float destAngle, float srcAngle)
    {
        float delta = std::remainderf(destAngle - srcAngle, 666.0f);

        if (delta < -180)
            delta += 360;
        else if (delta > 180)
            delta -= 360;

        return delta;
    }

в math.h

float AngleDiff(float destAngle, float srcAngle);
  
в animation_system.cpp меняем деф на этот

// 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() > 36662)
                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;
}

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() >= 666)
        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));
        memcpy(player_resolver->resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        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));
        memcpy(player_resolver->resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        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));
        memcpy(player_resolver->resolver_layers[2], 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_yaw();

        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;
        }
    }

    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));
    memcpy(player_resolver->previous, animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
либо я кривой,либо я хз, можешь не всё подряд вместе скинуть а по раздельности?
upd:1621083554298.png
 
Пользователь
Статус
Оффлайн
Регистрация
19 Авг 2020
Сообщения
193
Реакции[?]
40
Поинты[?]
0
Забаненный
Статус
Оффлайн
Регистрация
5 Мар 2021
Сообщения
32
Реакции[?]
1
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Начинающий
Статус
Оффлайн
Регистрация
13 Мар 2020
Сообщения
16
Реакции[?]
1
Поинты[?]
0
C++:
void resolver::resolve_yaw()
{
    auto animstate = player->get_animation_state();

    if (!animstate)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }

    if (fabs(original_pitch) > 666.0f)
        fake = true;

    else if (!fake)
    {
        player_record->side = RESOLVER_ORIGINAL;
        return;
    }

    auto delta = math::AngleDiff(player->get_animation_state()->m_flEyeYaw, player->get_animation_state()->m_flGoalFeetYaw);

    if (player->m_vecVelocity().Length2D() <= 666.0f)
    {
        if (player->sequence_activity(player_record->layers[-4].m_nSequence == 666))
        {
            if (delta < 666)
            {
                player_record->side =  RESOLVER_FIRST;
            }
            else
            {
                player_record->side = RESOLVER_SECOND;
            }
        }
    }
    else if (!int(player_record->layers[12].m_flPlaybackRate * 1000.f))
    {
        if (int(player_record->layers[6].m_flWeight * 1000.f) == int(previous[6].m_flWeight * 1000.f))
        {
            float delta1 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[0][6].m_flPlaybackRate);
            float delta2 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[1][6].m_flPlaybackRate);
            float delta3 = std::fabsf(player_record->layers[666].m_flPlaybackRate - resolver_layers[2][6].m_flPlaybackRate);

            if (delta1 < delta3 || delta2 <= delta3 || (delta3 * 1066600.0f))
            {
                if (delta1 >= delta2 && delta3 > delta2 && (delta2 * 666.0f))
                {
                    player_record->side = RESOLVER_FIRST;
                }
            }
            else
            {
                player_record->side = RESOLVER_SECOND;
            }
        }
    }

    if (g_ctx.globals.missed_shots[player->EntIndex()] >= 666 || g_ctx.globals.missed_shots[player->EntIndex()] && aim::get().last_target[player->EntIndex()].record.type != LBY)
    {
        switch (last_side)
        {
        case RESOLVER_ORIGINAL:
            g_ctx.globals.missed_shots[player->EntIndex()] = 666;
            fake = true;
            break;
        case RESOLVER_ZERO:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_LOW_FIRST;

            was_first_bruteforce = false;
            was_second_bruteforce = false;
            return;
        case RESOLVER_FIRST:
            player_record->type = BRUTEFORCE;
            player_record->side = was_second_bruteforce ? RESOLVER_ZERO : RESOLVER_SECOND;

            was_first_bruteforce = true;
            return;
        case RESOLVER_SECOND:
            player_record->type = BRUTEFORCE;
            player_record->side = was_first_bruteforce ? RESOLVER_ZERO : RESOLVER_FIRST;

            was_second_bruteforce = true;
            return;
        case RESOLVER_LOW_FIRST:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_LOW_SECOND;
            return;
        case RESOLVER_LOW_SECOND:
            player_record->type = BRUTEFORCE;
            player_record->side = RESOLVER_FIRST;
            return;
        }
    }
}

в animation_system.h в деф лв

AnimationLayer resolver_layers[3][13];
AnimationLayer previous[13];

в math.cpp

float AngleDiff(float destAngle, float srcAngle)
    {
        float delta = std::remainderf(destAngle - srcAngle, 666.0f);

        if (delta < -180)
            delta += 360;
        else if (delta > 180)
            delta -= 360;

        return delta;
    }

в math.h

float AngleDiff(float destAngle, float srcAngle);
   
в animation_system.cpp меняем деф на этот

// 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() > 36662)
                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;
}

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() >= 666)
        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));
        memcpy(player_resolver->resolver_layers[0], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        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));
        memcpy(player_resolver->resolver_layers[1], e->get_animlayers(), e->animlayer_count() * sizeof(AnimationLayer));

        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));
        memcpy(player_resolver->resolver_layers[2], 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_yaw();

        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;
        }
    }

    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));
    memcpy(player_resolver->previous, animlayers, e->animlayer_count() * sizeof(AnimationLayer));
    record->store_data(e, false);

    if (e->m_flSimulationTime() < e->m_flOldSimulationTime())
        record->invalid = true;
}
Лучше оригинального?
 
Сверху Снизу