Skip to content

Commit 3a97b87

Browse files
v5.1
1 parent c4daff6 commit 3a97b87

File tree

1 file changed

+35
-39
lines changed

1 file changed

+35
-39
lines changed

Swing_Prediction.lua

+35-39
Original file line numberDiff line numberDiff line change
@@ -52,37 +52,31 @@ local Visuals = {
5252
}
5353

5454
local mVisuals = menu:AddComponent(MenuLib.MultiCombo("^Visuals", Visuals, ItemFlags.FullWidth))
55-
56-
if GetViewHeight ~= nil then
57-
local mTHeightt = GetViewHeight()
58-
end
59-
local vPlayerOriginLast
60-
local pLocalOriginLast
55+
local closestDistance = 2000
56+
local fDistance
57+
local hitbox_max = Vector3(-14, -14, 85)
58+
local hitbox_min = Vector3(14, 14, 0)
59+
local isMelee = false
60+
local mresolution = 128
6161
local mTHeightt = 85
6262
local msamples = 66
6363
local pastPredictions = {}
64-
local hitbox_min = Vector3(14, 14, 0)
65-
local hitbox_max = Vector3(-14, -14, 85)
66-
local vPlayerOrigin = nil
67-
local pLocal = entities.GetLocalPlayer() -- Immediately set "pLocal" to the local player (entities.GetLocalPlayer)
68-
local tickRate = 66 -- game tick rate
69-
local pLocalOrigin
70-
local closestDistance = 2000
71-
local tick
64+
local pLocal = entities.GetLocalPlayer()
7265
local pLocalClass
66+
local pLocalFuture
67+
local pLocalOrigin
68+
local ping = 0
69+
local Safe_Strafe = false
7370
local swingrange
74-
local mresolution = 128
75-
local viewheight
71+
local tick
72+
local tickRate = 66
7673
local tick_count = 0
77-
local isMelee = false
74+
local viewheight
7875
local vdistance
79-
local fDistance
8076
local vPlayerFuture
81-
local pLocalFuture
82-
local ping = 0
83-
local Safe_Strafe = false
84-
local latency = 0
85-
local lerp = 0
77+
local vPlayerOrigin
78+
local vPlayerOriginLast
79+
8680
local pivot
8781
local can_charge = false
8882
local settings = {
@@ -260,10 +254,23 @@ local function OnCreateMove(pCmd)
260254
if pLocalClass == nil then goto continue end --when local player did not chose class then skip code
261255
if pLocalClass == 8 then goto continue end --when local player is spy then skip code
262256

257+
-- Get current latency and lerp
258+
local time = 16
259+
local latIn, latOut = clientstate.GetLatencyIn(), clientstate.GetLatencyOut()
260+
local lerp = client.GetConVar("cl_interp") or 0
261+
local Tolerance = 2
262+
--print(lerp)
263+
-- Define the reaction time in seconds
264+
local Latency = (latOut + lerp )
265+
-- Convert the delay to ticks
266+
Latency = math.floor( Latency * tickRate )
267+
268+
-- Add the ticks to the current time
269+
time = time + Latency - Tolerance
270+
263271
--[--obtain secondary information after confirming we need it for fps boost whe nnot using script]
264272
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
265273
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
266-
local time = 16
267274
local closestPlayer
268275
if #players == 0 then return end -- Immediately check if there are any players in the game. If there aren't, return.
269276
--[--if we enabled trodlier assist run auto weapon script]
@@ -329,18 +336,6 @@ end
329336

330337
--[--------------Prediction-------------------] -- predict both players position after swing
331338

332-
-- Get current latency
333-
local latIn, latOut = clientstate.GetLatencyIn(), clientstate.GetLatencyOut()
334-
if latIn and latOut then
335-
latency = latIn + latOut
336-
else
337-
latency = 0
338-
end
339-
-- Get current lerp
340-
lerp = client.GetConVar("cl_interp") or 0
341-
342-
time = math.floor(time + latency + lerp)
343-
344339
if pLocal:EstimateAbsVelocity() == 0 then
345340
-- If the local player is not accelerating, set the predicted position to the current position
346341
pLocalFuture = pLocalOrigin
@@ -390,8 +385,8 @@ if not Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFu
390385
end
391386

392387
if Achargebot:GetValue() and chargeLeft >= 100.0 then
393-
collision, collisionPoint = checkCollision(vPlayerFuture, pLocalFuture, (swingrange * 1.5)) --increased range when in charge
394-
if collision then
388+
collision, collisionPoint = checkCollision(vPlayerFuture, pLocalOrigin, (swingrange * 1.5)) --increased range when in charge
389+
if collision then
395390
can_attack = true
396391
tick_count = tick_count + 1
397392
if tick_count % 6 == 0 then
@@ -427,7 +422,7 @@ if not Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFu
427422
aimpos = Math.PositionAngles(pLocalOrigin, aimpos)
428423
pCmd:SetViewAngles(aimpos:Unpack()) --engine.SetViewAngles(aimpos) --set angle at aim position manualy not silent aimbot
429424

430-
elseif Mchargebot:GetValue() and pLocal:InCond(17) then
425+
elseif Mchargebot:GetValue() and pLocal:InCond(17) and not Maimbot:GetValue() then
431426

432427
-- Calculate the source and destination vectors
433428
-- Get the current view angles
@@ -468,6 +463,7 @@ end
468463
end
469464

470465
if can_charge then
466+
pCmd:SetButtons(pCmd:GetButtons() | IN_JUMP)
471467
pCmd:SetButtons(pCmd:GetButtons() | IN_ATTACK2)-- charge
472468
end
473469

0 commit comments

Comments
 (0)