Skip to content

Commit c5f85c5

Browse files
Add files via upload
1 parent 0e229c7 commit c5f85c5

File tree

1 file changed

+59
-47
lines changed

1 file changed

+59
-47
lines changed

A_Swing_Prediction.lua

+59-47
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ local function GetPressedkey()
4141
end
4242
end
4343
return pressedKey
44-
end
44+
end
4545

4646
--[[menu:AddComponent(MenuLib.Button("Debug", function() -- Disable Weapon Sway (Executes commands)
4747
client.SetConVar("cl_vWeapon_sway_interp", 0) -- Set cl_vWeapon_sway_interp to 0
@@ -200,21 +200,13 @@ else
200200
CreateCFG(string.format([[Lua %s]], Lua__fileName), Menu) -- Save the config
201201
end
202202

203-
local closestDistance = 2000
204-
local fDistance = 1
205-
local hitbox_Height = 82
206-
local hitbox_Width = 24
207203
local isMelee = false
208-
local mresolution = 64
209204
local pLocal = entities.GetLocalPlayer()
210205
local players = entities.FindByClass("CTFPlayer")
211-
local ping = 0
212206
local swingrange = 48
213-
local tickRate = 66
214207
local tick_count = 0
215-
local time = 13
208+
local time = 13 -- ~0.2s
216209
local can_attack = false
217-
local Safe_Strafe = false
218210
local can_charge = false
219211
local Charge_Range = 128
220212
local swingRangeMultiplier = 1
@@ -270,7 +262,6 @@ local inaccuracy = {} ---@type table<number, number>
270262
local pastPositions = {} -- Stores past positions of the local player
271263
local maxPositions = 4 -- Number of past positions to consider
272264

273-
274265
local function CalcStrafe()
275266
local autostrafe = gui.GetValue("Auto Strafe")
276267
local flags = entities.GetLocalPlayer():GetPropInt("m_fFlags")
@@ -294,8 +285,7 @@ local function CalcStrafe()
294285
if #pastPositions > maxPositions then
295286
table.remove(pastPositions)
296287
end
297-
298-
288+
299289
if not onGround and autostrafe == 2 and #pastPositions >= maxPositions then
300290
v = Vector3(0, 0, 0)
301291
for i = 1, #pastPositions - 1 do
@@ -555,30 +545,54 @@ local function checkInRange(targetPos, spherePos, sphereRadius, pWeapon)
555545
attackReady = true
556546
attackData = {
557547
pWeapon = pWeapon,
558-
spherePos = spherePos,
548+
spherePos = spherePos - Vector3(0, 0, 75),
559549
closestPoint = closestPoint,
560550
originalPosition = pLocal:GetPropVector("tfnonlocaldata", "m_vecOrigin"),
561551
originalAngles = pLocal:GetPropVector("tfnonlocaldata", "m_angEyeAngles[0]")
562552
}
563553
return isAttackSuccessful, closestPoint
564554
else
555+
-- Reset the flags and clear data
556+
attackData = {}
557+
attackReady = false
565558
-- Target is not in range
566559
return false, nil
567560
end
568561
end
569562

570-
local counter = 0
563+
local function normalizeAngle(offsetNumber)
564+
offsetNumber = offsetNumber % 360
565+
if offsetNumber > 180 then
566+
offsetNumber = offsetNumber - 360
567+
elseif offsetNumber < -180 then
568+
offsetNumber = offsetNumber + 360
569+
end
570+
return offsetNumber
571+
end
571572

572573
-- PostPropUpdate function to adjust player position and angle
573574
local function PropUpdate()
574-
counter = counter + 1
575-
if counter % 2 == 0 and attackReady and Menu.Misc.advancedHitreg then
575+
if attackReady and Menu.Misc.advancedHitreg then
576+
if not attackData or not attackData.spherePos or not attackData.closestPoint or not attackData.pWeapon then return end
577+
576578
local angle = Math.PositionAngles(attackData.spherePos, attackData.closestPoint)
579+
attackData.originalPosition = pLocal:GetPropVector("tfnonlocaldata", "m_vecOrigin")
580+
attackData.originalAngles = pLocal:GetPropVector("tfnonlocaldata", "m_angEyeAngles[0]")
581+
577582

583+
gui.SetValue("Anti Aim", 1)
584+
gui.SetValue("Anti Aim - Pitch", 7)
585+
gui.SetValue("Anti Aim - Custom Pitch (Real)", math.floor(angle.pitch))
586+
587+
local localview = engine.GetViewAngles()
588+
-- Calculate the real yaw based on target angle and local yaw
589+
local realYaw = math.floor(normalizeAngle((angle.yaw - localview.yaw)))
590+
gui.SetValue("Anti Aim - Yaw", 8)
591+
gui.SetValue("Anti Aim - Yaw (Fake)", 7)
592+
gui.SetValue("Anti Aim - Custom Yaw (Real)", realYaw)
578593
-- Adjust player position and view angles for swing trace
579594
pLocal:SetPropVector(attackData.spherePos, "tfnonlocaldata", "m_vecOrigin")
580595
pLocal:SetPropVector(Vector3(angle.x, angle.y, angle.z), "tfnonlocaldata", "m_angEyeAngles[0]")
581-
582596
-- Perform the swing trace
583597
local swingTraceResult = pLocal.DoSwingTrace(attackData.pWeapon)
584598

@@ -593,10 +607,6 @@ local function PropUpdate()
593607
-- Reset the player's original position and view angles
594608
pLocal:SetPropVector(attackData.originalPosition, "tfnonlocaldata", "m_vecOrigin")
595609
pLocal:SetPropVector(attackData.originalAngles, "tfnonlocaldata", "m_angEyeAngles[0]")
596-
597-
-- Reset the flags and clear data
598-
attackReady = false
599-
attackData = {}
600610
end
601611
end
602612

@@ -1042,6 +1052,7 @@ end
10421052
strafeAngle = strafeAngles[CurrentTarget:GetIndex()] or 0
10431053

10441054
local predData = PredictPlayer(player, time, strafeAngle)
1055+
if not predData then return end
10451056

10461057
vPlayerPath = predData.pos
10471058
vPlayerFuture = predData.pos[time]
@@ -1073,33 +1084,35 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
10731084

10741085
-- Inside your game loop
10751086
if Menu.Aimbot.Aimbot then
1076-
if InRangePoint then
1077-
aimpos = InRangePoint
1078-
aimposVis = aimpos -- transfer aim point to visuals
1087+
local aim_angles
1088+
if InRangePoint then
1089+
aimpos = InRangePoint
1090+
aimposVis = aimpos -- transfer aim point to visuals
1091+
1092+
-- Calculate aim position only once
1093+
aimpos = Math.PositionAngles(pLocalOrigin, aimpos)
1094+
aim_angles = aimpos
1095+
end
10791096

1080-
-- Calculate aim position only once
1081-
aimpos = Math.PositionAngles(pLocalOrigin, aimpos)
1097+
if pLocal:InCond(17) and Menu.Aimbot.ChargeBot and not can_attack then
1098+
local trace = engine.TraceHull(pLocalOrigin, UpdateHomingMissile(), vHitbox[1], vHitbox[2], MASK_PLAYERSOLID_BRUSHONLY)
1099+
if trace.fraction == 1 or trace.entity == CurrentTarget then
1100+
-- If the trace hit something, set the view angles to the position of the hit
1101+
aim_angles = Math.PositionAngles(pLocalOrigin, UpdateHomingMissile())
1102+
-- Set view angles based on the future position of the local player
1103+
engine.SetViewAngles(EulerAngles(engine.GetViewAngles().pitch, aim_angles.yaw, 0))
10821104
end
1083-
1084-
if pLocal:InCond(17) and Menu.Aimbot.ChargeBot and not can_attack then
1085-
local trace = engine.TraceHull(pLocalOrigin, UpdateHomingMissile(), vHitbox[1], vHitbox[2], MASK_PLAYERSOLID_BRUSHONLY)
1086-
if trace.fraction == 1 or trace.entity == CurrentTarget then
1087-
-- If the trace hit something, set the view angles to the position of the hit
1088-
local aim_angles = Math.PositionAngles(pLocalOrigin, UpdateHomingMissile())
1089-
-- Set view angles based on the future position of the local player
1090-
engine.SetViewAngles(EulerAngles(engine.GetViewAngles().pitch, aim_angles.yaw, 0))
1091-
end
1092-
elseif can_attack and aimpos then
1093-
-- Set view angles based on whether silent aim is enabled
1094-
if Menu.Aimbot.Silent then
1095-
pCmd:SetViewAngles(aimpos.pitch, aimpos.yaw, 0)
1096-
else
1097-
engine.SetViewAngles(EulerAngles(aimpos.pitch, aimpos.yaw, 0))
1098-
end
1099-
elseif pLocalClass == 4 then
1100-
-- Control charge if charge bot is enabled and the local player is in condition 17
1101-
ChargeControl(pCmd)
1105+
elseif can_attack and aim_angles and aim_angles.pitch and aim_angles.yaw then
1106+
-- Set view angles based on whether silent aim is enabled
1107+
if Menu.Aimbot.Silent then
1108+
pCmd:SetViewAngles(aim_angles.pitch, aim_angles.yaw, 0)
1109+
else
1110+
engine.SetViewAngles(EulerAngles(aim_angles.pitch, aim_angles.yaw, 0))
11021111
end
1112+
elseif pLocalClass == 4 then
1113+
-- Control charge if charge bot is enabled and the local player is in condition 17
1114+
ChargeControl(pCmd)
1115+
end
11031116

11041117
elseif Menu.Misc.ChargeControl and pLocal:InCond(17) then
11051118
-- Control charge if charge bot is enabled and the local player is in condition 17
@@ -1123,7 +1136,6 @@ vdistance = (vPlayerOrigin - pLocalOrigin):Length()
11231136
end
11241137

11251138
-- Update last variables
1126-
Safe_Strafe = false -- reset safe strafe
11271139
vHitbox[2].z = 82
11281140
::continue::
11291141
end

0 commit comments

Comments
 (0)