Исходник Weave prediction system

Забаненный
Статус
Оффлайн
Регистрация
20 Янв 2021
Сообщения
33
Реакции[?]
22
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Код:
#include "EnginePrediction.h"
#include "checksum_md5.h"
#include "AntiAims.h"

int post_think(IBasePlayer* player)
{
    getvfunc<void(__thiscall*)(void*)>(interfaces.model_cache, 33)(interfaces.model_cache);

    if (player->isAlive()
        || *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(player) + 0x3A81)) {
        getvfunc<void(__thiscall*)(void*)>(player, 339)(player);

        player->GetFlags()& FL_ONGROUND ? player->GetFallVelocity() = 0.f : 0;

        player->GetSequence() == -1 ? getvfunc<void(__thiscall*)(void*, int)>(player, 218)(player, 0) : 0;

        getvfunc<void(__thiscall*)(void*)>(player, 219)(player);

        static auto post_think_v_physics = reinterpret_cast <bool(__thiscall*)(IBasePlayer*)> (csgo->Utils.FindPatternIDA(GetModuleHandleA(g_Modules[fnv::hash(hs::client_dll::s().c_str())].c_str()),
            hs::post_think::s().c_str()));
        post_think_v_physics(player);
    }

    static auto simulate_player_simulated_entities = reinterpret_cast <bool(__thiscall*)(IBasePlayer*)> (csgo->Utils.FindPatternIDA(GetModuleHandleA(
        g_Modules[fnv::hash(hs::client_dll::s().c_str())].c_str()),
        hs::simulate_player::s().c_str()));
    simulate_player_simulated_entities(player);

    return getvfunc<int(__thiscall*)(void*)>(interfaces.model_cache, 34)(interfaces.model_cache);
}

void CEnginePrediction::FixNetvarCompression(CUserCmd* cmd, IBasePlayer* local)
{
    Vector m_aimPunchAngle = {};
    Vector m_aimPunchAngleVel = {};
    Vector m_viewPunchAngle = {};

    Vector m_vecViewOffset = {};
    Vector m_vecBaseVelocity = {};

    Vector m_vecVelocity = {};
    Vector m_vecOrigin = {};

    float m_flDuckAmount = 0.0f;
    m_flDuckAmount = 0.0f;

    float m_flDuckSpeed = 0.0f;
    m_flDuckSpeed = 0.0f;

    float m_flFallVelocity = 0.0f;
    m_flFallVelocity = 0.0f;

    float m_flVelocityModifier = 0.0f;
    m_flVelocityModifier = 0.0f;

    const auto aim_punch_vel_diff = m_aimPunchAngleVel - local->GetPunchAngleVel();
    const auto aim_punch_diff = m_aimPunchAngle - local->GetPunchAngle();
    const auto viewpunch_diff = m_viewPunchAngle.x - local->GetViewPunchAngle().x;
    const auto velocity_diff = m_vecVelocity - local->GetVelocity();
    const auto origin_diff = m_vecOrigin - local->GetOrigin();

    if (std::abs(aim_punch_diff.x) <= 0.03125f && std::abs(aim_punch_diff.y) <= 0.03125f && std::abs(aim_punch_diff.z) <= 0.03125f)
       local->GetPunchAngle() = m_aimPunchAngle;

    if (std::abs(aim_punch_vel_diff.x) <= 0.03125f && std::abs(aim_punch_vel_diff.y) <= 0.03125f && std::abs(aim_punch_vel_diff.z) <= 0.03125f)
        local->GetPunchAngleVel() = m_aimPunchAngleVel;

    if (std::abs(local->GetVecViewOffset().z - m_vecViewOffset.z) <= 0.25f)
        local->GetVecViewOffset().z = m_vecViewOffset.z;

    if (abs(local->GetDuckAmount() - m_flDuckAmount) <= 0.03125f)
        local->GetDuckAmount() = m_flDuckAmount;

    if (abs(origin_diff.x) <= 0.03125f && abs(origin_diff.y) <= 0.03125f && abs(origin_diff.z) <= 0.03125f)
    {
        local->GetOrigin() = m_vecOrigin;
        local->SetAbsOrigin(m_vecOrigin);
    }

    if (std::abs(velocity_diff.x) <= 0.03125f && std::abs(velocity_diff.y) <= 0.03125f && std::abs(velocity_diff.z) <= 0.03125f)
        local->GetVelocity() = m_vecVelocity;

    if (abs(local->GetDuckSpeed() - m_flDuckSpeed) <= 0.03125f)
       local->GetDuckSpeed() = m_flDuckSpeed;

    if (abs(local->GetFallVelocity() - m_flFallVelocity) <= 0.03125f)
        local->GetFallVelocity() = m_flFallVelocity;

    if (std::abs(local->GetVelocityModifier() - m_flVelocityModifier) <= 0.00625f)
        local->GetVelocityModifier() = m_flVelocityModifier;
}

