Skip to content

Commit a4c609e

Browse files
v4.4.0
1 parent 5979ff7 commit a4c609e

File tree

1 file changed

+75
-64
lines changed

1 file changed

+75
-64
lines changed

Swing_Prediction.lua

Lines changed: 75 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ menu.Style.Outline = true -- Outline around the menu
3737
end, ItemFlags.FullWidth))]]
3838
local Swingpred = menu:AddComponent(MenuLib.Checkbox("Enable", true, ItemFlags.FullWidth))
3939
local Maimbot = menu:AddComponent(MenuLib.Checkbox("Aimbot(Rage)", true, ItemFlags.FullWidth))
40-
local mtime = menu:AddComponent(MenuLib.Slider("attack delay(ticks)",3 ,20 ,14 ))
40+
local mFov = menu:AddComponent(MenuLib.Slider("Aimbot FOV",10 ,360 ,180 ))
41+
local mtime = menu:AddComponent(MenuLib.Slider("prediction(ticks)",3 ,20 ,14 ))
4142
local mAutoRefill = menu:AddComponent(MenuLib.Checkbox("Crit Refill", true))
4243
local mAutoGarden = menu:AddComponent(MenuLib.Checkbox("Troldier assist", false))
4344
local mmVisuals = menu:AddComponent(MenuLib.Checkbox("Enable Visuals", false))
@@ -61,7 +62,6 @@ local vPlayerOrigin = nil
6162
local pLocal = entities.GetLocalPlayer() -- Immediately set "pLocal" to the local player (entities.GetLocalPlayer)
6263
local tickRate = 66 -- game tick rate
6364
local pLocalOrigin
64-
local closestPlayer
6565
local closestDistance = 2000
6666
local tick
6767
local pLocalClass
@@ -76,72 +76,82 @@ local vPlayerFuture
7676
local pLocalFuture
7777
local ping = 0
7878

79+
local settings = {
80+
MinDistance = 200,
81+
MaxDistance = 1000,
82+
MinHealth = 10,
83+
MaxHealth = 100,
84+
MinFOV = 0,
85+
MaxFOV = mFov:GetValue(),
86+
}
87+
7988
---@param me WPlayer
8089
---@return AimTarget? target
8190
local function GetBestTarget(me)
82-
local settings = {
91+
settings = {
8392
MinDistance = 200,
8493
MaxDistance = 1000,
8594
MinHealth = 10,
8695
MaxHealth = 100,
8796
MinFOV = 0,
88-
MaxFOV = 360,
97+
MaxFOV = mFov:GetValue(),
8998
}
9099

91-
local players = entities.FindByClass("CTFPlayer")
92-
local localPlayer = entities.GetLocalPlayer()
93-
if not localPlayer then return end
94-
95-
---@type Target[]
96-
local targetList = {}
97-
98-
-- Calculate target factors
99-
for entIdx, player in pairs(players) do
100-
if entIdx == localPlayer:GetIndex() then goto continue end
101-
102-
local distance = (player:GetAbsOrigin() - localPlayer:GetAbsOrigin()):Length()
103-
local health = player:GetHealth()
104-
105-
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), player:GetAbsOrigin())
106-
local fov = Math.AngleFov(engine.GetViewAngles(), angles)
107-
108-
local distanceFactor = Math.RemapValClamped(distance, settings.MinDistance, settings.MaxDistance, 1, 0.1)
109-
local healthFactor = Math.RemapValClamped(health, settings.MinHealth, settings.MaxHealth, 1, 0.5)
110-
local fovFactor = Math.RemapValClamped(fov, settings.MinFOV, settings.MaxFOV, 1, 0.5)
111-
112-
local factor = distanceFactor * healthFactor * fovFactor
113-
table.insert(targetList, { player = player, factor = factor })
114-
115-
::continue::
116-
end
117-
118-
-- Sort target list by factor
119-
table.sort(targetList, function(a, b)
120-
return a.factor > b.factor
121-
end)
122-
123-
local bestTarget = nil
124-
125-
for _, target in ipairs(targetList) do
126-
local player = target.player
127-
local aimPos = player:GetAbsOrigin()
128-
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), aimPos)
129-
local fov = Math.AngleFov(angles, engine.GetViewAngles())
130-
if fov > 360 then goto continue end
131-
132-
-- Visibility Check
133-
if not Helpers.VisPos(player, pLocalOrigin, aimPos) then goto continue end
134-
if target.player == nil or not target.player:IsAlive() or target.player:GetTeamNumber() == pLocal:GetTeamNumber() then goto continue end
135-
136-
-- Set as best target
137-
bestTarget = { entity = player, pos = aimPos, angles = angles, factor = target.factor }
138-
break
139-
140-
::continue::
141-
end
142-
143-
return bestTarget
100+
local players = entities.FindByClass("CTFPlayer")
101+
local localPlayer = entities.GetLocalPlayer()
102+
if not localPlayer then return end
103+
104+
---@type Target[]
105+
local targetList = {}
106+
107+
-- Calculate target factors
108+
for entIdx, player in pairs(players) do
109+
if entIdx == localPlayer:GetIndex() then goto continue end
110+
111+
local distance = (player:GetAbsOrigin() - localPlayer:GetAbsOrigin()):Length()
112+
local health = player:GetHealth()
113+
114+
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), player:GetAbsOrigin())
115+
local fov = Math.AngleFov(engine.GetViewAngles(), angles)
116+
117+
local distanceFactor = Math.RemapValClamped(distance, settings.MinDistance, settings.MaxDistance, 1, 0.1)
118+
local healthFactor = Math.RemapValClamped(health, settings.MinHealth, settings.MaxHealth, 1, 0.5)
119+
local fovFactor = Math.RemapValClamped(fov, settings.MinFOV, settings.MaxFOV, 1, 0.5)
120+
121+
local factor = distanceFactor * healthFactor * fovFactor
122+
table.insert(targetList, { player = player, factor = factor})
123+
124+
::continue::
144125
end
126+
127+
-- Sort target list by factor
128+
table.sort(targetList, function(a, b)
129+
return a.factor > b.factor
130+
end)
131+
132+
local bestTarget = nil
133+
134+
for _, target in ipairs(targetList) do
135+
local player = target.player
136+
local aimPos = player:GetAbsOrigin()
137+
local angles = Math.PositionAngles(localPlayer:GetAbsOrigin(), aimPos)
138+
local fov = Math.AngleFov(angles, engine.GetViewAngles())
139+
if fov > settings.MaxFOV then goto continue end
140+
141+
-- Visibility Check
142+
if not Helpers.VisPos(player, pLocalOrigin, aimPos) then goto continue end
143+
if target.player == nil or not target.player:IsAlive() or target.player:GetTeamNumber() == pLocal:GetTeamNumber() then goto continue end
144+
145+
-- Set as best target
146+
bestTarget = { entity = player, pos = aimPos, angles = angles, factor = target.factor }
147+
break
148+
149+
::continue::
150+
end
151+
152+
return bestTarget
153+
end
154+
145155

