-
Notifications
You must be signed in to change notification settings - Fork 0
/
Resolver.cpp
276 lines (235 loc) · 7.41 KB
/
Resolver.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
#include "Hooks.h"
#include "Features.h"
enum EResolverStages {
antifreestand,
inverse_antifreestand,
unresolved,
};
std::string ResolverMode[65];
float CResolver::GetAngle(IBasePlayer* player) {
return Math::NormalizeYaw(player->GetEyeAngles().y);
}
float CResolver::GetForwardYaw(IBasePlayer* player) {
return Math::NormalizeYaw(GetBackwardYaw(player) - 180.f);
}
float CResolver::GetAwayAngle(IBasePlayer* player) {
return Math::CalculateAngle(csgo->local->GetEyePosition(), player->GetEyePosition()).y;
}
float CResolver::GetBackwardYaw(IBasePlayer* player) {
return Math::CalculateAngle(csgo->local->GetOrigin(), player->GetOrigin()).y;
}
float CResolver::GetLeftYaw(IBasePlayer* player) {
return Math::NormalizeYaw(Math::CalculateAngle(csgo->local->GetOrigin(), player->GetOrigin()).y - 90.f);
}
float CResolver::GetRightYaw(IBasePlayer* player) {
return Math::NormalizeYaw(Math::CalculateAngle(csgo->local->GetOrigin(), player->GetOrigin()).y + 90.f);
}
void CResolver::StoreAntifreestand()
{
if (!csgo->local->isAlive()) {
memset(this->ResolverInfo, 0, sizeof(this->ResolverInfo));
return;
}
static int delay_ticks[65] = { 0 };
for (int i = 0; i < interfaces.engine->GetMaxClients(); ++i)
{
auto player = interfaces.ent_list->GetClientEntity(i);
if (!player
|| !player->isAlive()
|| player->IsDormant()
|| !player->IsPlayer()
|| player->GetTeam() == csgo->local->GetTeam()
|| player->EntIndex() == interfaces.engine->GetLocalPlayer()) {
continue;
}
auto idx = player->GetIndex();
if (vars.ragebot.resolver) {
if (csgo->actual_misses[player->GetIndex()] <= 0) {
auto latest_animation = g_Animfix->get_latest_animation(player);
if (!latest_animation)
continue;
auto point = g_Ragebot->GetAdvancedHeadPoints(player, latest_animation->unresolved_bones);
g_Ragebot->BackupPlayer(latest_animation);
g_Ragebot->SetAnims(latest_animation, latest_animation->unresolved_bones);
float left_damage = g_AutoWall->Think(point[0], player, HITGROUP_HEAD).m_damage;
float right_damage = g_AutoWall->Think(point[1], player, HITGROUP_HEAD).m_damage;
g_Ragebot->RestorePlayer(latest_animation);
if (left_damage > right_damage)
FreestandSide[idx] = 1;
else if (left_damage < right_damage)
FreestandSide[idx] = -1;
}
memset(&ResolverInfo[idx], 0, sizeof(&ResolverInfo[idx]));
}
}
}
bool DoesHaveFakeAngles(IBasePlayer* player) {
static int skip_ticks[65] = { 0 };
int idx = player->GetIndex();
if (player->GetSimulationTime() == player->GetOldSimulationTime())
skip_ticks[idx]++;
else
skip_ticks[idx] = 0;
return skip_ticks[idx] >= 16;
}
bool CResolver::Do(IBasePlayer* player) {
static int offresolver_ticks[65] = { 0 };
static float last_velocity[65] = { 0.f };
static int ticks_with_zero_pitch[65] = { 0.f };
if (player->GetPlayerInfo().fakeplayer) return false;
int idx = player->GetIndex();
auto animstate = player->GetPlayerAnimState();
if (!animstate || !vars.ragebot.enable || player->HasGunGameImmunity() || !vars.ragebot.resolver || !csgo->local->isAlive()) {
ResolverMode[idx] = str("OFF");
ResolverInfo[idx].Index = 0;
return false;
}
if (player->GetEyeAngles().x < 45.f)
ticks_with_zero_pitch[idx]++;
else
ticks_with_zero_pitch[idx] = 0;
int add = 0;
if (!shot_snapshots.empty()) {
const auto& snapshot = shot_snapshots.front();
const bool& dt_ready = !csgo->need_to_recharge && g_Misc->dt_bullets <= 1 && csgo->weapon->isAutoSniper();
if (dt_ready && snapshot.hitbox == 0 && snapshot.intended_damage > player->GetHealth()) {
add = g_Misc->dt_bullets;
}
}
int missed_shots = (csgo->actual_misses[idx] + csgo->imaginary_misses[idx] + add) % 4;
#ifndef _DEBUG
if (player->GetPlayerInfo().fakeplayer) {
ResolverMode[idx] = str("OFF");
ResolverInfo[idx].Index = 0;
return false;
}
#endif
const float delta = 60.f;
const float angle = GetAngle(player);
const float low_delta = player->GetDSYDelta() * 0.5f;
float desync_angle = delta;
const bool& sideways =
fabsf(Math::NormalizeYaw(angle - GetLeftYaw(player))) < 45.f
||
fabsf(Math::NormalizeYaw(angle - GetRightYaw(player))) < 45.f;
const bool& forward = fabsf(Math::NormalizeYaw(angle - GetForwardYaw(player))) < 90.f && !sideways;
if (!HitInfo[idx].empty()) {
const auto& info = HitInfo[idx].front();
if ((csgo->actual_misses[idx] + csgo->imaginary_misses[idx]) <= 0) {
static std::string AA = str("AA");
static std::string AB = str("AB");
static std::string AC = str("AC");
int side = FreestandSide[idx];
if (side != 0)
{
if (info.Stage == inverse_antifreestand) {
side *= -1;
ResolverMode[idx] = AA;
ResolverInfo[idx].Stage = EResolverStages::inverse_antifreestand;
}
else {
ResolverInfo[idx].Stage = EResolverStages::antifreestand;
ResolverMode[idx] = AB;
}
ResolverInfo[idx].Index = forward ? -side : side;
}
else {
ResolverInfo[idx].Index = 0;
ResolverMode[idx] = AC;
}
if (info.LowDelta) {
desync_angle = low_delta;
ResolverMode[idx].insert(ResolverMode[idx].begin(), 'l');
ResolverInfo[idx].LowDelta = true;
}
else {
ResolverInfo[idx].LowDelta = false;
ResolverMode[idx].insert(ResolverMode[idx].begin(), 'd');
}
return false;
}
}
if (missed_shots >= 2) {
const float& velocity = player->GetVelocity().Length2D();
const bool& additional_check = player->GetDuckAmount() >= 0.8f || player->GetEyeAngles().x <= 60.f;
if (Math::IsNearEqual(velocity, last_velocity[idx], 10.f)) {
if (velocity <= 120.f) {
if (!additional_check)
desync_angle = low_delta;
else {
if (missed_shots >= 3 && additional_check)
desync_angle = low_delta;
}
}
}
}
if (missed_shots == 0) {
if (FreestandSide[idx] != 0) {
ResolverMode[idx] = hs::C.s();
if (forward) {
ResolverMode[idx] += hs::B.s();
}
else
ResolverMode[idx] += hs::A.s();
ResolverInfo[idx].Index = forward ? -FreestandSide[idx] : FreestandSide[idx];
ResolverInfo[idx].Stage = EResolverStages::antifreestand;
}
else
{
static std::string CC = str("CC");
ResolverMode[idx] = CC;
ResolverInfo[idx].Index = 0;
ResolverInfo[idx].Stage = EResolverStages::unresolved;
}
}
else {
switch (missed_shots % 2)
{
case 0:
if (FreestandSide[idx] == 0)
FreestandSide[idx] = 1;
break;
case 1:
if (FreestandSide[idx] == 0)
FreestandSide[idx] = -1;
}
if (forward) {
switch (missed_shots % 2) {
case 0:
ResolverMode[idx] = hs::DB.s();
ResolverInfo[idx].Index = -FreestandSide[idx];
break;
case 1:
ResolverMode[idx] = hs::DA.s();
ResolverInfo[idx].Index = FreestandSide[idx];
break;
}
}
else {
switch (missed_shots % 2) {
case 0:
ResolverMode[idx] = hs::DB.s();
ResolverInfo[idx].Index = FreestandSide[idx];
break;
case 1:
ResolverMode[idx] = hs::DA.s();
ResolverInfo[idx].Index = -FreestandSide[idx];
break;
}
}
if (desync_angle != low_delta)
ResolverInfo[idx].Stage = EResolverStages::inverse_antifreestand;
}
if (desync_angle == low_delta) {
ResolverMode[idx].insert(ResolverMode[idx].begin(), 'l');
ResolverInfo[idx].LowDelta = true;
}
else {
ResolverInfo[idx].LowDelta = false;
ResolverMode[idx].insert(ResolverMode[idx].begin(), 'd');
}
last_velocity[idx] = player->GetVelocity().Length2D();
if (ResolverInfo[idx].Index != 0)
ResolverInfo[idx].ResolvedAngle = Math::NormalizeYaw(angle + (desync_angle * ResolverInfo[idx].Index));
return true;
}