Я у мамы даун
-
Автор темы
- #1
predict.cpp
predict.hpp
Код:
void prediction::start()
{
static auto g_pLocalPlayer = Globals::LocalPlayer;
if (!g_pLocalPlayer)
return;
static auto oldorigin = g_pLocalPlayer->GetOrigin();
unpred_vel = (g_pLocalPlayer->GetOrigin() - oldorigin) * (1.0 / g_pGlobalVars->intervalPerTick);
oldorigin = g_pLocalPlayer->GetOrigin();
unpred_eyepos = g_pLocalPlayer->GetEyePosition();
static bool is_initialized = false;
if (!is_initialized)
{
m_prediction_random_seed = *(int**)(Utils::FindSignature("client_panorama.dll", "8B 0D ? ? ? ? BA ? ? ? ? E8 ? ? ? ? 83 C4 04") + 2);
is_initialized = true;
}
*m_prediction_random_seed = MD5_PseudoRandom(Globals::pCmd->command_number) & 0x7FFFFFFF;
orig_currtime = g_pGlobalVars->curtime;
orig_frametime = g_pGlobalVars->frametime;
g_pGlobalVars->curtime = get_curtime();
g_pGlobalVars->frametime = g_pLocalPlayer->GetFlags() & FL_FROZEN ? 0 : g_pGlobalVars->intervalPerTick;
g_pMovement->StartTrackPredictionErrors(g_pLocalPlayer);
memset(&move_data, 0, sizeof(move_data));
g_pMoveHelper->SetHost(g_pLocalPlayer);
g_pPrediction->SetupMove(g_pLocalPlayer, Globals::pCmd, g_pMoveHelper, &move_data);
g_pMovement->ProcessMovement(g_pLocalPlayer, &move_data);
g_pPrediction->FinishMove(g_pLocalPlayer, Globals::pCmd, &move_data);
static auto pred_oldorigin = g_pLocalPlayer->GetOrigin();
pred_vel = (g_pLocalPlayer->GetOrigin() - pred_oldorigin) * (1.0 / g_pGlobalVars->intervalPerTick);
pred_oldorigin = g_pLocalPlayer->GetOrigin();
unpred_eyepos = g_pLocalPlayer->GetEyePosition();
}
void prediction::finish() const
{
static auto g_pLocalPlayer = Globals::LocalPlayer;
if (!g_pLocalPlayer)
return;
g_pMovement->FinishTrackPredictionErrors(g_pLocalPlayer);
g_pMoveHelper->SetHost(nullptr);
*m_prediction_random_seed = -1;
g_pGlobalVars->curtime = orig_currtime;
g_pGlobalVars->frametime = orig_frametime;
}
int prediction::get_tickbase()
{
return Globals::LocalPlayer->GetTickBase();
}
float prediction::get_curtime()
{
return get_tickbase() * g_pGlobalVars->intervalPerTick;
}
float prediction::get_unpred_curtime()
{
return orig_currtime;
}
Vector prediction::get_unpred_vel()
{
return unpred_vel;
}
Vector prediction::get_pred_vel()
{
return pred_vel;
}
Vector prediction::get_unpred_eyepos()
{
return unpred_eyepos;
}
Код:
#pragma once
#include "../../SDK/singleton.h"
#include "../../SDK/Vector.h"
#include "../../SDK/CPrediction.h"
class prediction : public singleton<prediction>
{
public:
void start();
void finish() const;
static int get_tickbase();
static float get_curtime();
float get_unpred_curtime();
Vector get_unpred_vel();
Vector get_pred_vel();
Vector get_unpred_eyepos();
private:
float orig_currtime = 0.f;
float orig_frametime = 0.f;
CMoveData move_data;
int* m_prediction_random_seed = nullptr;
Vector unpred_vel;
Vector unpred_eyepos;
Vector pred_vel;
};