void CEnginePrediction::Start(CUserCmd* cmd, IBasePlayer* local) {

    if (!local)
        return;

    interfaces.prediction->Update(csgo->client_state->iDeltaTick, true, csgo->client_state->nLastCommandAck, csgo->client_state->nLastOutgoingCommand + csgo->client_state->iChokedCommands);

    if (!prediction_random_seed)
        prediction_random_seed = *reinterpret_cast <int**> (csgo->Utils.FindPatternIDA(GetModuleHandleA(g_Modules[fnv::hash(hs::client_dll::s().c_str())].c_str()), hs::random_seed::s().c_str()) + 0x1);

    old_vars.curtime = interfaces.global_vars->curtime;
    old_vars.frametime = interfaces.global_vars->frametime;
    old_vars.tickcount = interfaces.global_vars->tickcount;

    old_vars.m_in_prediction = interfaces.prediction->bInPrediction;
    old_vars.m_first_time_predicted = interfaces.prediction->bIsFirstTimePredicted;

    interfaces.global_vars->curtime = TICKS_TO_TIME(GetTickbase(cmd, local));
    interfaces.global_vars->frametime = interfaces.prediction->bEnginePaused ? 0.f : interfaces.global_vars->interval_per_tick;
    interfaces.global_vars->tickcount = TIME_TO_TICKS(interfaces.global_vars->curtime);

    interfaces.prediction->bInPrediction = true;
    interfaces.prediction->bIsFirstTimePredicted = false;

    *reinterpret_cast<CUserCmd**>(reinterpret_cast<uintptr_t>(local) + 0x3288) = cmd;

    if (!prediction_player)
        prediction_player = *reinterpret_cast <int**> (csgo->Utils.FindPatternIDA(GetModuleHandleA(g_Modules[fnv::hash(hs::client_dll::s().c_str())].c_str()), hs::prediction_player::s().c_str()) + 0x2);

    auto buttons_forced = *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(local) + 0x3334);
    auto buttons_disabled = *reinterpret_cast<int*>(reinterpret_cast<uintptr_t>(local) + 0x3330);

    cmd->buttons |= buttons_forced;
    cmd->buttons &= ~buttons_disabled;

    if (cmd->weaponselect) {
        auto weapon = reinterpret_cast<IBaseCombatWeapon*>(interfaces.ent_list->GetClientEntity(cmd->weaponselect));
        if (weapon) {
            auto weapon_data = weapon->GetCSWpnData();
            weapon_data ? local->SelectItem(weapon_data->m_szWeaponName, cmd->weaponsubtype) : 0;
        }
    }

    if (cmd->impulse)
        *local->GetImpulse() = cmd->impulse;

    auto buttons = cmd->buttons;
    auto buttons_changed = buttons ^ *local->GetButtons();

    local->GetButtonLast() = *local->GetButtons();

    *local->GetButtons() = buttons;

    local->GetButtonPressed() = buttons_changed & buttons;

    local->GetButtonReleased() = buttons_changed & ~buttons;

    interfaces.prediction->CheckMovingGround(local, interfaces.global_vars->frametime);

    local->SetLocalViewAngles(cmd->viewangles);

    if (local->PhysicsRunThink(0))
        local->PreThink();

    if (local->GetNextThinkTick() > 0 && *local->GetNextThinkTick() <= GetTickbase(cmd, local))
    {
        *local->GetNextThinkTick() = -1;
        local->UnkFunc();
        local->Think();
    }

    interfaces.move_helper->SetHost(local);
    interfaces.game_movement->StartTrackPredictionErrors(local);

    memset(&data, 0, sizeof(data));
    interfaces.prediction->SetupMove(local, cmd, interfaces.move_helper, &data);
    interfaces.game_movement->ProcessMovement(local, &data);

    interfaces.prediction->FinishMove(local, cmd, &data);
    interfaces.move_helper->ProcessImpacts();

    post_think(local);

    interfaces.prediction->bInPrediction = old_vars.m_in_prediction;
    interfaces.prediction->bIsFirstTimePredicted = old_vars.m_first_time_predicted;
}

