-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstolen_aim.lua
More file actions
328 lines (285 loc) · 9.79 KB
/
stolen_aim.lua
File metadata and controls
328 lines (285 loc) · 9.79 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
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
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/*
cunt [STEAM_0:0:40143824 | 63.141.253.124:27005]
hake/aimbot.lua (10932 bytes)
*/
/*
====================
Name: aimbot.lua
Purpose: Aimbot?
====================
*/
--[ ConVars ]--
CreateConVar( "aim_auto", 1 )
CreateConVar( "aim_friendly", 1 )
CreateConVar( "aim_ignoreadmins", 0 )
CreateConVar( "aim_ignorefriends", 1 )
CreateConVar( "aim_ignoretraitors", 0 )
CreateConVar( "aim_ignoreinnocents", 0 )
CreateConVar( "aim_prediction", 1 )
CreateConVar( "aim_spawnprotection", 1 )
CreateConVar( "aim_obbcenter", 0 )
CreateConVar( "aim_fov", 360 )
CreateConVar( "aim_offset", 0 )
CreateConVar( "aim_anti", 0 )
CreateConVar( "aim_nospread", 1 )
CreateConVar( "aim_holdtarget", 0 )
CreateConVar( "aim_noshake", 1 )
CreateConVar( "aim_ignorebots", 1 )
require( "nyx" )
_nyx.Init()
function SetViewAngles( cmd, ang )
return R.CUserCmd.SetViewAngles( cmd, ang )
end
function GetWeaponVector( value, typ )
local s = ( -value )
if ( typ == true ) then
s = ( -value )
elseif ( typ == false ) then
s = ( value )
else
s = ( value )
end
return Vector( s, s, s )
end
function GetCone( wep )
if !IsValid( wep ) then return 0 end
if HL2Cones[ wep:GetClass() ] then return HL2Cones[ wep:GetClass() ] end
if NormalCones[ wep.Base ] then return wep.Cone or wep.Primary.Cone or 0 end
if CustomCones[ wep.Base ] then return CustomCones[ wep.Base ]( wep ) end
local Cone = wep.Cone
if !Cone then
Cone = wep.Primary and wep.Primary.Cone or 0
end
return Cone
end
NormalCones = {
[ "weapon_cs_base" ] = true,
[ "weapon_sh_base" ] = true,
[ "weapon_zs_base" ] = true,
}
HL2Cones = {
[ "weapon_pistol" ] = Vector( 0.0100, 0.0100, 0.0100 ),
[ "weapon_smg1" ] = GetWeaponVector( 0.04362, true, true ),
[ "weapon_ar2" ] = Vector( 0.02618, 0.02618, 0.02618 ),
[ "weapon_shotgun" ] = Vector( 0.08716, 0.08716, 0.08716 ),
}
CustomCones = {
[ "weapon_sh_base" ] = function( wep )
local Cone = wep.Primary.Cone
local Recoil = WeaponRecoil[ wep:GetClass() ]
local IsSniper = wep.Sniper and 2 or 1
local Stance = wep.Owner:IsOnGround() and wep.Owner:Crouching() and 10
or !wep.Sprinting and wep.Owner:IsOnGround() and 15
or wep.Walking and wep.Owner:IsOnGround() and 20
or !wep.Owner:IsOnGround() and 25
or wep.Primary.Ammo == "buckshot" and 0
local WepType = wep.Sniper and 8
or wep.SMG and 2
or wep.Pistol and 2
or wep.Primary.Ammo == "buckshot" and 0
or 1.6
local Shotgun = wep.Primary.Ammo == "buckshot" and wep.Primary.Cone or 0
if wep:GetIronsights() then
return Cone
else
return Cone * Recoil * Stance * WepType + Shotgun
end
end,
[ "weapon_zs_base" ] = function( wep )
local Cone = wep.Cone or wep.Primary.Cone or 0
if LocalPlayer():GetVelocity():Length() > 20 then
return wep.ConeMoving
end
if LocalPlayer():Crouching() then
return wep.ConeCrouching
end
return Cone
end,
}
function PredictSpread( cmd, ang )
local w = LocalPlayer():GetActiveWeapon()
local vecCone, valCone = Vector( 0, 0, 0 )
if ( w && w:IsValid() && ( type( w.Initialize ) == "function" ) ) then
valCone = GetCone( w )
if ( type( valCone ) == "number" ) then
vecCone = Vector( -valCone, -valCone, -valCone )
elseif ( type( valCone ) == "Vector" ) then
vecCone = valCone * -1
elseif bit.band( cmd:GetButtons(), IN_SPEED ) or bit.band( cmd:GetButtons(), IN_JUMP ) then
vecCone = valCone + (cone * 2 )
end
else
if ( w:IsValid() ) then
local class = w:GetClass()
if ( CustomCones[ class ] ) then
vecCone = CustomCones[ class ]
elseif ( HL2Cones[ class ] ) then
vecCone = HL2Cones[ class ]
end
end
end
return ( _nyx.RemoveSpread( cmd, ang, vecCone ) ):Angle()
end
FireBulletCone = Vector( 0, 0, 0 )
R.Entity.FireBullets = Detour( R.Entity.FireBullets, function( ent, shot )
FireBulletCone = shot.Spread
return Detours[ R.Entity.FireBullets ]( ent, shot )
end )
function GetTarget()
local target
if target == nil then
target = LocalPlayer()
else
target = target
end
local ply = LocalPlayer()
local angA, angB = 0
local x, y = ScrW(), ScrH()
local distance = math.huge
for k, e in pairs( player.GetAll() ) do
if ( e != LocalPlayer() && e:Alive() && IsVisible( e ) && ValidTarget( e ) && InFov( e ) ) then
local ePos, oldPos, myAngV = e:EyePos():ToScreen(), target:EyePos():ToScreen(), ply:GetAngles()
local thedist = e:GetPos():DistToSqr( LocalPlayer():GetPos() )
angA = math.Dist( x / 2, y / 2, oldPos.x, oldPos.y )
angB = math.Dist( x / 2, y / 2, ePos.x, ePos.y )
if (thedist < distance) then
distance = thedist;
target = e;
end
end
end
return target
end
function GetPos( ent )
local Eyes = ent:LookupAttachment( "eyes" )
local Pos
if ( GetVar( "aim_obbcenter" ) == 1 or ent:EyeAngles().p < -89 ) then -- anti anti aim
Pos = ent:LocalToWorld( ent:OBBCenter() )
elseif Eyes ~= 0 then
Eyes = ent:GetAttachment( Eyes )
if ( Eyes && Eyes.Pos ) then
Pos = Eyes.Pos, Eyes.Ang
end
else
Pos = ent:LookupBone( "ValveBiped.Bip01_Head1" )
end
return Pos
end
function Prediction( pos , pl )
if IsValid( pl ) and type( pl:GetVelocity() ) == "Vector" and pl.GetPos and type( pl:GetPos() ) == "Vector" then
local distance = LocalPlayer():GetPos():Distance( pl:GetPos() )
local weapon = ( LocalPlayer().GetActiveWeapon and ( IsValid( LocalPlayer():GetActiveWeapon() ) and LocalPlayer():GetActiveWeapon():GetClass() ) )
if weapon and Prediction[ weapon ] then
local time = distance / Prediction[ weapon ]
return pos + pl:GetVelocity() * time
end
end
return pos
end
function IsVisible( e )
local trace = util.TraceLine( {
start = LocalPlayer():GetShootPos(),
endpos = GetPos( e ),
filter = { LocalPlayer(), e },
mask = MASK_SHOT + CONTENTS_WINDOW
} )
if (( trace.Fraction >= 0.99 )) then return true end
return false
end
function InFov( e )
if( GetVar( "aim_fov" ) != 360 ) then
local lpang = LocalPlayer():GetAngles()
local ang = ( e:GetPos() - LocalPlayer():EyePos() ):Angle()
local ady = math.abs( math.NormalizeAngle( lpang.y - ang.y ) )
local adp = math.abs( math.NormalizeAngle( lpang.p - ang.p ) )
if( ady > GetVar( "aim_fov" ) || adp > GetVar( "aim_fov" ) ) then return false end
end
return true
end
function ValidTarget( e )
local ply = LocalPlayer()
if ( !IsValid( e ) ) then return false end
if ( !e:IsValid() || ( !e:IsPlayer() && !e:IsNPC() ) || e == ply ) then return false end
if ( e:IsPlayer() && e:InVehicle() ) then return false end
if ( e:IsPlayer() && !e:Alive() || e:IsPlayer() && e:Health() <= 0 ) then return false end
if ( e:IsNPC() ) then return false end
if ( GetVar( "aim_ignorebots" ) == 1 && e:IsBot() ) then return false end
if ( !InFov( e ) ) then return false end
if ( e:GetMoveType() == MOVETYPE_OBSERVER ) then return false end
if string.find( string.lower( team.GetName( e:Team() ) ), "spec" ) then return false end
if ( GetVar( "aim_friendly" ) == 0 && e:Team() == LocalPlayer():Team()) then return false end
if ( GetVar( "aim_ignoreadmins" ) == 1 && IsAdmin( e ) ) then return false end
if ( GetVar( "aim_spawnprotection" ) == 1 && e:GetColor( r, g, b, a ).a < 255 or LocalPlayer():GetColor( r, g, b, a ).a < 255 ) then return false end
if ( GetVar( "aim_ignorefriends" ) == 1 && e:GetFriendStatus() == "friend" ) then return false end
if ( IsTTT() && GetVar( "aim_ignoreinnocents" ) == 1 && !table.HasValue( Traitors, e:Nick() ) ) then return false end
if ( IsTTT() && IsTraitor( e ) && GetVar( "aim_ignoretraitors" ) == 1 ) then return false end
return true
end
function ShouldAim()
if Aimon == 1 then
return true
else
return false
end
end
HasTarget = false
NoSpreadAngle = Angle( 0, 0, 0 )
function Aimbot( ucmd )
NoSpreadAngle = ucmd:GetViewAngles()
Target = GetTarget()
Angles = ucmd:GetViewAngles()
local ply = LocalPlayer()
if ( ShouldAim() && Target != ply && Target != nil ) then
local Aimspot
HasTarget = true
if GetVar( "aim_prediction" ) == 1 then
Aimspot = Prediction( GetPos( Target ) ) - Vector( 0, 0, GetVar( "aim_offset" ) )
Aimspot = Aimspot + Target:GetVelocity() * ( 1 / 66 ) - LocalPlayer():GetVelocity() * ( 1 / 66 )
else
Aimspot = ( GetPos( Target ) ) - Vector( 0, 0, GetVar( "aim_offset" ) )
Aimspot = Aimspot + Target:GetVelocity() / 50 - LocalPlayer():GetVelocity() / 50
end
Angles = ( Aimspot - LocalPlayer():GetShootPos() ):GetNormal():Angle()
if GetVar( "aim_noshake" ) == 1 then
NoSpreadAngle = Angles
else
NoSpreadAngle = ucmd:GetViewAngles()
end
if GetVar( "aim_nospread" ) == 1 then
Spread = PredictSpread( ucmd, Angle( Angles.p, Angles.y, 0 ) )
else
Spread = Angle( Angles.p, Angles.y, 0 )
end
Angles.p = math.NormalizeAngle( Angles.p )
Angles.y = math.NormalizeAngle( Angles.y )
if GetVar( "aim_anti" ) == 1 then
ucmd:SetViewAngles( Angle( -Spread.p + 900, Spread.y + 180, 0 ) )
else
SetViewAngles( ucmd, Spread )
end
if GetVar( "aim_auto" ) == 1 then
ucmd:SetButtons( bit.bor( ucmd:GetButtons(), IN_ATTACK ) )
end
else
HasTarget = false
end
end
GAMEMODE = table.Copy( GAMEMODE )
function GAMEMODE:CalcView( ply, origin, angles, fov )
local view = GAMEMODE.CalcView( self, ply, origin, angles, fov ) || {}
view.angles = NoSpreadAngle
return view
end
-- Static anti-aim, go fuck yourself
function AntiAim( cmd, u )
ViewAngles = cmd:GetViewAngles()
if ( GetVar( "aim_anti" ) == 1 && !LocalPlayer():KeyDown( IN_ATTACK ) && Target == nil ) then
cmd:SetViewAngles( Angle( -181, cmd:GetViewAngles().y, 0 ) )
end
end
--[ Commands ]--
AddCommand( "+hake", function() Aimon = 1 end )
AddCommand( "-hake", function() Aimon = 0 end )
--[ Hooks ]--
AddHook( "CreateMove", AntiAim )
AddHook( "CreateMove", Aimbot )