forked from SimpleRealistic/styles-cheat-csgo-source
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEnginePrediction.cpp
95 lines (78 loc) · 2.4 KB
/
EnginePrediction.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include "EnginePrediction.h"
#include "Hacks.h"
#include "NetVars.h"
#include "XorStr.hpp"
Vector vecBaseVelocity;
float flFallVelocity;
float m_accuracyPenalty;
int GetIDToOffsetIndex(int id)
{
switch (id)
{
case WEAPON_GLOCK:
return OFFSETINDEX_GLOCK;
break;
case OFFSETINDEX_FAMAS:
return OFFSETINDEX_FAMAS;
break;
case WEAPON_M4A1:
return OFFSETINDEX_M4A1;
break;
case WEAPON_USP:
return OFFSETINDEX_USP;
break;
default:
break;
}
return -1;
}
void PredictWeapon(IClientEntity *localPlayer)
{
CBaseCombatWeapon *weapon = localPlayer->GetWeapon();
if (!weapon)
return;
bool shouldupdate = true;
int id = weapon->GetWeaponId();
int offsetIndex = GetIDToOffsetIndex(id);
if ((id == WEAPON_GLOCK) || (id == WEAPON_FAMAS))
{
if (weapon->IsSpecialMode(offsetIndex) && weapon->HasBurstShotsRemaining(offsetIndex))
{
shouldupdate = false;
}
}
if (shouldupdate)
{
m_accuracyPenalty = weapon->GetInaccuracy();
weapon->UpdateAccPenalty();
}
}
void StartPrediction(CUserCmd* pCmd)
{
auto bMoveData = *reinterpret_cast<void**>(reinterpret_cast<DWORD>(I::GameMovement) + 0x8);
if (I::MoveHelper && I::Engine->IsConnected() && I::Engine->IsInGame() && hackManager.pLocal()->IsAlive())
{
vecBaseVelocity = hackManager.pLocal()->GetBaseVelocity();
flFallVelocity = *hackManager.pLocal()->GetFallVelocity();
I::MoveHelper->SetHost(hackManager.pLocal());
*I::PredictionRandomSeed = pCmd->random_seed;
float curtime = I::Globals->curtime;
float frametime = I::Globals->frametime;
int iFlags = *hackManager.pLocal()->GetFlags();
I::Globals->curtime = (float)hackManager.pLocal()->GetTickBase() * I::Globals->interval_per_tick;
I::Globals->frametime = I::Globals->interval_per_tick;
I::GameMovement->StartTrackPredictionErrors(hackManager.pLocal());
I::Prediction->SetupMove(hackManager.pLocal(), pCmd, nullptr, bMoveData);
I::GameMovement->ProcessMovement(hackManager.pLocal(), bMoveData);
I::Prediction->FinishMove(hackManager.pLocal(), pCmd, bMoveData);
I::GameMovement->FinishTrackPredictionErrors(hackManager.pLocal());
I::Globals->curtime = curtime;
I::Globals->frametime = frametime;
*hackManager.pLocal()->GetFlags() = iFlags;
*I::PredictionRandomSeed = -1;
I::MoveHelper->SetHost(nullptr);
hackManager.pLocal()->GetBaseVelocity() = vecBaseVelocity;
*hackManager.pLocal()->GetFallVelocity() = flFallVelocity;
PredictWeapon(hackManager.pLocal());
}
}