Исходник onetap v2 prediction system

Пользователь
Статус
Оффлайн
Регистрация
8 Янв 2020
Сообщения
187
Реакции[?]
138
Поинты[?]
20K
Onetap v2 prediction system.

Возможно вронг.

C++:
void CPredictionSystem::StoreNetvars()
{
    backup_netvars.tickbase = g_pLocalPlayer->m_nTickBase();
    backup_netvars.flags = g_pLocalPlayer->m_fFlags();
    backup_netvars.move_type = g_pLocalPlayer->m_iMoveType();
    backup_netvars.duck_amount = g_pLocalPlayer->m_flDuckAmount();
    backup_netvars.origin = g_pLocalPlayer->m_vecOrigin();
    backup_netvars.velocity = g_pLocalPlayer->m_vecVelocity();
    backup_netvars.velocity_modifier = g_pLocalPlayer->m_flVelocityModifier();
    backup_netvars.view_offset = g_pLocalPlayer->m_vecViewOffset();
    backup_netvars.aim_punch = g_pLocalPlayer->m_vecAimPunchAngle();
    backup_netvars.aim_punch_vel = g_pLocalPlayer->m_vecAimPunchAngleVel();
    backup_netvars.view_punch = g_pLocalPlayer->m_vecViewPunchAngle();

    CBaseCombatWeapon* active_weapon = g_pLocalPlayer->m_hActiveWeapon().Get();

    if (active_weapon)
    {
        backup_netvars.recoil_index = active_weapon->m_flRecoilIndex();
        backup_netvars.accuracy_penalty = active_weapon->m_fAccuracyPenalty();
    }
}

void CPredictionSystem::RestoreNetvars()
{
    g_pLocalPlayer->m_nTickBase() = backup_netvars.tickbase;
    g_pLocalPlayer->m_fFlags() = backup_netvars.flags;
    g_pLocalPlayer->m_iMoveType() = backup_netvars.move_type;
    g_pLocalPlayer->m_flDuckAmount() = backup_netvars.duck_amount;
    g_pLocalPlayer->m_vecOrigin() = backup_netvars.origin;
    g_pLocalPlayer->m_vecVelocity() = backup_netvars.velocity;
    g_pLocalPlayer->m_flVelocityModifier() = backup_netvars.velocity_modifier;
    g_pLocalPlayer->m_vecViewOffset() = backup_netvars.view_offset;
    g_pLocalPlayer->m_vecAimPunchAngle() = backup_netvars.aim_punch;
    g_pLocalPlayer->m_vecAimPunchAngleVel() = backup_netvars.aim_punch_vel;
    g_pLocalPlayer->m_vecViewPunchAngle() = backup_netvars.view_punch;

    CBaseCombatWeapon* active_weapon = g_pLocalPlayer->m_hActiveWeapon().Get();

    if (active_weapon)
    {
        active_weapon->m_flRecoilIndex() = backup_netvars.recoil_index;
        active_weapon->m_fAccuracyPenalty() = backup_netvars.accuracy_penalty;
    }
}

void CPredictionSystem::UpdatePrediction()
{
    if (g_pGlobals.StoredVelocityModifier < 1.0)
        g_pPrediction->m_bFirstTimePredicted = true;

    if (g_pClientState->m_iDeltaTick > 0)
        g_pPrediction->Update(g_pClientState->m_iDeltaTick, true, g_pClientState->m_nLastCommandAck, g_pClientState->m_nLastOutgoingCommand + g_pClientState->m_iChokedCommands);

    CBaseCombatWeapon* active_weapon = g_pLocalPlayer->m_hActiveWeapon().Get();

    if (active_weapon)
        CPredictionSystem::UpdatePostponeFiretime(active_weapon);
}

void CPredictionSystem::UpdatePostponeFiretime(CBaseCombatWeapon* weapon)
{
    if (weapon->m_iItemDefinitionIndex() == WEAPON_REVOLVER && g_pConfigs.RageBot.Enabled)
    {
        if (weapon->m_flNextPrimaryAttack() == 0x7F7FFFFF)
            weapon->m_flNextPrimaryAttack() = weapon->m_flPostponeFireReadyTime();
    }
}