void CEnginePrediction::Finish(IBasePlayer* local) {
    if (!local)
        return;

    interfaces.game_movement->FinishTrackPredictionErrors(local);
    interfaces.move_helper->SetHost(nullptr);

    interfaces.game_movement->Reset();

    *prediction_random_seed = -1;
    *prediction_player = 0;

    interfaces.global_vars->curtime = old_vars.curtime;
    interfaces.global_vars->frametime = old_vars.frametime;
    interfaces.global_vars->tickcount = old_vars.tickcount;

    !interfaces.prediction->bEnginePaused&& interfaces.global_vars->frametime ? local->GetTickBasePtr()++ : 0;
}

int CEnginePrediction::GetTickbase(CUserCmd* pCmd, IBasePlayer* pLocal)
{
    static int iTick = 0;
    static CUserCmd* pLastCmd = nullptr;

    if (pCmd != nullptr)
    {
        if (pLastCmd == nullptr || pLastCmd->hasbeenpredicted)
            iTick = pLocal->GetTickBase();
        else
            iTick++;

        pLastCmd = pCmd;
    }

    return iTick;
}
Код:
#pragma once
#include "hooks.h"
#define ZERO Vector(0.0f, 0.0f, 0.0f)
#define MULTIPLAYER_BACKUP 150

struct backup
{
    int flags = 0;
    Vector velocity = Vector(0, 0, 0);
};

class CEnginePrediction : public Singleton<CEnginePrediction>
{
public:
    void FixNetvarCompression(CUserCmd* cmd, IBasePlayer* local);
    void Start(CUserCmd* cmd, IBasePlayer* local);
    void Finish(IBasePlayer* local);

    int GetTickbase(CUserCmd* pCmd, IBasePlayer* pLocal);

    backup backup_data;
private:
    CMoveData data;
    CUserCmd* last_cmd{};
    int32_t tick_base{};
    struct {
        float curtime, frametime;
        int tickcount, tickbase;
        bool m_in_prediction, m_first_time_predicted;
    }old_vars;
    int* prediction_random_seed = nullptr;
    int* prediction_player = nullptr;
};
 
Начинающий
Статус
Оффлайн
Регистрация
28 Авг 2017
Сообщения
52
Реакции[?]
18
Поинты[?]
1K
C:
static auto post_think_v_physics = reinterpret_cast <bool(__thiscall*)(IBasePlayer*)> (csgo->Utils.FindPatternIDA(GetModuleHandleA(g_Modules[fnv::hash(hs::client_dll::s().c_str())].c_str()),
hs::post_think::s().c_str()));

interfaces.global_vars->curtime = TICKS_TO_TIME(GetTickbase(cmd, local));
:NotLikeThis:
 
ставь чайник, зажигай плиту
Эксперт
Статус
Оффлайн
Регистрация
22 Май 2020
Сообщения
1,444
Реакции[?]
1,092
Поинты[?]
10K
Похожие темы
Сверху Снизу