Skip to content

Commit 8005842

Browse files
v3.3.10
1 parent 37e1778 commit 8005842

File tree

1 file changed

+16
-53
lines changed

1 file changed

+16
-53
lines changed

Swing_Prediction.lua

+16-53
Original file line numberDiff line numberDiff line change
@@ -28,18 +28,11 @@ local mAutoRefill = menu:AddComponent(MenuLib.Checkbox("Crit Refill", true))
2828
local debug = menu:AddComponent(MenuLib.Checkbox("Visuals", false))
2929
local mAutoGarden = menu:AddComponent(MenuLib.Checkbox("Troldier assist", false))
3030
local mKillaura = menu:AddComponent(MenuLib.Checkbox("Killaura (soon)", false))
31-
local mtime = menu:AddComponent(MenuLib.Slider("attack distance", 150 ,300 , 250 ))
32-
33-
local solution = {
34-
"default",
35-
"strafe pred"
36-
}
37-
38-
local msolution = menu:AddComponent(MenuLib.Combo("Prediction Solution", solution))
31+
local mtime = menu:AddComponent(MenuLib.Slider("attack distance", 150 ,330 , 300 ))
3932
--solution:GetSelectedIndex() -- Selected item index (number)
4033

4134
--amples = menu:AddComponent(MenuLib.Slider("movement ahead", 1 ,25 , 200 ))
42-
local msamples = 66
35+
local msamples = 66
4336
local pastPredictions = {}
4437
local hitbox_min = Vector3(14, 14, 0)
4538
local hitbox_max = Vector3(-14, -14, 85)
@@ -91,28 +84,11 @@ function GetClosestEnemy(pLocal, pLocalOrigin)
9184
end
9285
end
9386

94-
local lastVectors = {}
95-
96-
function interpolateVectors(current, last, t)
97-
local totalIterations = 8
98-
local iterations = t % totalIterations
99-
local percent = iterations / totalIterations
100-
101-
-- Check if a last vector exists for this current vector, otherwise set it to the current vector
102-
if lastVectors[current] == nil then
103-
lastVectors[current] = current
104-
end
105-
106-
local interpolated = lastVectors[current] + (last - lastVectors[current]) * percent
10787

108-
lastVectors[current] = interpolated
109-
110-
return interpolated
111-
end
11288

11389

11490

115-
function TargetPositionPrediction(targetLastPos, targetOriginLast, tickRate, time, tick)
91+
--[[function TargetPositionPrediction(targetLastPos, targetOriginLast, tickRate, time, tick)
11692
-- If the origin of the target from the previous tick is nil, initialize it to a zero vector.
11793
if targetOriginLast == nil then
11894
targetOriginLast = Vector3(0, 0, 0)
@@ -138,7 +114,7 @@ function TargetPositionPrediction(targetLastPos, targetOriginLast, tickRate, tim
138114
local targetVelocity = targetLastPos - targetOriginLast
139115
table.insert(targetVelocitySamples[targetKey], 1, targetVelocity)
140116
141-
local samples = msamples:GetValue()
117+
local samples = msamples
142118
-- Remove the oldest sample if there are more than maxSamples.
143119
if #targetVelocitySamples[targetKey] > samples then
144120
table.remove(targetVelocitySamples[targetKey], samples + 1)
@@ -177,7 +153,7 @@ function TargetPositionPrediction(targetLastPos, targetOriginLast, tickRate, tim
177153
targetFutureLast = targetFuture
178154
-- Return the predicted future position.
179155
return targetFuture
180-
end
156+
end]]
181157

182158

183159
local vhitbox_Height = 85
@@ -229,19 +205,17 @@ end
229205

230206
--[[ Code needed to run 66 times a second ]]--
231207
local function OnCreateMove(pCmd)
232-
if not Swingpred:GetValue() then goto continue end -- enable or distable script
233-
234-
-- Use pLocal, pWeapon, pWeaponDefIndex, etc. as needed
235-
if not pLocal then goto continue end -- Immediately check if the local player exists. If it doesn't, return.
236-
local pLocalClass = pLocal:GetPropInt("m_iClass") --getlocalclass
237-
if pLocalClass == nil then goto continue end
238-
if pLocalClass == 8 then goto continue end
239-
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
240-
local swingrange = pWeapon:GetSwingRange() -- + 11.17
241-
local flags = pLocal:GetPropInt( "m_fFlags" )
242-
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
243-
local time = mtime:GetValue() * 0.001
244-
208+
if not Swingpred:GetValue() then goto continue end -- enable or distable script
209+
if not pLocal then goto continue end -- Immediately check if the local player exists. If it doesn't, return.
210+
211+
local pLocalClass = pLocal:GetPropInt("m_iClass") --getlocalclass
212+
if pLocalClass == nil then goto continue end --when local player did not chose class then skip code
213+
if pLocalClass == 8 then goto continue end --when local player is spy then skip code
214+
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
215+
local swingrange = pWeapon:GetSwingRange() -- + 11.17
216+
local flags = pLocal:GetPropInt( "m_fFlags" )
217+
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
218+
local time = mtime:GetValue() * 0.001
245219

246220
if mAutoGarden:GetValue() == true then
247221
local bhopping = false
@@ -283,19 +257,8 @@ if closestPlayer == nil then goto continue end
283257
local Killaura = mKillaura:GetValue()
284258

285259
--[[position prediction]]--
286-
287-
288-
if msolution:IsSelected("default") then
289260
vPlayerFuture = (vPlayerOrigin + closestPlayer:EstimateAbsVelocity() * time)--TargetPositionPrediction(vPlayerOrigin, vPlayerOriginLast, tickRate, time, tick)
290261
pLocalFuture = (pLocalOrigin + pLocal:EstimateAbsVelocity() * time) --TargetPositionPrediction(pLocalOrigin, pLocalOriginLast, tickRate, time, tick)
291-
else
292-
if tick % 8 == 0 or tick == nil then
293-
tick = 0
294-
end
295-
tick = tick + 1
296-
vPlayerFuture = TargetPositionPrediction(vPlayerOrigin, vPlayerOriginLast, tickRate, time, tick)
297-
pLocalFuture = TargetPositionPrediction(pLocalOrigin, pLocalOriginLast, tickRate, time, tick)
298-
end
299262

300263

301264
--[[-----------------------------Swing Prediction------------------------------------------------------------------------]]

0 commit comments

Comments
 (0)