-
Notifications
You must be signed in to change notification settings - Fork 2
/
AntiAntiAim.cpp
203 lines (176 loc) · 5.12 KB
/
AntiAntiAim.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
// Don't take credits for this ;) Joplin / Manhhao are the first uploaders ;)
// Credits to Valve and Shad0w
#include "Interfaces.h"
#include "Menu.h"
// Shad0ws Yaw fix
// (FIX ME UP LATER)
void FixY(const CRecvProxyData *pData, void *pStruct, void *pOut)
{
static Vector vLast[65];
static bool bShotLastTime[65];
static bool bJitterFix[65];
float *flPitch = (float*)((DWORD)pOut - 4);
float flYaw = pData->m_Value.m_Float;
bool bHasAA;
bool bSpinbot;
static bool last[128];
bool tmp = last[((IClientEntity*)(pStruct))->GetIndex()];
float yaw = pData->m_Value.m_Float;
yaw -= 0.087929;
switch (Menu::Window.RageBotTab.AccuracyResolver.GetIndex() == 5)
{
case 0:
// No resolver needed
break;
case 1:
// Normal Fix
yaw -= 0.087929;
last[((IClientEntity*)(pStruct))->GetIndex()] = (yaw >= 180 && yaw <= 360);
if (tmp && (yaw >= 0 && yaw <= 180))
yaw += 359;
yaw -= (int)(yaw / 360) * 360;
if (yaw < -180)
yaw += 360;
else if (yaw > 180)
yaw -= 360;
break;
case 2:
// Anglefix
bHasAA = ((*flPitch == 90.0f) || (*flPitch == 270.0f));
bSpinbot = false;
if (!bShotLastTime[((IClientEntity*)(pStruct))->GetIndex()]
&& (fabsf(flYaw - vLast[((IClientEntity*)(pStruct))->GetIndex()].y) > 15.0f) && !bHasAA)
{
flYaw = vLast[((IClientEntity*)(pStruct))->GetIndex()].y;
bShotLastTime[((IClientEntity*)(pStruct))->GetIndex()] = true;
}
else
{
if (bShotLastTime[((IClientEntity*)(pStruct))->GetIndex()]
&& (fabsf(flYaw - vLast[((IClientEntity*)(pStruct))->GetIndex()].y) > 15.0f))
{
bShotLastTime[((IClientEntity*)(pStruct))->GetIndex()] = true;
bSpinbot = true;
}
else
{
bShotLastTime[((IClientEntity*)(pStruct))->GetIndex()] = false;
}
}
vLast[((IClientEntity*)(pStruct))->GetIndex()].y = flYaw;
bool bTmp = bJitterFix[((IClientEntity*)(pStruct))->GetIndex()];
bJitterFix[((IClientEntity*)(pStruct))->GetIndex()] = (flYaw >= 180.0f && flYaw <= 360.0f);
if (bTmp && (flYaw >= 0.0f && flYaw <= 180.0f))
{
flYaw += 359.0f;
}
break;
}
*(float*)(pOut) = flYaw;
}
// Simple fix for some Fake-Downs
void FixX(const CRecvProxyData* pData, void* pStruct, void* pOut) // Clamp other player angles to fix fakedown or lisp
{
float* ang = (float*)pOut;
*ang = pData->m_Value.m_Float;
DWORD hex = *(DWORD*)(&ang);
switch (Menu::Window.RageBotTab.AccuracyResolver.GetIndex() == 5)
{
case 0:
// No resolver needed
break;
case 1:
// Regular Pitch Resolver
if (hex >= 0x43330000)
{
*ang -= 360.f;
}
else if (hex <= -0x43330000)
{
*ang += 360.f;
}
if (hex == 0x42b40000)
{
*ang = 90.f;
}
else if (hex == -0x42b40000)
{
*ang = -90.f;
}
*(float*)(pOut) = *ang;
break;
case 2:
if (pData->m_Value.m_Float > 180.0f)
*ang -= 360.0f;
else if (pData->m_Value.m_Float < -180.0f)
*ang += 360.0f;
break;
}
}
RecvVarProxyFn oRecvnModelIndex;
void Hooked_RecvProxy_Viewmodel(CRecvProxyData *pData, void *pStruct, void *pOut)
{
// Get the knife view model id's
static int default_t = Interfaces::ModelInfo->GetModelIndex("models/weapons/v_knife_default_t.mdl");
static int default_ct = Interfaces::ModelInfo->GetModelIndex("models/weapons/v_knife_default_ct.mdl");
static int bayonet = Interfaces::ModelInfo->GetModelIndex("models/weapons/v_knife_bayonet.mdl");
static int karam = Interfaces::ModelInfo->GetModelIndex("models/weapons/v_knife_karam.mdl");
// Get local player (just to stop replacing spectators knifes)
IClientEntity* pLocal = Interfaces::EntList->GetClientEntity(Interfaces::Engine->GetLocalPlayer());
if (Menu::Window.MiscTab.KnifeEnable.GetState() && pLocal)
{
// If we are alive and holding a default knife(if we already have a knife don't worry about changing)
if (pLocal->IsAlive() && (pData->m_Value.m_Int == default_t || pData->m_Value.m_Int == default_ct))
{
// Set whatever knife we want
if (Menu::Window.MiscTab.KnifeModel.GetIndex() == 0)
pData->m_Value.m_Int = karam;
else if (Menu::Window.MiscTab.KnifeModel.GetIndex() == 1)
pData->m_Value.m_Int = bayonet;
}
}
// Carry on the to original proxy
oRecvnModelIndex(pData, pStruct, pOut);
}
void ApplyAAAHooks()
{
ClientClass *pClass = Interfaces::Client->GetAllClasses();
while (pClass)
{
const char *pszName = pClass->m_pRecvTable->m_pNetTableName;
if (!strcmp(pszName, "DT_CSPlayer"))
{
for (int i = 0; i < pClass->m_pRecvTable->m_nProps; i++)
{
RecvProp *pProp = &(pClass->m_pRecvTable->m_pProps[i]);
const char *name = pProp->m_pVarName;
// Pitch Fix
if (!strcmp(name, "m_angEyeAngles[0]"))
{
pProp->m_ProxyFn = FixX;
}
// Yaw Fix
if (!strcmp(name, "m_angEyeAngles[1]"))
{
Utilities::Log("Yaw Fix Applied");
pProp->m_ProxyFn = FixY;
}
}
}
else if (!strcmp(pszName, "DT_BaseViewModel"))
{
for (int i = 0; i < pClass->m_pRecvTable->m_nProps; i++)
{
RecvProp *pProp = &(pClass->m_pRecvTable->m_pProps[i]);
const char *name = pProp->m_pVarName;
// Knives
if (!strcmp(name, "m_nModelIndex"))
{
oRecvnModelIndex = (RecvVarProxyFn)pProp->m_ProxyFn;
pProp->m_ProxyFn = Hooked_RecvProxy_Viewmodel;
}
}
}
pClass = pClass->m_pNext;
}
}