-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathnospread.cpp
More file actions
198 lines (148 loc) · 4.2 KB
/
nospread.cpp
File metadata and controls
198 lines (148 loc) · 4.2 KB
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
#include "nospread.h"
Vector
nospread::hl2ws = Vector(),
nospread::recoil = Vector();
extern IEntities* ents;
extern IEngine* engine;
extern IMovement* movement;
extern GlobalVars* globals;
typedef float (__thiscall* GetSpreadFn)(void*);
JMP* jmpFireBullets = 0;
extern IPrediction* pd;
bool prefire = 0;
void __fastcall hooked_FireBullets(CBaseEntity* ecx, void*, char* fb)
{
if (ecx == LocalPlayer() && prefire)
{
nospread::hl2ws =
*(Vector*)(fb + 0x1C);
return;
}
jmpFireBullets->SetOrigin(ecx);
jmpFireBullets->Call(1, fb);
}
void nospread::ApplyBulletSpread(CUserCmd* cmd, CBaseEntity* w, Vector &ref, float m)
{
static void (*RandomSeed)(unsigned) = (void (__cdecl*)(unsigned))IMPORT("vstdlib", "RandomSeed");
static float (*RandomFloat)(float, float) = (float (__cdecl*)(float, float))IMPORT("vstdlib", "RandomFloat");
cmd->random_seed = MD5_PseudoRandom(cmd->command_number) & 255;
if (css()) // || csgo())
{
#define o_spread 371
void (__thiscall* UpdateAccuracyPenalty)(void*) = GetVFunc<void (__thiscall*)(void*)>(w, o_spread + 2);
GetSpreadFn GetWeaponSpread = GetVFunc<GetSpreadFn>(w, o_spread);
GetSpreadFn GetWeaponCone = GetVFunc<GetSpreadFn>(w, o_spread + 1);
Vector forward, right, up;
RandomSeed(cmd->random_seed + 1);
UpdateAccuracyPenalty(w);
float rand0 = RandomFloat(0.f, M_PI * 2.f);
float rand1 = RandomFloat(0.f, GetWeaponSpread(w));
float rand2 = RandomFloat(0.f, M_PI * 2.f);
float rand3 = RandomFloat(0.f, GetWeaponCone(w));
Vector shake = Vector((cosf(rand0) * rand1) + (cosf(rand2) * rand3), (sinf(rand0) * rand1) + (sinf(rand2) * rand3), 0.f);
NormalizeAngles(cmd->viewangles);
AngleVectors(cmd->viewangles, &forward, &right, &up);
Vector new_va = forward + (right * shake.x * m) + (up * shake.y * m);
new_va.NormalizeInPlace();
VectorAngles(new_va, ref);
NormalizeAngles(ref);
}
else
{
// hl2dm: 267
Vector shake = Vector();
if (gmod())
{
shake = hl2ws;
}
else
if (tf2())
{
if ((globals->cur_time - ReadPtr<float>(w, m_flLastFireTime)) > 2.0f)
shake.Zero();
else
{
GetSpreadFn GetBulletSpread = GetVFunc<GetSpreadFn>(w, 445);
float f = GetBulletSpread(w);
shake.x = f;
shake.y = f;
}
}
else
if (dod())
{
float (__thiscall* GetBulletSpread)(void*, float) = GetVFunc<float (__thiscall*)(void*, float)>(w, 368);
float f = GetBulletSpread(w, LocalPlayer()->GetVelocity().Length2D());
shake.x = f;
shake.y = f;
}
if (cmd->random_seed == 39)
cmd->random_seed += 2;
RandomSeed(cmd->random_seed);
float x = RandomFloat(-0.5f, 0.5f) + RandomFloat(-0.5f, 0.5f);
float y = RandomFloat(-0.5f, 0.5f) + RandomFloat(-0.5f, 0.5f);
Vector forward, right, up;
NormalizeAngles(cmd->viewangles);
AngleVectors(cmd->viewangles, &forward, &right, &up);
Vector new_va = forward + (right * shake.x * x * m) + (up * shake.y * y * m);
new_va.NormalizeInPlace();
VectorAngles(new_va, ref);
NormalizeAngles(ref);
}
}
void nospread::HandleCmd(CUserCmd* cmd, CBaseEntity* w)
{
CBaseEntity* lp = LocalPlayer();
if (tf2())
{
static unsigned fakeseed = 0, oldindex = 0;
if (oldindex != lp->EntIndex())
{
oldindex = lp->EntIndex();
fakeseed = cmd->command_number;
}
if (w && !strcmp(w->GetClientClass()->m_pNetworkName, "CTFMinigun") && chk(cmd->buttons, IN_ATTACK))
{
static char rseed = MD5_PseudoRandom(188) & 255;
if (MENU_SMACSEED)
{
// todo: code
fakeseed++;
}
else for (++fakeseed; (MD5_PseudoRandom(fakeseed) & 255) != rseed; ++fakeseed);
}
else
fakeseed++;
cmd->command_number = fakeseed;
}
if (aimbot::dummy)
return;
if (MENU_NOSPREAD && chk(cmd->buttons, IN_ATTACK))
{
if (aimbot::bullet && gmod())
{
static CBaseEntity* lw = 0;
if (lw != w)
{
lw = w;
hl2ws.Zero();
}
prefire = 1;
pd->RunCommand(LocalPlayer(), cmd, 0); // find better way to do so
}
ApplyBulletSpread(cmd, w, cmd->viewangles, -1.0f);
if (prefire)
prefire = 0;
}
}
void nospread::FixRecoil(CUserCmd* cmd)
{
Vector p = recoil;
float normal = p.Normalize();
normal = max(normal - (10.f + normal * 0.5f) * globals->interval_per_tick, 0.f);
p *= normal;
p.z = 0.f;
if (css())
p *= 2.f;
cmd->viewangles -= p;
}