void CPredictionSystem::Predict()
{
    if (g_pLocalPlayer->IsAlive())
    {
        CMoveData movedata;
        std::memset(movedata, 0, sizeof(CMoveData));

        backup.stored_curtime = g_pGlobalVars->m_flCurTime;
        backup.stored_frametime = g_pGlobalVars->m_flFrameTime;

        backup.isfirsttimepredicted = g_pPrediction->m_bFirstTimePredicted;
        backup.inprediction = g_pPrediction->m_bInPrediction;

        backup.unpredicted_movetype = g_pLocalPlayer->m_iMoveType();
        backup.unpredicted_velocity = g_pLocalPlayer->m_vecVelocity();

        g_pGlobalVars->m_flCurTime = TICKS_TO_TIME(g_pLocalPlayer->m_nTickBase());
        g_pGlobalVars->m_flFrameTime = g_pGlobalVars->m_flIntervalPerTick;

        g_pPrediction->StartTrackPredictionErrors(g_pLocalPlayer);
        g_pPrediction->SetupMove(g_pLocalPlayer, g_pGlobals.UserCmd, g_pMoveHelper, &movedata);

        СPredictionSystem::RestoreNetvars();
        CPredictionSystem::RePredict();
    }
}

void CPredictionSystem::RePredict(CMoveData& movedata)
{
    if (g_pLocalPlayer->IsAlive())
    {
        CPredictionSystem::UpdatePrediction();
        CPredictionSystem::StoreNetvars();

        *data.predicted_seed = /*predicted seed signature*/;
        *data.predicted_player = /*predicted player signature*/;

        movedata.forward_move = g_pGlobals.UserCmd->m_forwardMove;
        movedata.side_move = g_pGlobals.UserCmd->m_sideMove;
        movedata.up_move = g_pGlobals.UserCmd->m_upMove;
        movedata.buttons = g_pGlobals.UserCmd->m_buttons;
        movedata.viewangles = g_pGlobals.UserCmd->m_viewAngles;
        movedata.angles = g_pGlobals.UserCmd->m_viewAngles;
        movedata.impulse = g_pGlobals.UserCmd->m_impulse;

        g_pPrediction->m_bFirstTimePredicted = false;
        g_pPrediction->m_bInPrediction = true;

        *data.predicted_seed = g_pGlobals.UserCmd.m_randomSeed;
        *data.predicted_player = g_pLocalPlayer;

        g_pGlobalVars->m_flCurTime = TICKS_TO_TIME(g_pLocalPlayer->m_nTickBase());

        float m_flFinalFrametime = 0.0;

        if (!(g_pLocalPlayer->m_fFlags() & FL_ATCONTROLS))
            m_flFinalFrametime = g_pGlobalVars->m_flIntervalPerTick;

        g_pGlobalVars->m_flFrameTime = m_flFinalFrametime;

        g_pMoveHelper->SetHost(g_pLocalPlayer);
        g_pPrediction->StartTrackPredictionErrors(g_pLocalPlayer);
        g_pGameMovement->ProcessMovement(g_pLocalPlayer, &movedata);

        g_pPrediction->FinishTrackPredictionErrors(g_pLocalPlayer);
        g_pMoveHelper->SetHost(nullptr);

        *data.predicted_seed = -1;
        *data.predicted_player = 0;

        CBaseCombatWeapon* active_weapon = g_pLocalPlayer->m_hActiveWeapon().Get();

        if (active_weapon)
            active_weapon->UpdateAccuracyPenatly();

        g_pGlobalVars->m_flCurTime = backup.stored_curtime;
        g_pGlobalVars->m_flFrameTime = backup.stored_frametime;

        g_pPrediction->m_bFirstTimePredicted = backup.isfirsttimepredicted;
        g_pPrediction->m_bInPrediction = backup.inprediction;
    }
}
 
Последнее редактирование:
Забаненный
Статус
Оффлайн
Регистрация
26 Апр 2021
Сообщения
18
Реакции[?]
2
Поинты[?]
0
Обратите внимание, пользователь заблокирован на форуме. Не рекомендуется проводить сделки.
Похожие темы
Сверху Снизу