146156

147157
function TargetPositionPrediction(targetLastPos, time, targetEntity)
@@ -275,6 +285,8 @@ local function OnCreateMove(pCmd)
275285
local pWeapon = pLocal:GetPropEntity("m_hActiveWeapon")
276286
local players = entities.FindByClass("CTFPlayer") -- Create a table of all players in the game
277287
local time = mtime:GetValue()
288+
local closestPlayer
289+
if #players == 0 then return end -- Immediately check if there are any players in the game. If there aren't, return.
278290
--[--if we enabled trodlier assist run auto weapon script]
279291
if mAutoGarden:GetValue() == true then
280292
local flags = pLocal:GetPropInt( "m_fFlags" )
@@ -346,6 +358,7 @@ end
346358
fDistance = (vPlayerFuture - pLocalFuture):Length()
347359

348360
--[[-----------------------------Swing Prediction------------------------------------------------------------------------]]
361+
349362
local can_attack = false
350363
local stop = false
351364
swingrange = pWeapon:GetSwingRange()
@@ -362,23 +375,21 @@ end
362375
end
363376
end
364377

365-
--[--------------AimBot-------------------]
366-
if Maimbot:GetValue() and Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFuture) then
367-
--get hitbox of ennmy pelwis(jittery but works)
378+
--[--------------AimBot-------------------] --get hitbox of ennmy pelwis(jittery but works)
368379
local hitboxes = closestPlayer:GetHitboxes()
369380
local hitbox = hitboxes[4]
370381
local aimpos = (hitbox[1] + hitbox[2]) * 0.5
382+
if Maimbot:GetValue() and Helpers.VisPos(closestPlayer,vPlayerFuture + Vector3(0, 0, 150), pLocalFuture) and pLocal:InCond(17) then
371383

372-
if pLocal:InCond(17) then -- if can hit then aimbot
373384
-- change angles at target
374385
aimpos = Math.PositionAngles(pLocalOrigin, vPlayerFuture + Vector3(0, 0, 60))
375386
pCmd:SetViewAngles(aimpos:Unpack()) --engine.SetViewAngles(aimpos)
376387

377-
else -- if predicted position is visible then aim at it
388+
else -- if predicted position is visible then aim at it
378389
-- change angles at target
379390
aimpos = Math.PositionAngles(pLocalOrigin, aimpos)
380-
pCmd:SetViewAngles(aimpos:Unpack())
381-
end
391+
pCmd:SetViewAngles(aimpos:Unpack()) --engine.SetViewAngles(aimpos)
392+
382393
end
383394

384395
--[----------------wall check Future-------------]

0 commit comments

Comments
 (0)